# NDSolve with minimum value [closed]

I want to plot the decay of $O_3$ to $O_2$.

My system and my code (x = $O_3$, y = $O_2$):

ϵ=98;
k=3;
ozonProb = {x'[t]==-x[t]-x[t]*y[t]+ϵ*k*y[t],
y'[t]==x[t]*((1-y[t])/ϵ)-k*y[t],
x[0]==1,
y[0]==0}
loes = NDSolve[ozonProb, {x, y}, {t, 0, 240}]

Now when I plot my $O_3$ or $O_2$ concentration:

Plot[x[t]/.loes, {t, 0, 2922}]

both of them reach a negative value after ~2 years. Is there a problem in my system?

## closed as off-topic by Michael E2, user9660, MarcoB, Bob Hanlon, m_goldbergJan 9 '16 at 17:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Michael E2, Community, MarcoB, Bob Hanlon, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

• Your Plot extends outside the domain of the NDSolve solution requested, i.e., {t, 0, 240}. – Bob Hanlon Jan 9 '16 at 15:59

ϵ = 98;
k = 3;
ozonProb = {x'[t] == -x[t] - x[t]*y[t] + ϵ*k*y[t],
y'[t] == x[t]*((1 - y[t])/ϵ) - k*y[t], x[0] == 1,
y[0] == 0};
loes = NDSolve[ozonProb, {x, y}, {t, 0, 2922}];

Plot[Evaluate[{x[t], 100 y[t]} /. loes], {t, 0, 2922}]

Explanation

You solved your system in the range 0 .. 240 but your plot is in the range 0 .. 2922 . You got extrapolation difficulties.

loes2 = NDSolve[ozonProb, {x, y}, {t, 0, 3}];

Show[
Plot[Evaluate[{x[t], 100 y[t]} /. loes2], {t, 0, 3}],
Plot[Evaluate[{x[t], 100 y[t]} /. loes], {t, 0, 3}]
]

It is sufficient to solve the system in the range 0 ..2922 once.

• No explanation? – Michael E2 Jan 9 '16 at 13:27
• Rewi, please comment on the changes you made in the OP's code that fixed the original problem (e.g. You extended the domain over which NDSolve operated, etc). – MarcoB Jan 9 '16 at 16:01
• thank you :) If I want to use loes for i.e. {t,0,3} and {t,0,2922}, would it be better to define a Block for loes/use NDSolve twice (to get better WorkingPrecision i.e.?) or is it ok, if I use NDSolve with 2922 (the maximum time value) and plot in a range from 0 to 3 too? – gumpel Jan 9 '16 at 16:44
• @MarcoB Sorry, I thought that the code is easy to understand. – user36273 Jan 9 '16 at 16:45
• When you see the error, it's easy to understand. When you don't see the error, it's not; and a simple explanation in this case makes it obvious and easy for others. (+1) -- Side note: The old Plot use to let warnings about extrapolation escape, which would probably have solved it for the OP before posting. – Michael E2 Jan 9 '16 at 16:57