Understanding Euler Method: Finding Initial Condition of y(0)=1

In summary, determining the initial condition for the Euler method in a first-order differential equation is important for the accuracy of the approximation. In most cases, the initial condition is given as y(0) = 1, which is the best choice for didactic purposes. When finding the equation of the curve, the integrating factor can be used to determine the exact values at certain points, which can then be compared to the values found using Euler's method.
  • #1
chwala
Gold Member
2,664
352
TL;DR Summary
Kindly see the reference below;

https://math.libretexts.org/Courses/Monroe_Community_College/MTH_225_Differential_Equations/3%3A_Numerical_Methods/3.1%3A_Euler's_Method

My interest is on Example 3.1.1
How did they determine the initial condition ##y(0)=1##or is it picked out of convenience? why not ##y(0)=0.95## or ##y(0)=0.99##
The Euler method is straightforward to me; i.e ##y_{n+1}=y_n+ hf(t_0, y_0)## where the smaller the steps i.e ##h## size the better the approximation.

My question is 'how does one go about in determining the initial condition ##y(0)=1## in this problem? am assuming that this has to be a point on the line.

Assuming that i had this other problem; using it to elaborate my point,

##\dfrac{dy}{dt}=y## and given ##y(0)=1##

then in this case if i am to find ##y(t)## (using separation of variables) then the Exact solution is,
##y(t)=e^{t + k}## and when ##x=0, y=1 ⇒k=0##.
The exact value at ##t=4## is given by,
##y(4)=e^4≈54.598## on the other hand
Euler method (Numerical method) with step size ##h=0.0125## will give us,
##y=53.26##

...In this case,the initial condition, ##y(0)=1## makes sense to me as ##(0,1)## is a point on the curve. I hope that i am clear on my argument.
On the flip side, i attempted to find;

##f(x,y)## of the function

##\dfrac{dy}{dx}+2y=x^3e^{-2x}##

and i ended up with;

##f(x,y)=ye^{2x}-\dfrac{x^4}{4} + y^2e^{2x}-x^3y-e^{2x}y##

i am not sure whether its correct...still checking then i can post all my working. Cheers
 
Last edited:
Physics news on Phys.org
  • #2
The initial condition is part of the problem statement. You do not figure out the initial condition, it is given to you. Keep in mind that Euler's method while simple is very unstable. I don't know what you are doing with f(x,y) the example shows how to find it.
 
  • Like
Likes PhDeezNutz
  • #3
lurflurf said:
The initial condition is part of the problem statement. You do not figure out the initial condition, it is given to you. Keep in mind that Euler's method while simple is very unstable. I don't know what you are doing with f(x,y) the example shows how to find it.
I understand that...the Euler method will give us a range of approximate values of ##y## at different points... I on the other hand was trying to get the function ##f(x,y)## itself using other methods so as to graph it and see how the points look like...so as to validate the given initial point.

Yes, i understand that initial conditions are given...no doubt about that...question is why particular values? i hope you get my question...in most cases they give ##y(0)=1## why not ##y=0.99##

Euler method by itself is unstable we have other improvements like the predictor-corrector method, the mid-point method etc...
 
  • #4
chwala said:
I understand that...the Euler method will give us a range of approximate values of ##y## at different points... I on the other hand was trying to get the function ##f(x,y)## itself using other methods so as to graph it and see how the points look like...so as to validate the given initial point.

Yes, i understand that initial conditions are given...no doubt about that...question is why particular values? i hope you get my question...in most cases they give ##y(0)=1## why not ##y=0.99##

These examples have the didactic purpose of showing how and why the method works in cases where the analytical solution of either the ODE or the recurrence produced by the numerical algorithm are not available. Giving an initial condition like [itex]y(0) = 0.99[/itex] does not serve this didactic purpose: It unduly complicates the arithmetic, and gives rise to the temptation to introduce errors by using intermediate quantities quoted to less than full precision in the calculation. Actual calculations by digital computers will introduce such errors as an inevitable consequence of how floating point arithmetic works, but when the calculations are done by hand there is no place for these errors.

From that point of view [itex]y(0) = 1[/itex] is the best initial condition.
 
  • Like
Likes robphy, jim mcnamara and chwala
  • #5
chwala said:
TL;DR Summary: Kindly see the reference below;

https://math.libretexts.org/Courses/Monroe_Community_College/MTH_225_Differential_Equations/3:_Numerical_Methods/3.1:_Euler's_Method

My interest is on Example 3.1.1
How did they determine the initial condition ##y(0)=1##or is it picked out of convenience? why not ##y(0)=0.95## or ##y(0)=0.99##

The Euler method is straightforward to me; i.e ##y_{n+1}=y_n+ hf(t_0, y_0)## where the smaller the steps i.e ##h## size the better the approximation.

My question is 'how does one go about in determining the initial condition ##y(0)=1## in this problem? am assuming that this has to be a point on the line.

Assuming that i had this other problem; using it to elaborate my point,

##\dfrac{dy}{dt}=y## and given ##y(0)=1##

then in this case if i am to find ##y(t)## (using separation of variables) then the Exact solution is,
##y(t)=e^{t + k}## and when ##x=0, y=1 ⇒k=0##.
The exact value at ##t=4## is given by,
##y(4)=e^4≈54.598## on the other hand
Euler method (Numerical method) with step size ##h=0.0125## will give us,
##y=53.26##

...In this case,the initial condition, ##y(0)=1## makes sense to me as ##(0,1)## is a point on the curve. I hope that i am clear on my argument.
On the flip side, i attempted to find the equation of the curve;

##\dfrac{dy}{dx}+2y=x^3e^{-2x}##

and i ended up with;

##f(x,y)=ye^{2x}-\dfrac{x^4}{4} + y^2e^{2x}-x^3y-e^{2x}y##

i am not sure whether its correct...still checking then i can post all my working. Cheers

Consider the first -order differential equation that is given in example 3.1.1;

##\dfrac{dy}{dx}+2y=x^3e^{-2x}##

The equation of the curve will be given by as follows;

...
integrating factor= ##e^{2x}##

therefore

...

##ye^{2x} = \int x^3 dx##

##ye^{2x} = \dfrac{x^4}{4} +k##

##y=\dfrac{x^4}{4e^{2x}}+ \dfrac{k}{e^{2x}}##

Using ##y(0)=1## we shall get,

##1=0+k, ⇒k=1##

thus,

##y=\dfrac{x^4e^{-2x}}{4}+ e^{-2x}##

I can see from the graph that the point ##(0,1)## lies on the graph...

For the exact values i have;

##y_1=0.8188, y_2=0.6706, y_3=0.5499## and so on...

these values are quite close to the ones that were found by Euler's method.

Cheers guys!
 
Last edited:
  • #6
pasmith said:
These examples have the didactic purpose of showing how and why the method works in cases where the analytical solution of either the ODE or the recurrence produced by the numerical algorithm are not available. Giving an initial condition like [itex]y(0) = 0.99[/itex] does not serve this didactic purpose: It unduly complicates the arithmetic, and gives rise to the temptation to introduce errors by using intermediate quantities quoted to less than full precision in the calculation. Actual calculations by digital computers will introduce such errors as an inevitable consequence of how floating point arithmetic works, but when the calculations are done by hand there is no place for these errors.

From that point of view [itex]y(0) = 1[/itex] is the best initial condition.
In my understanding the initial condition can be taken as any point that lies on the curve...but the fact is that in general; ##y(0)=1## is usually picked as the initial condition in these kind of problems...i think this may be due to the fact that at other given points, the solutions may differ significantly say in comparison to the exact solution.
 
  • #7
chwala said:
In my understanding the initial condition can be taken as any point that lies on the curve...
Yes.
chwala said:
but the fact is that in general; y(0)=1 is usually picked as the initial condition in these kind of problems...i think this may be due to the fact that at other given points, the solutions may differ significantly say in comparison to the exact solution.
I doubt that this is the case. Instead, the initial condition is more likely picked for convenience in writing the problem. Which point is picked has nothing to do with how the computed solution compares to the exact solution, which may or may not be available.
 
  • Informative
Likes chwala
  • #8
In theory, yes, a solution curve is uniquely specified by requiring that a given point lies on it.

But in practice we have a system whose current state is known and whose future behaviour we want to predict. It makes no sense to start our calculations at some future time, because we don't know what the system will be doing then. It makes little sense to start at some time in the past, because we will lose accuracy (and waste computational time) in getting from that point to the present. It makes sense then to start from "now", and to call that time 0.
 
  • Informative
Likes chwala

Similar threads

  • Differential Equations
Replies
1
Views
842
  • Differential Equations
Replies
9
Views
2K
  • Differential Equations
Replies
7
Views
2K
  • Differential Equations
Replies
16
Views
958
  • Differential Equations
Replies
5
Views
2K
  • Differential Equations
Replies
5
Views
4K
  • Differential Equations
Replies
10
Views
1K
Replies
16
Views
2K
  • Differential Equations
Replies
11
Views
3K
Replies
6
Views
1K
Back
Top