Message Boards Message Boards

NDSolve an equation for a function including an integral?

Posted 1 year ago

Hi all, my code looks like the following:

l = 1
b = 0
m = 1
g = 9.81
ps = 0
dps = 1
H = 1/2*m*l^2*dps^2 - m*g*l*Cos[ps]
s = NDSolve[{b + t == 
    1/2*Integrate[Sqrt[2*m*l^2/(H + m*g*l*Cos[p[t]])], p[t]]}, 
  p[t], {t, 0, 100}]

I want to solve the equation in the NDSolve function. However I do not know why my way does not work. Can somebody help?
Thanks,
Emil

POSTED BY: Emil Rosanowski
2 Replies

From the documentation:

NDSolve[]: finds a numerical solution to the ordinary differential equations ...

But there is no derivative in your equation.

POSTED BY: Henrik Schachner

Does not work because Integrate can't you give a Antiderivative.

    Integrate[Sqrt[2*m*l^2/(H + m*g*l*Cos[p[t]])], p[t]]
    (* No way *)

We can solve like this:

      ClearAll["`*"]; Remove["`*"];
      l = 1;
      b = 0;
      m = 1;
      g = 9.81;
      ps = 0;
      dps = 1;
      H = 1/2*m*l^2*dps^2 - m*g*l*Cos[ps];
      EQ = D[b + t == 
         1/2*Integrate[Sqrt[2*m*l^2/(H + m*g*l*Cos[p[t]])], p[t]], t]
      s = DSolve[{EQ, p[0] == 0}, p[t], {t, 0, 100}] // 
        Quiet(*I assume a Initial condition !!! *)
      Plot[p[t] /. s, {t, 0, 100}, WorkingPrecision -> 20, 
       PlotPoints -> 100]

     Plot[p[t] /. s, {t, 0, 2}, PlotLabel -> "Analytically"]
     Plot[p[t] /. s, {t, 0, 1/2}, PlotLabel -> "Analytically"]
     s1 = NDSolve[{EQ, p[0] == 0}, p, {t, 0, 1/2}, 
        Method -> 
         "LinearlyImplicitEuler"];(*I assume a Initial condition !!! *)
     Plot[(p[t] /. s1), {t, 0, 1/2}, PlotLabel -> "Numerically"]
POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract