Euler's Method to approximate a second order Differential Equation

In summary: Homework Statement y'' + 4y' + 4y = 0 ---- y(0) = 1, y'(0) = 5Find the exact solution of the differential equation.Use the exact solution and Euler's Method to compute Euler's Approximation for time t = 0 to t = 5 using a step h=0.05. Plot Euler's & Exact vs. t and plot Error vs. t. Then, answer the following question:Is the error really increasing? That is, is Euler's method becoming less accurate as t increases?Homework Equationsx1 = yx2 = y'x1' = y'x2' = y'' = -4
  • #1
Yosty22
185
4

Homework Statement



y'' + 4y' + 4y = 0 ---- y(0) = 1, y'(0) = 5
Find the exact solution of the differential equation.
Use the exact solution and Euler's Method to compute Euler's Approximation for time t = 0 to t = 5 using a step h=0.05. Plot Euler's & Exact vs. t and plot Error vs. t. Then, answer the following question:

Is the error really increasing? That is, is Euler's method becoming less accurate as t increases?

Homework Equations



x1 = y
x2 = y'
x1' = y'
x2' = y'' = -4y' - 4y = -4x2 - 41
Euler's Method Equations assuming the substitutions made above:
x1(n+1) = x1(n) + hx/2(n)
x2(n+1) = x2(n) + h*(y''(n))

The Attempt at a Solution


[/B]
First, I solved the differential equation. Writing the characteristic equation r2 + 4r + 4 = 0, I solved for there to be a repeated root at r = -2. Therefore, the general solution is:
y= c1e-2t + c2te-2t
Taking a derivative to use the initial conditions:
y' = -c1/2 * e-2t + c2te-2t/2 + c2e-2t
Applying the initla conditions, I find c1 = 1 and c2 = 11/2
Therefore, the solution becomes:
e-2t + 11t/2 * e-2t

I then created an excel spreadsheet which calculate and then plots the exact solution vs. the eulerapproximation, giving me the graph:
upload_2014-10-6_22-9-44.png

then the error graph looks as follows:
upload_2014-10-6_22-10-51.png

So around time t = 3, it makes sense that the error would be about 0 due to how Euler approximations work. Since Euler Approximations use the tangent lines of the functions at a certain point to approximate the shape of the graph, the more and more linear the solution gets (such as from t --> infinity in this solution), the easier it is to approximate the solution because the slope of a horizontal line is 0. However, I have absolutely no idea what could be going on here that would cause the error to start increasing seemingly linearly after time t = 3 where the solution and the euler approximation is practically horizontal. I cannot fathom that a repeated root would cause this error. Does anyone have any idea what could be causing this?

Thanks in advance.
 
Physics news on Phys.org
  • #2
Sorry, I thought I could be more a little more explicit about my response at the bottom. Since Euler Approximations go off of the slope of the tangent line of the exact solution and as t is increasing, the slope of the tangent line of the solution approaches 0, so the error should be approaching 0. So to answer the question, I would say that the error isn't really increasing despite what the graph displays. However, I'm not sure how to answer the part of the question asking to explicitly state what would cause it to appear as if it was increasing.
 
  • #3
Yosty22 said:

Homework Statement



y'' + 4y' + 4y = 0 ---- y(0) = 1, y'(0) = 5
Find the exact solution of the differential equation.
Use the exact solution and Euler's Method to compute Euler's Approximation for time t = 0 to t = 5 using a step h=0.05. Plot Euler's & Exact vs. t and plot Error vs. t. Then, answer the following question:

Is the error really increasing? That is, is Euler's method becoming less accurate as t increases?

Homework Equations



x1 = y
x2 = y'
x1' = y'
x2' = y'' = -4y' - 4y = -4x2 - 41
Euler's Method Equations assuming the substitutions made above:
x1(n+1) = x1(n) + hx/2(n)
x2(n+1) = x2(n) + h*(y''(n))

The Attempt at a Solution


[/B]
First, I solved the differential equation. Writing the characteristic equation r2 + 4r + 4 = 0, I solved for there to be a repeated root at r = -2. Therefore, the general solution is:
y= c1e-2t + c2te-2t
Taking a derivative to use the initial conditions:
y' = -c1/2 * e-2t + c2te-2t/2 + c2e-2t

The derivative of [itex]e^{kt}[/itex] is [itex]ke^{kt}[/itex], not [itex]\frac1k e^{kt}[/itex].
 
  • #4
Yosty22 said:

Homework Statement



y'' + 4y' + 4y = 0 ---- y(0) = 1, y'(0) = 5
Find the exact solution of the differential equation.
Use the exact solution and Euler's Method to compute Euler's Approximation for time t = 0 to t = 5 using a step h=0.05. Plot Euler's & Exact vs. t and plot Error vs. t. Then, answer the following question:

Is the error really increasing? That is, is Euler's method becoming less accurate as t increases?

Homework Equations



x1 = y
x2 = y'
x1' = y'
x2' = y'' = -4y' - 4y = -4x2 - 41
Euler's Method Equations assuming the substitutions made above:
x1(n+1) = x1(n) + hx/2(n)
x2(n+1) = x2(n) + h*(y''(n))

The Attempt at a Solution


[/B]
First, I solved the differential equation. Writing the characteristic equation r2 + 4r + 4 = 0, I solved for there to be a repeated root at r = -2. Therefore, the general solution is:
y= c1e-2t + c2te-2t
Taking a derivative to use the initial conditions:
y' = -c1/2 * e-2t + c2te-2t/2 + c2e-2t
Applying the initla conditions, I find c1 = 1 and c2 = 11/2
Therefore, the solution becomes:
e-2t + 11t/2 * e-2t

I then created an excel spreadsheet which calculate and then plots the exact solution vs. the eulerapproximation, giving me the graph: View attachment 74110
then the error graph looks as follows:
View attachment 74111
So around time t = 3, it makes sense that the error would be about 0 due to how Euler approximations work. Since Euler Approximations use the tangent lines of the functions at a certain point to approximate the shape of the graph, the more and more linear the solution gets (such as from t --> infinity in this solution), the easier it is to approximate the solution because the slope of a horizontal line is 0. However, I have absolutely no idea what could be going on here that would cause the error to start increasing seemingly linearly after time t = 3 where the solution and the euler approximation is practically horizontal. I cannot fathom that a repeated root would cause this error. Does anyone have any idea what could be causing this?

Thanks in advance.

Your c1 and c2 are incorrect; you calculated y' incorrectly.

Anyway, even if you have the correct y(t) the errors can still grow (but they need not always do so). This can happen even in a simple case such as y' = a*y; see, eg., http://en.wikipedia.org/wiki/Euler_method , especially section 7. The point is that errors "accumulate", so that as the time increases you are applying a slightly incorrect step t -> t+h, starting from an incorrect y(t), and that can make y(t+h) even less correct. [Note: I said 'can', not 'will'.]
 
Last edited:
  • #5
Also, I noted that your error graph is % error, or error/x, right? As x goes to zero, your small error will become very large relative to the zero value of the function. Try plotting true error to see how the method converges to the flat line at the end.
 

1. What is Euler's Method and how does it work?

Euler's Method is a numerical method used to approximate the solutions to a second order differential equation. It works by breaking down the equation into small time intervals and using the initial conditions to calculate the slope at each interval. This slope is then used to approximate the solution at the next interval, and the process is repeated until the desired accuracy is achieved.

2. What are the limitations of using Euler's Method?

One limitation of Euler's Method is that it can only provide an approximation of the solution, and the accuracy of this approximation depends on the size of the time intervals used. Smaller intervals result in a more accurate approximation, but also require more computational resources. Additionally, Euler's Method may not work well for equations with complex or oscillatory solutions.

3. How do you choose the time intervals for Euler's Method?

The choice of time intervals for Euler's Method depends on the desired accuracy and the complexity of the equation. Generally, smaller intervals result in a more accurate approximation, but may require more computational resources. It is important to strike a balance between accuracy and computational efficiency when choosing time intervals for Euler's Method.

4. Can Euler's Method be used to solve any type of second order differential equation?

No, Euler's Method may not work well for equations with complex or oscillatory solutions. It is best suited for simple linear equations with smooth solutions. For more complex equations, other numerical methods such as Runge-Kutta methods may be more effective.

5. How can you check the accuracy of the solution obtained using Euler's Method?

The accuracy of the solution obtained using Euler's Method can be checked by comparing it to the exact solution, if known. Additionally, the error can be estimated by using smaller time intervals and comparing the results. If the error decreases with smaller intervals, then the solution is likely accurate. It is also important to check for any significant differences between the approximate solution and the exact solution at specific points or over a range of values.

Similar threads

  • Calculus and Beyond Homework Help
Replies
2
Views
137
  • Calculus and Beyond Homework Help
Replies
6
Views
861
  • Calculus and Beyond Homework Help
Replies
3
Views
575
  • Calculus and Beyond Homework Help
Replies
7
Views
694
  • Calculus and Beyond Homework Help
Replies
18
Views
1K
  • Calculus and Beyond Homework Help
Replies
5
Views
920
  • Calculus and Beyond Homework Help
Replies
2
Views
532
  • Calculus and Beyond Homework Help
Replies
2
Views
332
  • Calculus and Beyond Homework Help
Replies
4
Views
945
  • Calculus and Beyond Homework Help
Replies
5
Views
1K
Back
Top