MGSolveNonlinearEqnContinuously.html (MotionGenesis input/output).
(1) % MotionGenesis file: MGSolveNonlinearEqnContinuously.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) %---------------------------------------------------------------------------
(6) Variable y'
(7) eqnToSolve = y^4 - 8*y - 0.3*t^2 - 9*sin(t)
-> (8) eqnToSolve = y^4 - 0.3*t^2 - 9*sin(t) - 8*y
(9) yValuesAt0 = GetQuarticRoots( Evaluate(eqnToSolve, t=0) = 0, y )
-> (10) yValuesAt0 = [-1 - 1.732051*imaginary; -1 + 1.732051*imaginary; -1.721328E-18; 2]
(11) %---------------------------------------------------------------------------
(12) % Differentiate eqnToSolve to form an equation that is _linear_ in y'.
(13) eqnDt = Dt( eqnToSolve )
-> (14) eqnDt = 4*y^3*y' - 0.6*t - 9*cos(t) - 8*y'
(15) %---------------------------------------------------------------------------
(16) % Solve eqnDt = 0 to form an ODE (ordinary differential equation) for y'.
(17) Solve( eqnDt = 0, y' )
-> (18) y' = 0.15*(t+15*cos(t))/(-2+y^3)
(19) %---------------------------------------------------------------------------
(20) % Set the initial value for y from one of the quadratic roots at t = 0.
(21) Input y = yValuesAt0[4] meters
(22) %---------------------------------------------------------------------------
(23) % List output quantities (for subsequent ODE command).
(24) Output t seconds, y meters
(25) %---------------------------------------------------------------------------
(26) % Set numerical integration parameters, solve ODEs, and plot results.
(27) Input tFinal = 20 seconds, tStep = 0.02 sec, absError = 1.0E-07
(28) ODE() MGSolveNonlinearEqnContinuously
(29) Plot MGSolveNonlinearEqnContinuously.1
(30) %--------------------------------------------------------------------
(31) % Record input together with responses.
Saved by Motion Genesis LLC. MotionGenesis 6.4 Professional. Command names and syntax: Copyright (c) 2024 Motion Genesis LLC. All rights reserved.