I'm 16 and I'm pretty new to Mathematica. I've been working on a personal coding project which has some funky maths in it and I am kinda struggling. I've solved for the 4 polynomials but they answers are rather long and complex. I was wondering if anyone could help me simplify these (if they can be simplified that is). I tried using Simplify[%] but it didn't work for me.
Here's my code so far:
vars = {theta1'', phi1'', theta2'', phi2''}
sys = {2 l1 (Cos[theta1] theta1' phi1' + Sin[theta1] phi1'') +
l1 (Sin[theta2] Sin[phi1 - phi2] (theta2')^2 +
2 Cos[theta2] Cos[phi1 - phi2] theta2' phi2' +
Sin[theta2] Sin[phi1 - phi2] (phi2')^2 -
Cos[theta2] Sin[phi1 - phi2] theta2'' +
Cos[phi1 - phi2] Sin[theta2] phi2'') == 0,
l1 (-Sin[theta1] Sin[phi1 - phi2] (theta1')^2 +
2 Cos[theta1] Cos[phi1 - phi2] theta1' phi1' -
Sin[theta1] Sin[phi1 - phi2] (phi1')^2 +
Cos[theta1] Sin[phi1 - phi2] (theta1'')^2 +
Cos[phi1 - phi2] Sin[theta1] phi1'') +
l2 (2 Cos[theta2] theta2' phi2' + Sin[theta2] phi2'') == 0,
l1 (Sin[2 theta1] (theta1')^2 +
2 Sin[2 theta1] (phi1')^2 - (3 + Cos[2 theta1]) theta1'') +
2 (g Sin[theta1] +
Cos[theta1] l2 (Cos[phi1 - phi2] Sin[theta2] (theta2')^2 -
2*Cos[theta2] Sin[phi1 - phi2] theta2' phi2' +
Cos[phi1 - phi2] Sin[theta2] (phi2')^2 -
Cos[theta2] Cos[phi1 - phi2] theta2'' -
Sin[theta2] Sin[phi1 - phi2] phi2'')) == 0,
g Sin[theta2] + (1/2) l2 (Sin[2 theta2] (phi2')^2 - 2 theta2'') +
Cos[theta2] l1 (Cos[phi1 - phi2] Sin[theta1] (theta1')^2 +
2 Cos[theta1] Sin[phi1 - phi2] theta1' phi1' +
Cos[phi1 - phi2] Sin[theta1] (phi1')^2 -
Cos[theta1] Cos[phi1 - phi2] theta1'' +
Sin[theta1] Sin[phi1 - phi2] phi1'') == 0}
sol = NSolve[sys, vars]
sorry the equations are so long :)
also of there is any easier way to do this it would be greatly appreciated.
'is usually used to denote a derivative in Mathematica, so I would highly suggest avoiding them in your variables. – J. M.'s missing motivation May 04 '20 at 12:31_is used for pattern matching (e.g.f[x_] := Sin[x]), so that's out too. I now notice that you have parameters likel1,l2, andgthat do not have numerical values assigned to them, soNSolve[](which is intended for numerical solutions) is definitely not going to succeed here. – J. M.'s missing motivation May 04 '20 at 12:39vars /. Solve[sys, vars]seems to work. The solutions are really unwieldy. – Suba Thomas May 04 '20 at 15:04Solve[]/NSolve[]aren't appropriate. You wantNDSolve[]for this, after specifying numerical values for the parameters. Have you seen this and this? – J. M.'s missing motivation May 04 '20 at 15:06NDSolve[], as well as the functions to solve for, and the time interval you are considering. I would suggest (in general, not just for this problem) always making yourself familiar with simpler versions of your actual problem, before tackling the one of concern. In your specific situation, understand the 2D case well, so you can easily adapt to 3D. – J. M.'s missing motivation May 13 '20 at 01:07