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

In summary, the conversation discusses converting a second order ODE to a system of first order equations and using a MATLAB file to compute the solution for a given value. It is mentioned that there was a matrix indexing error in the file and a corrected version has been attached.
  • #1
squenshl
479
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

  • pc33assi3sys.m
    871 bytes · Views: 370
  • Ass3Q2.m
    70 bytes · Views: 364
Physics news on Phys.org
  • #2
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

  • pc33assi3sys_corrected.m
    914 bytes · Views: 348
  • #3
Cheers mate
 

1. What is a 2nd Order ODE?

A 2nd order ODE (ordinary differential equation) is a type of mathematical equation that involves the second derivative of a dependent variable with respect to an independent variable. In this case, the dependent variable is represented by y and the independent variable is x.

2. How do you solve a 2nd Order ODE?

To solve a 2nd Order ODE, you can use various methods such as separation of variables, variation of parameters, or the method of undetermined coefficients. In this specific example, we can use the method of undetermined coefficients to find the particular solution.

3. What is the initial condition in this equation?

The initial condition, represented as y(0) = 1 and y'(0) = 1, means that we are given the values of the dependent variable (y) and its derivative (y') at a specific point (x = 0). This information is necessary to find the particular solution of the equation.

4. How do you use the initial condition to solve the equation?

The initial condition can be used to find the particular solution by plugging in the given values of y and y' into the general solution of the equation. In this case, the general solution is y = Ae^x + Be^(-x), where A and B are constants. By plugging in the values for y(0) = 1 and y'(0) = 1, we can solve for the values of A and B and obtain the particular solution.

5. What is the significance of the e^(-x) term in this equation?

The e^(-x) term is a part of the particular solution and represents the exponential decay of the dependent variable (y) as the independent variable (x) increases. This term is a result of the right-hand side of the equation, e^(-x), and is necessary to balance the equation and satisfy the initial condition.

Similar threads

  • Calculus and Beyond Homework Help
Replies
14
Views
397
  • Calculus and Beyond Homework Help
Replies
7
Views
692
  • Calculus and Beyond Homework Help
Replies
18
Views
1K
Replies
4
Views
505
  • Calculus and Beyond Homework Help
Replies
2
Views
545
  • Calculus and Beyond Homework Help
Replies
2
Views
514
  • Calculus and Beyond Homework Help
Replies
3
Views
573
  • Calculus and Beyond Homework Help
Replies
6
Views
764
  • Calculus and Beyond Homework Help
Replies
11
Views
964
  • Calculus and Beyond Homework Help
Replies
6
Views
1K
Back
Top