% MotionGenesis file: MGSolveNonlinearEqnContinuouslyA.txt % Copyright (c) 2024 Motion Genesis LLC. % Purpose: Continuous solution to the nonlinear algebraic equation: % y^4 - 8*y - 0.3*t^2 - 9*sin(t) = 0 % Related: MGSolveNonlinearEqnContinuouslyA.txt % MGSolveNonlinearEqnsContinuouslyB.txt % MGSolveNonlinearEqnsContinuouslyC.txt % MGFigureEightLinkageInverseKinematics.txt %--------------------------------------------------------------------------- % For a continuous solution y(t), declare y and its 1st time-derivative. Variable y' eqnToSolve = y^4 - 8*y - 0.3*t^2 - 9*sin(t) %--------------------------------------------------------------------------- % Differentiate eqnToSolve to form an equation that is _linear_ in y'. eqnDt = Dt( eqnToSolve ) %--------------------------------------------------------------------------- % Calculate the values of y that satisfy eqnToSolve at t = 0. yValuesAt0 = GetQuarticRoots( Evaluate(eqnToSolve, t=0) = 0, y ) %--------------------------------------------------------------------------- % Solve eqnDt = 0 to form an ODE (ordinary differential equation) for y'. Solve( eqnDt = 0, y' ) %--------------------------------------------------------------------------- % Set the initial value for y from one of the quadratic roots at t = 0. Input y = yValuesAt0[4] meters %--------------------------------------------------------------------------- % List output quantities (for subsequent ODE command). Output t seconds, y meters %--------------------------------------------------------------------------- % Set numerical integration parameters, solve ODEs, and plot results. Input tFinal = 20 seconds, tStep = 0.02 sec, absError = 1.0E-07 ODE() MGSolveNonlinearEqnContinuouslyA Plot MGSolveNonlinearEqnContinuouslyA.1 %-------------------------------------------------------------------- % Record input together with responses. Save MGSolveNonlinearEqnContinuouslyA.html Quit