MGSolveNonlinearEqnContinuouslyA.html
MotionGenesis input/output:
(1) % MotionGenesis file: MGSolveNonlinearEqnContinuouslyA.txt
(2) % Copyright (c) 2024 Motion Genesis LLC.
(3) % Purpose: Continuous solution to the nonlinear algebraic equation:
(4) % y^4 - 8*y - 0.3*t^2 - 9*sin(t) = 0
(5) % Related: MGSolveNonlinearEqnContinuouslyA.txt
(6) % MGSolveNonlinearEqnsContinuouslyB.txt
(7) % MGSolveNonlinearEqnsContinuouslyC.txt
(8) % MGFigureEightLinkageInverseKinematics.txt
(9) %---------------------------------------------------------------------------
(10) % For a continuous solution y(t), declare y and its 1st time-derivative.
(11) Variable y'
(12) eqnToSolve = y^4 - 8*y - 0.3*t^2 - 9*sin(t)
-> (13) eqnToSolve = y^4 - 0.3*t^2 - 9*sin(t) - 8*y
(14) %---------------------------------------------------------------------------
(15) % Differentiate eqnToSolve to form an equation that is _linear_ in y'.
(16) eqnDt = Dt( eqnToSolve )
-> (17) eqnDt = 4*y^3*y' - 0.6*t - 9*cos(t) - 8*y'
(18) %---------------------------------------------------------------------------
(19) % Calculate the values of y that satisfy eqnToSolve at t = 0.
(20) yValuesAt0 = GetQuarticRoots( Evaluate(eqnToSolve, t=0) = 0, y )
-> (21) yValuesAt0 = [-1 - 1.732051*imaginary; -1 + 1.732051*imaginary; -1.721328E-18; 2]
(22) %---------------------------------------------------------------------------
(23) % Solve eqnDt = 0 to form an ODE (ordinary differential equation) for y'.
(24) Solve( eqnDt = 0, y' )
-> (25) y' = 0.15*(t+15*cos(t))/(-2+y^3)
(26) %---------------------------------------------------------------------------
(27) % Set the initial value for y from one of the quadratic roots at t = 0.
(28) Input y = yValuesAt0[4] meters
(29) %---------------------------------------------------------------------------
(30) % List output quantities (for subsequent ODE command).
(31) Output t seconds, y meters
(32) %---------------------------------------------------------------------------
(33) % Set numerical integration parameters, solve ODEs, and plot results.
(34) Input tFinal = 20 seconds, tStep = 0.02 sec, absError = 1.0E-07
(35) ODE() MGSolveNonlinearEqnContinuouslyA
(36) Plot MGSolveNonlinearEqnContinuouslyA.1
(37) %--------------------------------------------------------------------
(38) % 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.