Message Boards Message Boards

NDSolve not producing a smooth solution of an oscillatory function?

Posted 2 years ago

Why I am not getting a smooth solution, it should be a smooth oscillatory function

NDSolve[Rationalize[
  SetPrecision[{y1'[x] + 4 y1[x]/x == 
     0, (4 y2'[x])/x + (10^-36 x^6 y2[x] + 0.5 y1'[x]* y2'[x])/y1[x] +
       y2''[x] == 0, y1[1] == 10^33, y2'[1] == 0, y2[1] == 10^8}, 
   10]], {y1, y2}, {x, 10^0, 10^15}, 
 Method -> {"Chasing", "ExtraPrecision" -> 10, 
   "ChasingType" -> "NonlinearChasing"}, MaxSteps -> 10000000]
POSTED BY: John Wick
2 Replies

By the way, DSolve works on this problem and yields an exact solution.

It oscillates too rapidly for Plot[] to render a smooth curve, unless you zoom in a great deal.

sol = First@
   DSolve[{y1'[x] + 4 y1[x]/x == 
      0, (4 y2'[x])/x + (10^-36 x^6 y2[x] + 1/2 y1'[x]*y2'[x])/y1[x] +
        y2''[x] == 0, y1[1] == 10^33, y2'[1] == 0, y2[1] == 10^8},
    {y1, y2}, {x, 10^0, 10^15}];

Plot[y2[10^12 + x/10^24] /. sol, {x, 0, 1}, WorkingPrecision -> 32]
POSTED BY: Michael Rogers

I do get smooth plots:

{sol1, sol2} = 
 NDSolveValue[{y1'[x] + 4 y1[x]/x == 
    0, (4 y2'[x])/x + (10^-36 x^6 y2[x] + 1/2 y1'[x]*y2'[x])/y1[x] + 
     y2''[x] == 0, y1[1] == 10^33, y2'[1] == 0, y2[1] == 10^8}, {y1, 
   y2}, {x, 10^0, 10^7}, MaxSteps -> 10000000]
Plot[sol1[x], {x, 1, 3}, PlotRange -> All]
Plot[sol2[x], {x, 1, 6000000}]
Plot[sol2[x], {x, 1000000, 2000000}]
POSTED BY: Gianluca Gorni
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