Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.2K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

Why doesn't NDSolve StepMonitor return values for derivative term?

Posted 11 years ago

In the evaluation below, I want both y[t] and y'[t] sown by StepMonitor, but for some reason y[t] is sown unevaluated. It appears from the output that the derivative is taken after t is replaced by its value like y'[t->value], rather than y'[t]/.t->value. Does anyone see my error?

{sol, steps} = 
  Reap[NDSolveValue[{y'[t] == -y[t], y[0] == 1}, {y[t], y'[t]}, {t, 0,
      5}, StepMonitor :> Sow[{t, y[t], y'[t]}]]];

Plot[sol, {t, 0, 5}, PlotLegends -> {"y[t]", "y'[t]"}]

enter image description here

steps[[1, 1 ;; 5]]

{{0.000190613, 0.999809, Derivative[1][y][0.000190613]}, {0.000381227,
   0.999619, Derivative[1][y][0.000381227]}, {0.00489873, 0.995113, 
  Derivative[1][y][0.00489873]}, {0.00941624, 0.990628, 
  Derivative[1][y][0.00941624]}, {0.0139337, 0.986163, 
  Derivative[1][y][0.0139337]}}
POSTED BY: David Keith
2 Replies
POSTED BY: Ilian Gachevski
Posted 11 years ago

Thank you, Ilian. That makes perfect sense. Now, please pour yourself a nice beer and have a very Merry Christmas!

Warm regards, David

POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard