Understanding Heun's method
up vote
1
down vote
favorite
I want to have an intuitive understanding of Heun's method when applied to a 2nd order ODE rather than rely on plug and chug techniques.
The iteration is calculated by the formula $y_{n+1}=y_n+frac{h}4(k_1+3k_2)$
where $k_1=f(x_n,y_n)$ ,$k_2=f(x_n+frac{2h}{3},y_n+frac{2hk_1}{3})$
Approximate $y(0.1)$ with step-size $h=0.1$ given $y''=x^2+y-xy'$ and $y(0)=1,y'(0)=0$
Now I can convert a second order ODE to a first order by substituting $u=y', u'=y''$, so $x_0=0,y_0=1,u_0=0$ to give $u'=x^2+y-xu$
The principle behind Heun's method is to use the average of the two slopes, with $k_1$ and $k_2$ denoting the slopes at the initial value and at the first iteration.
Now the slope of the graph is $y'$ and in this example $y'=u$ so finding the value of u at the respective points gives us the graph. We know that $u(0)=0$ therefore the slope at $(0,1)=0$ so $k_1=0$, $k_2$=$f(frac{1}{16}$,$frac{15}{16})$
My only issue is that it seems to be a circular problem. Before I can work out $u$ I have to know $u'$, but $u'$ is obtained based on the value of $u$.
Ralston Graph
differential-equations numerical-methods
|
show 1 more comment
up vote
1
down vote
favorite
I want to have an intuitive understanding of Heun's method when applied to a 2nd order ODE rather than rely on plug and chug techniques.
The iteration is calculated by the formula $y_{n+1}=y_n+frac{h}4(k_1+3k_2)$
where $k_1=f(x_n,y_n)$ ,$k_2=f(x_n+frac{2h}{3},y_n+frac{2hk_1}{3})$
Approximate $y(0.1)$ with step-size $h=0.1$ given $y''=x^2+y-xy'$ and $y(0)=1,y'(0)=0$
Now I can convert a second order ODE to a first order by substituting $u=y', u'=y''$, so $x_0=0,y_0=1,u_0=0$ to give $u'=x^2+y-xu$
The principle behind Heun's method is to use the average of the two slopes, with $k_1$ and $k_2$ denoting the slopes at the initial value and at the first iteration.
Now the slope of the graph is $y'$ and in this example $y'=u$ so finding the value of u at the respective points gives us the graph. We know that $u(0)=0$ therefore the slope at $(0,1)=0$ so $k_1=0$, $k_2$=$f(frac{1}{16}$,$frac{15}{16})$
My only issue is that it seems to be a circular problem. Before I can work out $u$ I have to know $u'$, but $u'$ is obtained based on the value of $u$.
Ralston Graph
differential-equations numerical-methods
1
Your formulas are for the Ralston method, you then describe verbally the implicit trapezoidal method but Heun's method is usually the explicit trapezoidal method. Please check your sources on what you really want resp. should do.
– LutzL
Nov 22 at 4:34
So you've converted a second-order equation to first-order. Can you write down what $f$ is for the first-order equation?
– Rahul
Nov 22 at 4:36
For the first order equation is $f=x^2+y-xu$, or am I making $u$ the subject since that is of interest? It is called Heun's method in my notes and the above formula is what is given.
– kj980
Nov 22 at 4:37
1
That's not correct. When you reduce the order you should get a system of first-order equations: en.wikipedia.org/wiki/…. In this case, $f$ should be a function $mathbb R^2tomathbb R^2$ which maps $(y,u)$ to $(y',u')$.
– Rahul
Nov 22 at 5:25
@LutzL: It was news to me too, but Wikipedia says "Heun's method" also sometimes refers to Ralston's method, and cites a textbook by J. Leader.
– Rahul
Nov 22 at 5:29
|
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I want to have an intuitive understanding of Heun's method when applied to a 2nd order ODE rather than rely on plug and chug techniques.
The iteration is calculated by the formula $y_{n+1}=y_n+frac{h}4(k_1+3k_2)$
where $k_1=f(x_n,y_n)$ ,$k_2=f(x_n+frac{2h}{3},y_n+frac{2hk_1}{3})$
Approximate $y(0.1)$ with step-size $h=0.1$ given $y''=x^2+y-xy'$ and $y(0)=1,y'(0)=0$
Now I can convert a second order ODE to a first order by substituting $u=y', u'=y''$, so $x_0=0,y_0=1,u_0=0$ to give $u'=x^2+y-xu$
The principle behind Heun's method is to use the average of the two slopes, with $k_1$ and $k_2$ denoting the slopes at the initial value and at the first iteration.
Now the slope of the graph is $y'$ and in this example $y'=u$ so finding the value of u at the respective points gives us the graph. We know that $u(0)=0$ therefore the slope at $(0,1)=0$ so $k_1=0$, $k_2$=$f(frac{1}{16}$,$frac{15}{16})$
My only issue is that it seems to be a circular problem. Before I can work out $u$ I have to know $u'$, but $u'$ is obtained based on the value of $u$.
Ralston Graph
differential-equations numerical-methods
I want to have an intuitive understanding of Heun's method when applied to a 2nd order ODE rather than rely on plug and chug techniques.
The iteration is calculated by the formula $y_{n+1}=y_n+frac{h}4(k_1+3k_2)$
where $k_1=f(x_n,y_n)$ ,$k_2=f(x_n+frac{2h}{3},y_n+frac{2hk_1}{3})$
Approximate $y(0.1)$ with step-size $h=0.1$ given $y''=x^2+y-xy'$ and $y(0)=1,y'(0)=0$
Now I can convert a second order ODE to a first order by substituting $u=y', u'=y''$, so $x_0=0,y_0=1,u_0=0$ to give $u'=x^2+y-xu$
The principle behind Heun's method is to use the average of the two slopes, with $k_1$ and $k_2$ denoting the slopes at the initial value and at the first iteration.
Now the slope of the graph is $y'$ and in this example $y'=u$ so finding the value of u at the respective points gives us the graph. We know that $u(0)=0$ therefore the slope at $(0,1)=0$ so $k_1=0$, $k_2$=$f(frac{1}{16}$,$frac{15}{16})$
My only issue is that it seems to be a circular problem. Before I can work out $u$ I have to know $u'$, but $u'$ is obtained based on the value of $u$.
Ralston Graph
differential-equations numerical-methods
differential-equations numerical-methods
edited Nov 22 at 7:18
asked Nov 22 at 4:12
kj980
62
62
1
Your formulas are for the Ralston method, you then describe verbally the implicit trapezoidal method but Heun's method is usually the explicit trapezoidal method. Please check your sources on what you really want resp. should do.
– LutzL
Nov 22 at 4:34
So you've converted a second-order equation to first-order. Can you write down what $f$ is for the first-order equation?
– Rahul
Nov 22 at 4:36
For the first order equation is $f=x^2+y-xu$, or am I making $u$ the subject since that is of interest? It is called Heun's method in my notes and the above formula is what is given.
– kj980
Nov 22 at 4:37
1
That's not correct. When you reduce the order you should get a system of first-order equations: en.wikipedia.org/wiki/…. In this case, $f$ should be a function $mathbb R^2tomathbb R^2$ which maps $(y,u)$ to $(y',u')$.
– Rahul
Nov 22 at 5:25
@LutzL: It was news to me too, but Wikipedia says "Heun's method" also sometimes refers to Ralston's method, and cites a textbook by J. Leader.
– Rahul
Nov 22 at 5:29
|
show 1 more comment
1
Your formulas are for the Ralston method, you then describe verbally the implicit trapezoidal method but Heun's method is usually the explicit trapezoidal method. Please check your sources on what you really want resp. should do.
– LutzL
Nov 22 at 4:34
So you've converted a second-order equation to first-order. Can you write down what $f$ is for the first-order equation?
– Rahul
Nov 22 at 4:36
For the first order equation is $f=x^2+y-xu$, or am I making $u$ the subject since that is of interest? It is called Heun's method in my notes and the above formula is what is given.
– kj980
Nov 22 at 4:37
1
That's not correct. When you reduce the order you should get a system of first-order equations: en.wikipedia.org/wiki/…. In this case, $f$ should be a function $mathbb R^2tomathbb R^2$ which maps $(y,u)$ to $(y',u')$.
– Rahul
Nov 22 at 5:25
@LutzL: It was news to me too, but Wikipedia says "Heun's method" also sometimes refers to Ralston's method, and cites a textbook by J. Leader.
– Rahul
Nov 22 at 5:29
1
1
Your formulas are for the Ralston method, you then describe verbally the implicit trapezoidal method but Heun's method is usually the explicit trapezoidal method. Please check your sources on what you really want resp. should do.
– LutzL
Nov 22 at 4:34
Your formulas are for the Ralston method, you then describe verbally the implicit trapezoidal method but Heun's method is usually the explicit trapezoidal method. Please check your sources on what you really want resp. should do.
– LutzL
Nov 22 at 4:34
So you've converted a second-order equation to first-order. Can you write down what $f$ is for the first-order equation?
– Rahul
Nov 22 at 4:36
So you've converted a second-order equation to first-order. Can you write down what $f$ is for the first-order equation?
– Rahul
Nov 22 at 4:36
For the first order equation is $f=x^2+y-xu$, or am I making $u$ the subject since that is of interest? It is called Heun's method in my notes and the above formula is what is given.
– kj980
Nov 22 at 4:37
For the first order equation is $f=x^2+y-xu$, or am I making $u$ the subject since that is of interest? It is called Heun's method in my notes and the above formula is what is given.
– kj980
Nov 22 at 4:37
1
1
That's not correct. When you reduce the order you should get a system of first-order equations: en.wikipedia.org/wiki/…. In this case, $f$ should be a function $mathbb R^2tomathbb R^2$ which maps $(y,u)$ to $(y',u')$.
– Rahul
Nov 22 at 5:25
That's not correct. When you reduce the order you should get a system of first-order equations: en.wikipedia.org/wiki/…. In this case, $f$ should be a function $mathbb R^2tomathbb R^2$ which maps $(y,u)$ to $(y',u')$.
– Rahul
Nov 22 at 5:25
@LutzL: It was news to me too, but Wikipedia says "Heun's method" also sometimes refers to Ralston's method, and cites a textbook by J. Leader.
– Rahul
Nov 22 at 5:29
@LutzL: It was news to me too, but Wikipedia says "Heun's method" also sometimes refers to Ralston's method, and cites a textbook by J. Leader.
– Rahul
Nov 22 at 5:29
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
You have everything together, you need just to get used to the idea to apply the method to a system of ODE, or to an ODE for a vector-valued function.
$$
begin{align}
y'&=u\
u'&=f(x,y,u)=x^2+y−xu
end{align}
$$
which can be implemented as
dx = x[j+1]-x[j]
k1y = dx*u[j]
k1u = dx*f(x[j],y[j],u[j])
k2y = dx*(u[j]+2/3*k1u)
k2u = dx*f(x[j]+2/3*dx, y[j]+2/3*k1y, u[j]+2/3*k1u)
y[j+1] = y[j] + (k1y+3*k2y)/4
u[j+1] = u[j] + (k1u+3*k2u)/4
Since $y'=u$ therefore $frac{dy}{dx}=u$ and $k_1y$=u.dx, and $du=(x^2+y-xu)dx$ , is that right?
– kj980
Nov 22 at 11:29
Yes, that is all correct. The more abstracted the method implementation is from the problem to solve, the less place there is for errors. Thus even better would be to use $(y',u')=F(x,(y,u))=(u,x^2+y−xu)$ and use vector arithmetic in the arguments and values of $F$.
– LutzL
Nov 22 at 11:47
I am confused though about the $k_1y$ notation, because k1 is defined as f(x,y) is it not?
– kj980
Nov 22 at 11:51
No, $k_1$ is defined as $F(x,(y,u))$, using the full first-order system function. Here it has 2 components, one in $y$ and one in $u$ direction, named $k_{1y}$ and $k_{1u}$. The location of the $dx$ multiplication is arbitrary, there are aesthetic and logistical reasons for both choices.
– LutzL
Nov 22 at 13:48
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You have everything together, you need just to get used to the idea to apply the method to a system of ODE, or to an ODE for a vector-valued function.
$$
begin{align}
y'&=u\
u'&=f(x,y,u)=x^2+y−xu
end{align}
$$
which can be implemented as
dx = x[j+1]-x[j]
k1y = dx*u[j]
k1u = dx*f(x[j],y[j],u[j])
k2y = dx*(u[j]+2/3*k1u)
k2u = dx*f(x[j]+2/3*dx, y[j]+2/3*k1y, u[j]+2/3*k1u)
y[j+1] = y[j] + (k1y+3*k2y)/4
u[j+1] = u[j] + (k1u+3*k2u)/4
Since $y'=u$ therefore $frac{dy}{dx}=u$ and $k_1y$=u.dx, and $du=(x^2+y-xu)dx$ , is that right?
– kj980
Nov 22 at 11:29
Yes, that is all correct. The more abstracted the method implementation is from the problem to solve, the less place there is for errors. Thus even better would be to use $(y',u')=F(x,(y,u))=(u,x^2+y−xu)$ and use vector arithmetic in the arguments and values of $F$.
– LutzL
Nov 22 at 11:47
I am confused though about the $k_1y$ notation, because k1 is defined as f(x,y) is it not?
– kj980
Nov 22 at 11:51
No, $k_1$ is defined as $F(x,(y,u))$, using the full first-order system function. Here it has 2 components, one in $y$ and one in $u$ direction, named $k_{1y}$ and $k_{1u}$. The location of the $dx$ multiplication is arbitrary, there are aesthetic and logistical reasons for both choices.
– LutzL
Nov 22 at 13:48
add a comment |
up vote
0
down vote
You have everything together, you need just to get used to the idea to apply the method to a system of ODE, or to an ODE for a vector-valued function.
$$
begin{align}
y'&=u\
u'&=f(x,y,u)=x^2+y−xu
end{align}
$$
which can be implemented as
dx = x[j+1]-x[j]
k1y = dx*u[j]
k1u = dx*f(x[j],y[j],u[j])
k2y = dx*(u[j]+2/3*k1u)
k2u = dx*f(x[j]+2/3*dx, y[j]+2/3*k1y, u[j]+2/3*k1u)
y[j+1] = y[j] + (k1y+3*k2y)/4
u[j+1] = u[j] + (k1u+3*k2u)/4
Since $y'=u$ therefore $frac{dy}{dx}=u$ and $k_1y$=u.dx, and $du=(x^2+y-xu)dx$ , is that right?
– kj980
Nov 22 at 11:29
Yes, that is all correct. The more abstracted the method implementation is from the problem to solve, the less place there is for errors. Thus even better would be to use $(y',u')=F(x,(y,u))=(u,x^2+y−xu)$ and use vector arithmetic in the arguments and values of $F$.
– LutzL
Nov 22 at 11:47
I am confused though about the $k_1y$ notation, because k1 is defined as f(x,y) is it not?
– kj980
Nov 22 at 11:51
No, $k_1$ is defined as $F(x,(y,u))$, using the full first-order system function. Here it has 2 components, one in $y$ and one in $u$ direction, named $k_{1y}$ and $k_{1u}$. The location of the $dx$ multiplication is arbitrary, there are aesthetic and logistical reasons for both choices.
– LutzL
Nov 22 at 13:48
add a comment |
up vote
0
down vote
up vote
0
down vote
You have everything together, you need just to get used to the idea to apply the method to a system of ODE, or to an ODE for a vector-valued function.
$$
begin{align}
y'&=u\
u'&=f(x,y,u)=x^2+y−xu
end{align}
$$
which can be implemented as
dx = x[j+1]-x[j]
k1y = dx*u[j]
k1u = dx*f(x[j],y[j],u[j])
k2y = dx*(u[j]+2/3*k1u)
k2u = dx*f(x[j]+2/3*dx, y[j]+2/3*k1y, u[j]+2/3*k1u)
y[j+1] = y[j] + (k1y+3*k2y)/4
u[j+1] = u[j] + (k1u+3*k2u)/4
You have everything together, you need just to get used to the idea to apply the method to a system of ODE, or to an ODE for a vector-valued function.
$$
begin{align}
y'&=u\
u'&=f(x,y,u)=x^2+y−xu
end{align}
$$
which can be implemented as
dx = x[j+1]-x[j]
k1y = dx*u[j]
k1u = dx*f(x[j],y[j],u[j])
k2y = dx*(u[j]+2/3*k1u)
k2u = dx*f(x[j]+2/3*dx, y[j]+2/3*k1y, u[j]+2/3*k1u)
y[j+1] = y[j] + (k1y+3*k2y)/4
u[j+1] = u[j] + (k1u+3*k2u)/4
answered Nov 22 at 10:10
LutzL
54.6k41953
54.6k41953
Since $y'=u$ therefore $frac{dy}{dx}=u$ and $k_1y$=u.dx, and $du=(x^2+y-xu)dx$ , is that right?
– kj980
Nov 22 at 11:29
Yes, that is all correct. The more abstracted the method implementation is from the problem to solve, the less place there is for errors. Thus even better would be to use $(y',u')=F(x,(y,u))=(u,x^2+y−xu)$ and use vector arithmetic in the arguments and values of $F$.
– LutzL
Nov 22 at 11:47
I am confused though about the $k_1y$ notation, because k1 is defined as f(x,y) is it not?
– kj980
Nov 22 at 11:51
No, $k_1$ is defined as $F(x,(y,u))$, using the full first-order system function. Here it has 2 components, one in $y$ and one in $u$ direction, named $k_{1y}$ and $k_{1u}$. The location of the $dx$ multiplication is arbitrary, there are aesthetic and logistical reasons for both choices.
– LutzL
Nov 22 at 13:48
add a comment |
Since $y'=u$ therefore $frac{dy}{dx}=u$ and $k_1y$=u.dx, and $du=(x^2+y-xu)dx$ , is that right?
– kj980
Nov 22 at 11:29
Yes, that is all correct. The more abstracted the method implementation is from the problem to solve, the less place there is for errors. Thus even better would be to use $(y',u')=F(x,(y,u))=(u,x^2+y−xu)$ and use vector arithmetic in the arguments and values of $F$.
– LutzL
Nov 22 at 11:47
I am confused though about the $k_1y$ notation, because k1 is defined as f(x,y) is it not?
– kj980
Nov 22 at 11:51
No, $k_1$ is defined as $F(x,(y,u))$, using the full first-order system function. Here it has 2 components, one in $y$ and one in $u$ direction, named $k_{1y}$ and $k_{1u}$. The location of the $dx$ multiplication is arbitrary, there are aesthetic and logistical reasons for both choices.
– LutzL
Nov 22 at 13:48
Since $y'=u$ therefore $frac{dy}{dx}=u$ and $k_1y$=u.dx, and $du=(x^2+y-xu)dx$ , is that right?
– kj980
Nov 22 at 11:29
Since $y'=u$ therefore $frac{dy}{dx}=u$ and $k_1y$=u.dx, and $du=(x^2+y-xu)dx$ , is that right?
– kj980
Nov 22 at 11:29
Yes, that is all correct. The more abstracted the method implementation is from the problem to solve, the less place there is for errors. Thus even better would be to use $(y',u')=F(x,(y,u))=(u,x^2+y−xu)$ and use vector arithmetic in the arguments and values of $F$.
– LutzL
Nov 22 at 11:47
Yes, that is all correct. The more abstracted the method implementation is from the problem to solve, the less place there is for errors. Thus even better would be to use $(y',u')=F(x,(y,u))=(u,x^2+y−xu)$ and use vector arithmetic in the arguments and values of $F$.
– LutzL
Nov 22 at 11:47
I am confused though about the $k_1y$ notation, because k1 is defined as f(x,y) is it not?
– kj980
Nov 22 at 11:51
I am confused though about the $k_1y$ notation, because k1 is defined as f(x,y) is it not?
– kj980
Nov 22 at 11:51
No, $k_1$ is defined as $F(x,(y,u))$, using the full first-order system function. Here it has 2 components, one in $y$ and one in $u$ direction, named $k_{1y}$ and $k_{1u}$. The location of the $dx$ multiplication is arbitrary, there are aesthetic and logistical reasons for both choices.
– LutzL
Nov 22 at 13:48
No, $k_1$ is defined as $F(x,(y,u))$, using the full first-order system function. Here it has 2 components, one in $y$ and one in $u$ direction, named $k_{1y}$ and $k_{1u}$. The location of the $dx$ multiplication is arbitrary, there are aesthetic and logistical reasons for both choices.
– LutzL
Nov 22 at 13:48
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3008732%2funderstanding-heuns-method%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Your formulas are for the Ralston method, you then describe verbally the implicit trapezoidal method but Heun's method is usually the explicit trapezoidal method. Please check your sources on what you really want resp. should do.
– LutzL
Nov 22 at 4:34
So you've converted a second-order equation to first-order. Can you write down what $f$ is for the first-order equation?
– Rahul
Nov 22 at 4:36
For the first order equation is $f=x^2+y-xu$, or am I making $u$ the subject since that is of interest? It is called Heun's method in my notes and the above formula is what is given.
– kj980
Nov 22 at 4:37
1
That's not correct. When you reduce the order you should get a system of first-order equations: en.wikipedia.org/wiki/…. In this case, $f$ should be a function $mathbb R^2tomathbb R^2$ which maps $(y,u)$ to $(y',u')$.
– Rahul
Nov 22 at 5:25
@LutzL: It was news to me too, but Wikipedia says "Heun's method" also sometimes refers to Ralston's method, and cites a textbook by J. Leader.
– Rahul
Nov 22 at 5:29