# Solve two equations of motion?

GROUPS:
 Hi guys, Having a bit of an issue with one of my inputs on mathematica, i have two equations of motion for a complex system and trying to get a solution out of it. Keep getting the error message: NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.. But, as far as i'm concerned I have assigned a value to all my variables except the two i'm solving for. My input is below: eq1 := θ''[t] - A w^2 l Cos[θ[t]] Sin[w t] - l g Sin[θ[t]] + (l ϕ'[t]^2 Sin[θ[t] - ϕ[t]] + l ϕ''[t] Cos[θ[t] - ϕ[t]])/α == 0 eq2 := ϕ''[t] - (g Sin[ϕ[t]] + A w^2 Cos[ϕ[t]] Sin[w t] + l θ'[t] Sin[θ[t] - ϕ[t]] - l θ''[t] Cos[θ[t] - ϕ[t]])/L == 0 With[{g = 9.81, α = 20, l = 1, L = 1, A = 1, w = 50}, sol = NDSolve[{eq1, eq2, θ'[0.1] == 5, ϕ'[0.1] == 1, θ[0] == 0, ϕ[0] == 0}, {θ[t], ϕ[t]}, {t, 10}]] NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.. Thanks.
 Daniel Lichtblau 4 Votes One way to diagnose this is to add something like Print[sol] in the With. It will show quite clearly that the substitution did not take place. Why is that? Because it is a literal substitution, and the variables g et al do not appear literally in the body of the With statement.Here is a way to proceed. Define the ODE system inside the With statement. With[{g = 9.81, \[Alpha] = 20, l = 1, L = 1, A = 1, w = 50}, eq1 = \[Theta]''[t] - A w^2 l Cos[\[Theta][t]] Sin[w t] - l g Sin[\[Theta][ t]] + (l \[Phi]'[t]^2 Sin[\[Theta][t] - \[Phi][t]] + l \[Phi]''[t] Cos[\[Theta][t] - \[Phi][t]])/\[Alpha] == 0; eq2 = \[Phi]''[ t] - (g Sin[\[Phi][t]] + A w^2 Cos[\[Phi][t]] Sin[w t] + l \[Theta]'[t] Sin[\[Theta][t] - \[Phi][t]] - l \[Theta]''[t] Cos[\[Theta][t] - \[Phi][t]])/L == 0; sol = NDSolve[ {eq1, eq2, \[Theta]'[0.1] == 5, \[Phi]'[0.1] == 1, \[Theta][0] == 0, \[Phi][0] == 0}, {\[Theta][t], \[Phi][t]}, {t, 10}]; sol] This runs for me without error and produces a solution.--- edit ---Better way: force evalution inside With so the substitution of variables can occur. With[{g = 9.81, \[Alpha] = 20, l = 1, L = 1, A = 1, w = 50}, sol = Evaluate[ NDSolve[{eq1, eq2, \[Theta]'[0.1] == 5, \[Phi]'[0.1] == 1, \[Theta][0] == 0, \[Phi][0] == 0}, {\[Theta][t], \[Phi][t]}, {t, 10}]]; sol] --- end edit ---