# How can I find the equation for a graph?

**URL:** <https://community.wolfram.com/t/how-can-i-find-the-equation-for-a-graph/18887>\
**Category:** Questions\
**Tags:** modeling\
**Created:** [September 24, 2021, 3:58pm UTC](https://community.wolfram.com/t/how-can-i-find-the-equation-for-a-graph/18887 "2021-09-24T15:58:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivofred](https://avatars.discourse-cdn.com/v4/letter/i/e480ec/32.png) [@ivofred](https://community.wolfram.com/u/ivofred)\
**Post date:** [September 24, 2021, 3:58pm UTC](https://community.wolfram.com/t/how-can-i-find-the-equation-for-a-graph/18887/1 "2021-09-24T15:58:53Z")

</div>

Hi, I use NDSolve to get this numeric solution and then plot the solution. But I also need the equation for θ(t).  
How can I get the θ(t) equation?

thanks in advance.

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/3d7a6ab5-bf55-4fd5-9fa9-a620da8cffa6)

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [September 24, 2021, 4:09pm UTC](https://community.wolfram.com/t/how-can-i-find-the-equation-for-a-graph/18887/2 "2021-09-24T16:09:00Z")

</div>

Look up `DSolve`:

```
Clear[g];
DSolve[{\[Theta]''[t] + g/L*Sin[\[Theta][t]] == 0,
  \[Theta][0] == Pi/2, \[Theta]'[0] == 0},
 \[Theta][t], t]

```

---

<div class="post-metadata">

**Author:** ![ivofred](https://avatars.discourse-cdn.com/v4/letter/i/e480ec/32.png) [@ivofred](https://community.wolfram.com/u/ivofred)\
**Post date:** [September 24, 2021, 4:42pm UTC](https://community.wolfram.com/t/how-can-i-find-the-equation-for-a-graph/18887/3 "2021-09-24T16:42:12Z")

</div>

But the analytical solution for this nonlinear ODE is not good.

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [September 24, 2021, 6:30pm UTC](https://community.wolfram.com/t/how-can-i-find-the-equation-for-a-graph/18887/4 "2021-09-24T18:30:11Z")

</div>

You are right, it has branch cut discontinuities. But you can correct for them:

```
solN = Block[{g = 9.8, L = 1}, 
   NDSolveValue[{\[Theta]''[t] + g/L*Sin[\[Theta][t]] == 
      0, \[Theta][0] == Pi/2, \[Theta]'[0] == 0}, \[Theta], {t, 0, 
     10}]];
sol = DSolveValue[{\[Theta]''[t] + g/L*Sin[\[Theta][t]] == 
     0, \[Theta][0] == Pi/2, \[Theta]'[0] == 0}, \[Theta], t];
solDiscontinuities = 
  FunctionDiscontinuities[
   JacobiAmplitude[
    1/2 (-((Sqrt[2] Sqrt[g] t)/Sqrt[L]) + 2 EllipticF[\[Pi]/4, 2]), 
    2], t, Reals];
{discnt2, discnt1} = 
  t /. Solve[solDiscontinuities, t, Reals] /. {C[1] -> 0, g -> 9.8, 
    L -> 1};
solCorrected[t_] := sol[Mod[t, discnt2 - discnt1, discnt1]]
Block[{g = 9.8, L = 1}, {Plot[solCorrected[t], {t, 0, 10}],
  Plot[solN[t], {t, 0, 10}]}]

```
