# Problem with recursion depth

I want to solve a problem where I need to compute the Euler-Lagrange equation. However I receive a recursion problem, and I don't understand why.

\$RecursionLimit::reclim: Recursion depth of 1024 exceeded.


Everything executes fine except for the last three rows where this recursion problem occurs. I'm completely new to Mathematica so probably im just missing something trivial. Anyhow, my code is below: Any ideas on how to solve this?

v1x = D[L1*Cos[φ1[t]]*Cos[φ2[t]], t];
v1y = D[L1*Sin[φ2[t]], t];
v1z = D[L1*Cos[φ2[t]]*Sin[φ1[t]], t];

v2x = v1x +
D[(1/2)*L2*Cos[φ1[t]]*
Cos[φ2[t] + φ3[t]], t];
v2y = v1y + D[(1/2)*L2*Sin[φ2[t] + φ3[t]], t];
v2z = v1z +
D[(1/2)*L2*Cos[φ2[t] + φ3[t]]*
Sin[φ1[t]], t];

v1 = v1x^2 + v1y^2 + v1z^2;
v2 = v2x^2 + v2y^2 + v2z^2;

T1 = (1/2)*I1*D[φ1[t], t]^2;
T2 = (1/2)*I2*D[φ2[t], t]^2;
T3 = (1/2)*I3*(D[φ2[t], t] + D[φ3[t], t])^2;
T4 = (1/2)*m2*v1;
T5 = (1/2)*m3*v2;
U1 = (1/2)*L1*m2*g*Sin[φ2[t]];
U2 = m3*g (L1*Sin[φ2[t]] + (1/2)*L2*
Sin[φ2[t] + φ3[t]]);

L = Simplify[T1 + T2 + T3 + T4 + T5 - U1 - U2]

L1 = D[D[L, D[φ1[t], t]], t] - D[L, φ1[t]];
L2 = D[D[L, D[φ2[t], t]], t] - D[L, φ2[t]];
L3 = D[D[L, D[φ3[t], t]], t] - D[L, φ3[t]];

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey Feb 5 '15 at 20:54

You define L1 in terms of L1, which leads to a recursion. A much simplified but completely analogous example is

a = a+1


When this line is evaluated,

1. Mathematica creates the definition a = a+1
2. The expression a=a+1 evaluates to a+1, i.e. its RHS
3. Now it's time to evaluate a+1 part by part. The first part is a. But a has a definition which now evaluates to a+1.
4. ... and so on ad infinitum.

So the question is: what are you actually trying to achieve with a definition where a symbol appears both on the left and right hand side of the assignment operator?