# Solve this equation numerically using "NDSolve"?

**URL:** <https://community.wolfram.com/t/solve-this-equation-numerically-using-ndsolve/11800>\
**Category:** Questions\
**Tags:** equation-solving, numerical-computation\
**Created:** [January 10, 2018, 6:14pm UTC](https://community.wolfram.com/t/solve-this-equation-numerically-using-ndsolve/11800 "2018-01-10T18:14:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hampjonas](https://avatars.discourse-cdn.com/v4/letter/h/3ab097/32.png) [@hampjonas](https://community.wolfram.com/u/hampjonas)\
**Post date:** [January 10, 2018, 6:14pm UTC](https://community.wolfram.com/t/solve-this-equation-numerically-using-ndsolve/11800/1 "2018-01-10T18:14:15Z")

</div>

Hello, I am trying to derive the equations of motino for a simple pendulum using the Euler-Lagrange Equation. This works very well until I try to solve the equation numerically using “NDSolve”. The error code is: “Equation or list of equations expected instead of …”.  
Does someone has an idea?

```
Remove[L, g, M, Lagrange, T, V, eq, sol]
x = L*Sin[\[Theta][t]];
y = -L*Cos[\[Theta][t]];
x' = D[x, t]; 
y' = D[y, t];

T = M/2*(x' + y')^2;
V = M*g*y;
Lagrange = T - V;

eq = D[D[Lagrange, \[Theta]'], t] - D[Lagrange, \[Theta]];

L = 1; 
M = 1; 
g = 9.81;

sol = NDSolve[{eq, \[Theta][0] == Pi, \[Theta]'[0] == 
    0}, \[Theta], {t, 0, 10}]

```

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [January 10, 2018, 7:56pm UTC](https://community.wolfram.com/t/solve-this-equation-numerically-using-ndsolve/11800/2 "2018-01-10T19:56:16Z")

</div>

eq is not an equation. Try eq == 0 inside NDSolve

```
In[16]:= Remove[L, g, M, Lagrange, T, V, eq, sol]
x = L*Sin[\[Theta][t]];
y = -L*Cos[\[Theta][t]];
x' = D[x, t];
y' = D[y, t];

T = M/2*(x' + y')^2;
V = M*g*y;
Lagrange = T - V;

eq = D[D[Lagrange, \[Theta]'], t] - D[Lagrange, \[Theta]];

L = 1;
M = 1;
g = 9.81;

sol = NDSolve[{eq == 0, \[Theta][0] == Pi, \[Theta]'[0] == 
    0}, \[Theta], {t, 0, 10}]

Out[28]= {{\[Theta] -> 
   InterpolatingFunction[{{0., 10.}}, {
    5, 7, 2, {13}, {4}, 0, 0, 0, 0, Automatic, {}, {}, False}, {{0., 
    0.0010264848819015065`, 0.002052969763803013, 1.002052969763803, 
    2.002052969763803, 3.002052969763803, 4.0020529697638025`, 
    5.0020529697638025`, 6.0020529697638025`, 7.0020529697638025`, 
    8.002052969763803, 9.001026484881901, 10.}}, {
    Developer`PackedArrayForm, {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 
     30, 33, 36, 39}, CompressedData["
1:eJxTTMoPSmVkYGBQB2IJXZeQ34qcDgxoYFQcvzgAI98fLA==
"]}, {Automatic}]}}

```

---

<div class="post-metadata">

**Author:** ![hampjonas](https://avatars.discourse-cdn.com/v4/letter/h/3ab097/32.png) [@hampjonas](https://community.wolfram.com/u/hampjonas)\
**Post date:** [January 10, 2018, 8:38pm UTC](https://community.wolfram.com/t/solve-this-equation-numerically-using-ndsolve/11800/3 "2018-01-10T20:38:35Z")

</div>

Thank you very much, that helped. If I may, I have one more question:  
When I now want to plot the result, I used:

```
Plot[\[Theta], {t, 0, 10}]

```

Nothing happened. What can be the error?

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [January 10, 2018, 9:08pm UTC](https://community.wolfram.com/t/solve-this-equation-numerically-using-ndsolve/11800/4 "2018-01-10T21:08:43Z")

</div>

I plotted your result using

```
Plot[\[Theta][t] /. sol, {t, 0, 10}]

```

It’s constant, equal to Pi.
