Let's say I have solved an ODE with Euler's forward method, and also solved it using RK4, in both cases for varying decreasing step sizes h. Is there any way to look at the graphs and "see" the order of accuracy of the methods?

Chaim Ferguson
2022-10-23
Answered

You can still ask an expert for help

Adalyn Pitts

Answered 2022-10-24
Author has **15** answers

Yes, graph the differences of the results for stepsizes $h$ and $2h$h as double-logarithmic plot. The graph should be of lines, and the slopes correspond to the order of the method.

More precisely, the numerical result for step size $h$ is in first order of approximation

${y}_{h}={y}_{\ast}+C\xb7{h}^{p}+D/h$

where $C$ accumulates the derivative factors for the method error and $D$ accounts for the floating point errors in the evaluation of every single step.

Thus the mentioned difference gives

${y}_{2h}-{y}_{h}=({2}^{p}-1)\xb7C\xb7{h}^{p}-D/(2h)$

so that for moderately small $h\gg \sqrt[p+1]{D/C}$ one gets

$\mathrm{log}({y}_{2h}-{y}_{h})\approx \mathrm{log}(({2}^{p}-1)\xb7C)+p\xb7\mathrm{log}(h)$

More precisely, the numerical result for step size $h$ is in first order of approximation

${y}_{h}={y}_{\ast}+C\xb7{h}^{p}+D/h$

where $C$ accumulates the derivative factors for the method error and $D$ accounts for the floating point errors in the evaluation of every single step.

Thus the mentioned difference gives

${y}_{2h}-{y}_{h}=({2}^{p}-1)\xb7C\xb7{h}^{p}-D/(2h)$

so that for moderately small $h\gg \sqrt[p+1]{D/C}$ one gets

$\mathrm{log}({y}_{2h}-{y}_{h})\approx \mathrm{log}(({2}^{p}-1)\xb7C)+p\xb7\mathrm{log}(h)$

asked 2022-07-23

In particular, if Euler's method is implemented on a computer, what's the minimum step size that can be used before rounding errors cause the Euler approximations to become completely unreliable?

I presume it's when step size reaches the machine epsilon? E.g. if machine epsilon is e-16, then once step size is roughly e-16, the Euler approximations are unreliable.

I presume it's when step size reaches the machine epsilon? E.g. if machine epsilon is e-16, then once step size is roughly e-16, the Euler approximations are unreliable.

asked 2022-09-19

I am trying to show that, for the equation

${y}^{\prime}+\alpha y=0$

alternating between a forward Euler method step for ${y}_{2n}$ and a backward Euler step for ${y}_{2n+1}$ with time-step $h$ is equivalent to

${y}_{n+1}=\frac{1-\alpha h}{1+\alpha h}{y}_{n}$

I have that

${y}_{1}={y}_{0}+h(-\alpha {y}_{0})=(1-\alpha h){y}_{0}$

How exactly $(1+\alpha h)$ works into this I don't see. If I just press forward anyway, using the trapezoid rule for the backward Euler step next, and call ${\hat{y}}_{n}$ the approximation of ${y}_{n}$ using the forward Euler method, I get

${y}_{2}={y}_{1}+h\left(\frac{{y}_{1}+{\hat{y}}_{2}}{2}\right)$

I'm kind of doing this a priori but that seems right to me: the trapezoid rule is to multiply the change in the $x$-axis by the average of the bases which are ${y}_{1}$ and ${y}_{2}$. This becomes

${y}_{2}={y}_{1}+h\left(\frac{{y}_{1}+(1-\alpha h){y}_{1}}{2}\right)=(1+h\left(\frac{2-\alpha h}{2}\right)){y}_{1}$

This doesn't seem to be shaping up to the form I'm supposed to be getting. Am I doing something wrong?

${y}^{\prime}+\alpha y=0$

alternating between a forward Euler method step for ${y}_{2n}$ and a backward Euler step for ${y}_{2n+1}$ with time-step $h$ is equivalent to

${y}_{n+1}=\frac{1-\alpha h}{1+\alpha h}{y}_{n}$

I have that

${y}_{1}={y}_{0}+h(-\alpha {y}_{0})=(1-\alpha h){y}_{0}$

How exactly $(1+\alpha h)$ works into this I don't see. If I just press forward anyway, using the trapezoid rule for the backward Euler step next, and call ${\hat{y}}_{n}$ the approximation of ${y}_{n}$ using the forward Euler method, I get

${y}_{2}={y}_{1}+h\left(\frac{{y}_{1}+{\hat{y}}_{2}}{2}\right)$

I'm kind of doing this a priori but that seems right to me: the trapezoid rule is to multiply the change in the $x$-axis by the average of the bases which are ${y}_{1}$ and ${y}_{2}$. This becomes

${y}_{2}={y}_{1}+h\left(\frac{{y}_{1}+(1-\alpha h){y}_{1}}{2}\right)=(1+h\left(\frac{2-\alpha h}{2}\right)){y}_{1}$

This doesn't seem to be shaping up to the form I'm supposed to be getting. Am I doing something wrong?

asked 2022-07-15

This question was asked in CSIR. please help me to find out correct choice

Let $y(t)$ satisfy the differential equation

${y}^{\prime}=\lambda y;y(0)=1$

. Then the backward Euler method for $n>1$ and $h>0$

$\frac{{y}_{n}-{y}_{n-1}}{h}=\lambda {y}_{n};\phantom{\rule{1em}{0ex}}y(0)=1$

yields

1. a first order approximation to ${e}^{\lambda nh}$

2. a polynomial approximation to ${e}^{\lambda nh}$

3. a rational function approximation to ${e}^{\lambda nh}$

4. a Chebyshev polynomial approximation to ${e}^{\lambda nh}$

Let $y(t)$ satisfy the differential equation

${y}^{\prime}=\lambda y;y(0)=1$

. Then the backward Euler method for $n>1$ and $h>0$

$\frac{{y}_{n}-{y}_{n-1}}{h}=\lambda {y}_{n};\phantom{\rule{1em}{0ex}}y(0)=1$

yields

1. a first order approximation to ${e}^{\lambda nh}$

2. a polynomial approximation to ${e}^{\lambda nh}$

3. a rational function approximation to ${e}^{\lambda nh}$

4. a Chebyshev polynomial approximation to ${e}^{\lambda nh}$

asked 2022-11-04

$\int {e}^{-3t}cos(2-\sqrt{3}t)dt$

I have been asked to evaluate that using complex exponential/euler's method. I have done many similar questions but all of them had something like (cos3x), sin(5t) etc. This is the first time I have come across a question where its of the format (cos a+bx) and cannot understand how to deal with the extra term. I have been stuck for a while now and have thus decided to ask the community for help, please help me out.

I have been asked to evaluate that using complex exponential/euler's method. I have done many similar questions but all of them had something like (cos3x), sin(5t) etc. This is the first time I have come across a question where its of the format (cos a+bx) and cannot understand how to deal with the extra term. I have been stuck for a while now and have thus decided to ask the community for help, please help me out.

asked 2022-05-09

We have been told that ${u}^{\prime}(t)=u(t)$ and $u(0)=1$ from this information we can conclude that $u(t)={e}^{x}$

Show that ${u}_{k}=(1+h{)}^{k},k=0,1,...$ is an approximation for $u(kh)$ using Euler's method

My current thoughts are that h is the interval by which we increment, but I am not sure where to go from there.

Show that ${u}_{k}=(1+h{)}^{k},k=0,1,...$ is an approximation for $u(kh)$ using Euler's method

My current thoughts are that h is the interval by which we increment, but I am not sure where to go from there.

asked 2022-06-21

How do you work out if Euler's method overestimates the actual solution, for the ODE:

$\frac{dy}{dx}=24\mathrm{tan}(\pi x)$

With steps of 0.25 from $1\le x\le 2$?

$\frac{dy}{dx}=24\mathrm{tan}(\pi x)$

With steps of 0.25 from $1\le x\le 2$?

asked 2022-10-15

Consider the ODE

$f(u)\equiv {u}^{\prime}=au+b,\phantom{\rule{mediummathspace}{0ex}}\phantom{\rule{mediummathspace}{0ex}}\phantom{\rule{mediummathspace}{0ex}}u({t}_{0}=0)\equiv {u}^{0}={u}_{0}$

For a timestep $k$, the forward-difference approximator for ${u}^{\prime}$ gives the Euler update as

${u}^{n+1}={u}^{n}+kf({u}^{n})={u}^{n}+k(a{u}^{n}+b)$

I am trying to come up with a closed form expression for ${u}^{n}$, that is, one that involves only the constants $a,b,{u}_{0},k$.

I've tried to do this by first writing ${u}^{n}$ as a cumulative sum

${u}^{n}={u}^{n}+k(a{u}^{n}+b)={u}_{0}+\sum _{i=0}^{n-1}k(a{u}^{i}+b)$

I then tried to expand the sum on the right and see if there was any easily identifiable pattern to write more generally, or if it would perhaps resemble an expansion of some other known function.After some ugly algebra, this is something like

$\begin{array}{rl}{u}^{n}& ={u}_{0}+k(a{u}_{0}+b)+k(a{u}_{1}+b)+k(a{u}_{2}+b)+...\\ & ={u}_{0}+k(a{u}_{0}+b)+({k}^{2}a+k)(a{u}_{0}+b)+({k}^{3}{a}^{2}+2{k}^{2}a+k)(a{u}_{0}+b)+...\\ & ={u}_{0}+({k}^{3}{a}^{2}+3{k}^{2}a+3k+...)(a{u}_{0}+b)\end{array}$

Nothing jumps out to me, and I'm not sure this approach is promising. Any ideas?

I've massaged it some more and found that it can be written as

${u}^{n}=(1+ka{)}^{n}{u}_{0}+{C}_{n}$

Where C is a function of a,b,k,n, which I've yet to deduce...

$f(u)\equiv {u}^{\prime}=au+b,\phantom{\rule{mediummathspace}{0ex}}\phantom{\rule{mediummathspace}{0ex}}\phantom{\rule{mediummathspace}{0ex}}u({t}_{0}=0)\equiv {u}^{0}={u}_{0}$

For a timestep $k$, the forward-difference approximator for ${u}^{\prime}$ gives the Euler update as

${u}^{n+1}={u}^{n}+kf({u}^{n})={u}^{n}+k(a{u}^{n}+b)$

I am trying to come up with a closed form expression for ${u}^{n}$, that is, one that involves only the constants $a,b,{u}_{0},k$.

I've tried to do this by first writing ${u}^{n}$ as a cumulative sum

${u}^{n}={u}^{n}+k(a{u}^{n}+b)={u}_{0}+\sum _{i=0}^{n-1}k(a{u}^{i}+b)$

I then tried to expand the sum on the right and see if there was any easily identifiable pattern to write more generally, or if it would perhaps resemble an expansion of some other known function.After some ugly algebra, this is something like

$\begin{array}{rl}{u}^{n}& ={u}_{0}+k(a{u}_{0}+b)+k(a{u}_{1}+b)+k(a{u}_{2}+b)+...\\ & ={u}_{0}+k(a{u}_{0}+b)+({k}^{2}a+k)(a{u}_{0}+b)+({k}^{3}{a}^{2}+2{k}^{2}a+k)(a{u}_{0}+b)+...\\ & ={u}_{0}+({k}^{3}{a}^{2}+3{k}^{2}a+3k+...)(a{u}_{0}+b)\end{array}$

Nothing jumps out to me, and I'm not sure this approach is promising. Any ideas?

I've massaged it some more and found that it can be written as

${u}^{n}=(1+ka{)}^{n}{u}_{0}+{C}_{n}$

Where C is a function of a,b,k,n, which I've yet to deduce...