MGSolveNonlinearEqnsContinuouslyB.html

MotionGenesis input/output:


   (1) % MotionGenesis file: MGSolveNonlinearEqnsContinuouslyB.txt
   (2) % Copyright (c) 2024 Motion Genesis LLC. All rights reserved.
   (3) % Purpose: Continuous solution to the nonlinear algebraic equations:
   (4) %          cos(qA) + 2*cos(qB) = 2 + 0.2*cos(t)
   (5) %          2*sin(qB) - sin(qA) = 0.3*sin(3*t)
   (6) % Related: MGSolveNonlinearEqnContinuouslyA.txt
   (7) %          MGSolveNonlinearEqnsContinuouslyB.txt
   (8) %          MGSolveNonlinearEqnsContinuouslyC.txt
   (9) %          MGFigureEightLinkageInverseKinematics.txt
   (10) %-------------------------------------------------------------------------------
   (11) Variable  qA', qB'
   (12) eqnToSolve[1] = cos(qA) + 2*cos(qB) - 2 - 0.2*cos(t)
-> (13) eqnToSolve[1] = -2 + cos(qA) + 2*cos(qB) - 0.2*cos(t)

   (14) eqnToSolve[2] = 2*sin(qB) - sin(qA) - 0.3*sin(3*t)
-> (15) eqnToSolve[2] = 2*sin(qB) - 0.3*sin(3*t) - sin(qA)

   (16) %-------------------------------------------------------------------------------
   (17) %   Differentiate eqnToSolve to form equations that are _linear_ in qA', qB'.
   (18) eqnDt = Dt( eqnToSolve )
-> (19) eqnDt[1] = 0.2*sin(t) - 2*sin(qB)*qB' - sin(qA)*qA'
-> (20) eqnDt[2] = 2*cos(qB)*qB' - 0.9*cos(3*t) - cos(qA)*qA'

   (21) %-------------------------------------------------------------------------------
   (22) %   Solve eqnDt = 0 to form an ODE (ordinary differential equation) for qA' and qB'
   (23) Solve( eqnDt = 0,   qA', qB' )
-> (24) qA' = 0.2*(sin(t)*cos(qB)-4.5*cos(3*t)*sin(qB))/sin(qA+qB)
-> (25) qB' = 0.1*(sin(t)*cos(qA)+4.5*cos(3*t)*sin(qA))/sin(qA+qB)

   (26) %-------------------------------------------------------------------------------
   (27) %   Form a set of equations that govern the values of qA and qB at t = 0.
   (28) eqnInitial = Evaluate( eqnToSolve, t = 0 )
-> (29) eqnInitial = [-2.2 + cos(qA) + 2*cos(qB);  2*sin(qB) - sin(qA)]

   (30) %-------------------------------------------------------------------------------
   (31) %   Solve the nonlinear equations at t = 0 to set initial values for qA and qB.
   (32) %   Since the equations are nonlinear, provide a guess for qA and qB
   (33) SolveSetInput( eqnInitial = 0,  qA = 20 degrees,  qB = 60 degrees )

->   %  INPUT has been assigned as follows:
->   %   qA                        65.28014881708943       degrees
->   %   qB                        27.01229395886647       degrees

   (34) %-------------------------------------------------------------------------------
   (35) %   List output quantities (for subsequent ODE command).
   (36) Output  t seconds,  qA degrees,  qB degrees
   (37) %--------------------------------------------------------------------
   (38) %   Set numerical integration parameters and solve ODEs.
   (39) Input  tFinal = 8 sec,  tStep = 0.02 sec,  absError = 1.0E-07
   (40) ODE()  MGSolveNonlinearEqnsContinuouslyB

   (41) %-------------------------------------------------------------------------------
   (42) %   Optional: Plot results.
   (43) % Plot MGSolveNonlinearEqnsContinuouslyB.1 [1, 2, 3]
   (44) %-------------------------------------------------------------------------------
   (45) %   Record input together with responses.
Saved by MotionGenesis 6.6 Professional user Motion Genesis LLC.
Portions (including program responses) are copyright (c) 2009-2026 Motion Genesis LLC.