TransWikia.com

(2) Trying to model a simple second order ODE: Why time-step smaller is not better

Computational Science Asked by Quiet_waters on March 5, 2021

This question is related with this other question:
Trying to model a simple second order ODE.

On this other question, I get some useful comments on why the simulations are so terrible.

However, I have another question: Why time-step smaller is not better? Thank you in advance.

h=0.05 %h=0.5;
max=100;
np=max/h;
u=[];
y=[];
u(1)=0;
u(2)=-h^2/2-h;
y(1)=0;
y(2)=-h^2/2-h;
x=[0:h:max];
for i=3:np+1;
    u(i)=u(i-1)*(h+2)+u(i-2)*(-h-1)+h^2*x(i);
    y(i)=-(x(i))^2/2-(x(i));
end
close all
plot(x,u)
hold on
plot(x,y,'r')

enter image description here

enter image description here

One Answer

This is apparently the difference between $e^x$ and $(1+h)^{x/h}$ for different values of $h$. The latter is the term that occurs directly in solving the recursive inequalities for the global error, for small $h$ this converges to the exponential.

For $x=100$ and $h=0.5$ one gets the value 1.6529199107882081e+35, with $h=0.05$ the value is 2.3911022046137546e+42, which about fits the observed difference in magnitude. The exponential value is 2.6881171418161356e+43.

Correct answer by Lutz Lehmann on March 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP