Chronology Current Month Current Thread Current Date [Year List] [Month List (current year)] [Date Index] [Thread Index] [Thread Prev] [Thread Next] [Date Prev] [Date Next]

# Re: [Phys-L] Mathematica question; stiff differential equation

The responses have been helpful and interesting. I have heard of “stiff” DEs before but never understood what the term meant. Now I see it’s in part because it can mean many things, but overall it means a numerical instability in a DE.

But there’s still one part I’d like some more insight about. Is the problem with the DE itself (and the numerical method used to solve it) or is the problem with certain points only (what you call fixed points)? It seems to me this is two quite different questions.

I’ll illustrate by going back to my example. We’ll initially avoid the fixed point by again starting our ball in motion at y=99. But this time let’s reverse the velocity direction and throw the ball upward. So let’s put this code into Mathematica:

s = NDSolve[{y'[t] == Sqrt[2 9.8 (100 - y[t])], y == 99}, y, {t, 0, 4}]

Plot[Evaluate[y[t] /. s], {t, 0, 4}]

Can everyone guess what happens when I execute this?

The answer is it runs fine until it hits the peak. At that point, Mathematica reports: “"

The plot runs from 99 up to 100 and then abruptly ends. It doesn’t flatline at the peak. It just ends there.

In contrast, if we run:

s2 = NDSolve[{y''[t] == -9.8, y == 99, y' == Sqrt[2 9.8 (100 - y)]}, y, {t, 0, 4}]

Plot[Evaluate[y[t] /. s2], {t, 0, 4}]

then there is no problem. You get exactly the expected up and down quadratic.

So indeed, what you all are saying is correct. The problem is that in the energy approach we have a term like v^2 in the KE. When we differentiate it w.r.t. y, we get 2 v dv/dy and dv/dy = dv/dt dt/dy = a/v which is well defined everywhere *except* at v=0. Nevertheless the correct answer is 2 v a/v = 2 a everywhere including at v=0.

I have to ask once more: Is the problem in how the numerical integration is performed, or is there really some information missing in the energy equation. (In the present example, the missing information might be: Use l’Hopital’s rule at any point that v=0, but I could be oversimplifying the real issue.)

A possibly related issue is to think about a mass oscillating on a spring. In the energy equation, I’ve lost information about the sign of the velocity v. This is particularly problematic at v=0 because zero is unsigned. But again I might be oversimplifying.

-Carl

On Dec 8, 2020, at 7:20 PM, John Denker via Phys-l <phys-l@mail.phys-l.org> wrote:

On 12/8/20 10:22 AM, Francois Primeau via Phys-l wrote:

The problem is that Mathematica knows mathematics but not physics.

Yes.

As stated, your problem is ill posed because you start it off at a
point at which the derivative does not exist.

Yes.

Perhaps there is a way in Mathematica to start off your problem at
y=100-epsilon for epsilon>0 and then take the limit as epsilon
approaches zero.
Yes, that's one possibility.

Earlier:

an easy way to avoid the fact that the derivative of the square root
function does not exist at zero is to convert your equation into the
system y’=v and v’=g.
That's even better.

===============

FP's answer is correct and concise. Perhaps I can fill in a couple of
details. For starters, let's be clear: Do not confuse the statement:
y'' = -g for all time (which is true)

with the statement:
y'' = -g for all y (which is not true).

Beware: y simply does not exist for y>100.
Similarly: y is not twice differentiable for y>=100.

In more detail:
h = 100 - y # by fiat; new convenient variable
h' = -y' # by differentiating
h' = √(2 g h) for all h>=0 # from conservation
h'' = ½ √(2 g h)¯¹ ⋅ 2 g h' for all h>0 (not including h=0)
= g for all h>0

Mathematica knows mathematics but not physics

Mathematica has no reason to compute h'', and would be unable to compute
it even if it wanted to. So (h,h') = (0,0) is a fixed point.

This is a huge problem, because h'' is important to the physics, and is
presumably deeply built into your intuition. Alas it is not built into
this equation.

This corresponds to Zeno's paradox in reverse. It takes an infinite number
of steps to get away from the fixed point.

Here's another bit of jargon that may help: This is a /stiff/ differential
equation. Pretty much worst-case stiff.
https://en.wikipedia.org/wiki/Stiff_equation

Useful practical rule of thumb: Avoid(*) using differential equations that
bump up against the boundaries of the domain where the variables are defined.

(*) I was going to say "avoid like sin" or "avoid like the plague"
but we need to find better similes. It turns out people aren't very
good at avoiding those things.

convert your equation into the system y’=v and v’=g.

That would be my recommendation.
That is better math-wise as well as physics-wise.

Among other things, that sets you up to use a symplectic integrator, which
will probably outperform anything else rather spectacularly.

https://www.av8n.com/physics/symplectic-integrator.htm
_______________________________________________
Forum for Physics Educators
Phys-l@mail.phys-l.org
https://www.phys-l.org/mailman/listinfo/phys-l

-----
Carl E. Mungan, Professor of Physics 410-293-6680 (O) -3729 (F)
Naval Academy Stop 9c, 572C Holloway Rd, Annapolis MD 21402-1363
mailto:mungan@usna.edu http://usna.edu/Users/physics/mungan/