Message Boards Message Boards

Higher order derivates: Plotting Problems with orders > 4

Posted 10 years ago

First I define the 5th order derivative of my function of t to be sin(t):

f = Sin[t];
tMax = Pi/2;

nds = NDSolve[{
    x'''''[t] == f,
    x''''[0] == 0,
    x'''[0] == 0,
    x''[0] == 0,
    x'[0] == 0,
    x[0] == 0

    }, x, {t, 0, tMax}, 
    MaxSteps -> Infinity];

Then I make up the Plotting command:

plot[?_] := 
 Plot[Evaluate[? /. nds], {t, 0, tMax}, Frame -> True, 
  PlotRange -> All]

xt = Evaluate[x[tMax] /. nds][[1]] "m"; "x(t)" -> xt
plot[x[t]]

ct = Evaluate[x'''''[tMax] /. nds][[
   1]] "m/sec^5";  "c(t)" -> ct
plot[x'''''[t]]

?his works well up to the 3rd detivative, but at the 4th and 5th it starts oscillating like crazy. The function of the 5th derivative should be a plain Sinus, but it looks like this:

http://s24.postimg.org/6wifn1gx1/5thderivative.png

When I define lower derivatives the expected function always comes out clearly, but it always starts breaking down at order 4 or 5. I tried to increase WorkingPrecision, but that only made it worse. Any ideas?

Scratching my head,

Yukterez

PS: I work on Mathematica 9, because version 10 was unstable in various ways. If this problem does not appear in version 10 please tell me, then I will reinstall it.

Attachments:
POSTED BY: Simon Tyran
5 Replies

Simon,

As suggested by Frank, you can use DSolve[] for this problem. The problem with NDSolve[] is that solution interpolation order is not enough to produce "nice" result. You need to set InterpolationOrder option to get a better one:

nds = NDSolve[{x'''''[t] == f, x''''[0] == 0, x'''[0] == 0, 
    x''[0] == 0, x'[0] == 0, x[0] == 0}, x, {t, 0, tMax}, 
   MaxSteps -> Infinity,
    Method -> {"ImplicitRungeKutta", "DifferenceOrder" -> 20},
   InterpolationOrder -> All
   ];

I.M.

POSTED BY: Ivan Morozov
Posted 10 years ago

Superb! This brings nice results.

Excited,

Yukterez

POSTED BY: Simon Tyran

MaxSteps -> Infinity doesn't force the algorithm to take an infinite number of steps; it removes the limit on the number of steps, which is then determined by numerical goals set for the calculation. What you're seeing is the result of the NDSolve not being able to produce an exact solution, since it uses polynomial interpolation. If you used a quadratic instead of a sine function, you might get the result you expect. I haven't tried it so I don't know.

POSTED BY: Frank Kampas

The "problem" does occur using Mathematica 10. What you're seeing is the result of using a numerical algorithm, which takes finite steps and makes approximations. If you change from NDSolve to DSolve, the "problem" goes away.

POSTED BY: Frank Kampas
Posted 10 years ago

The "problem" does occur using Mathematica 10.

Ok so I'll stay with version 9.

What you're seeing is the result of using a numerical algorithm, which takes finite steps

Therefor I used "MaxSteps -> Infinity", but with no success

If you change from NDSolve to DSolve, the "problem" goes away.

This is what I did and it works, but I was not sure if the NDSolve error was on me. I expected Mathematica to plot the 7th derivate easier than the 0th, because it is defined directly while the lower derivatives need to be further evaluated. Curiously the Plot for the low derivatives gives the correct results, while depending on the incorrectly plotted higher derivate which is a straigt an plain Sin[t].

Still wondering,

Yukterez

POSTED BY: Simon Tyran
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