Solving 2nd Order ODE: y'' + 2y' - y = e^{-x}, y(0) = y'(0) = 1

  • Thread starter Thread starter squenshl
  • Start date Start date
  • Tags Tags
    2nd order Ode
Click For Summary
SUMMARY

The discussion focuses on solving the second order ordinary differential equation (ODE) given by y'' + 2y' - y = e^{-x} with initial conditions y(0) = y'(0) = 1. The ODE is converted into a system of first order equations: u1' = u2 and u2' = e^{-x} - 2u2 + u1, with initial conditions u1(0) = u2(0) = 1. The computed solution for y(2) is 3.27, but users encountered issues with the pc33assisys MATLAB file, specifically a matrix indexing error in the Adams-Moulton integration loop and an uninitialized variable f(1,:).

PREREQUISITES
  • Understanding of second order ordinary differential equations (ODEs)
  • Familiarity with MATLAB programming and syntax
  • Knowledge of numerical methods, specifically the Adams-Moulton integration method
  • Experience with converting higher order ODEs to first order systems
NEXT STEPS
  • Review MATLAB's numerical integration techniques, particularly the Adams-Moulton method
  • Learn about debugging matrix indexing errors in MATLAB
  • Explore the conversion process of higher order ODEs to first order systems
  • Investigate the use of MATLAB's built-in functions for solving ODEs, such as ode45
USEFUL FOR

Students studying differential equations, MATLAB programmers, and anyone interested in numerical methods for solving ODEs.

squenshl
Messages
468
Reaction score
4

Homework Statement


Consider the following second order ODE
$$ y'' + 2y' - y = e^{-x}, \quad y(0) = y'(0) = 1. $$ Convert this to a system of first order equations and use the pc33assisys MATLAB file to compute the solution for y(2).


Homework Equations





The Attempt at a Solution


The system of first order equations is
$$ u_1' = u_2 \\ u_2' = e^{-x}-2u_2+u_1 $$ with $$ u_1(0) = u_2(0) = 1. $$
The solution for y(2) is y(2) = 3.27 to 2 d.p. But my pc33assisys file doesn't give me this. All the relevant files are attached to run the program. Can someone help figure out what is wrong with my code.

Thanks.
 

Attachments

Physics news on Phys.org
There's a matrix indexing error in pc33assi3sys.m in the Adams-Moulton integration loop. Whoever wrote it also forgot to initialize f(1,:) for the first multi-step.

I've attached a corrected version.
 

Attachments

Cheers mate
 

Similar threads

  • · Replies 16 ·
Replies
16
Views
3K
Replies
7
Views
2K
  • · Replies 18 ·
Replies
18
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
Replies
11
Views
2K
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
2K
Replies
4
Views
2K