# How can I combine the solutions for u(t) and y(t) to find the solution for y(t)?

• eckiller
In summary, the conversation discusses using numerical ODE solvers to solve a second-order ODE y'' = f(t, y), with initial conditions y(a) = y0 and y'(a) = y0'. The conversation also suggests using the substitution u = y' to transform the second-order ODE into two first-order ODEs. It is then recommended to use Runge-Kutta or other methods to solve the two first-order equations simultaneously, with the initial conditions y(a) = y0 and v(a) = y'(a). The end result will be two separate functions: y(x) as the solution of the original second-order ODE and v(x) as y'(x) expressed as another function. This method
eckiller
Suppose we have y'' = f(t, y); y(a) = y0; y'(a) = y0'
Note all derivatives are with respect to t.

Let u = y', then u' = y''

1. u' = f(t, y), u(a) = y'(a)
2. y' = u, y(a) = y0

Question 1: For y' = u, should I think of this as dy/du = u? Otherwise, I don't see how to solve 2 because what is u as a function of t?

So I pump both (1) and (2) through a numerical ODE solver.

For (1) I get answer u(t), and for (2) I get answer y(t) ? That doesn't seem right, as y(t) is what I want. How do I put my two answers together to get y(t).

As you can probably tell, I'm very confused on this.

So for:

$$y^{''}=f(x,y)$$

Let:

$$y^{'}=v(x)$$

$$v^{'}=f(x,y)$$

Now you have two first-order ODEs just right for Runge-Kutta or other methods. To start the numerical method, y(a)=$y_0$ and v(a)=y'(a).

When you get the results, you get two separate (numerical) functions: y(x) and v(x). y(x) is the solution of the original second order ODE. v(x) is just y'(x) expressed as another function.

So for:

y'' = f(x, y)

Let:

y' = v(x)

v' = f(x, y)

Now you have two first-order ODEs just right for Runge-Kutta or other methods. To start the numerical method, y(a)=y0. Reload this page in a moment. and v(a)=y'(a).

Thank you for your reply. Okay, up to this point I don't know what v(x) is in y'. I don't see how I can apply Runge-Kutta to y' = v(x) if I do not know v(x) !

eckiller said:
Thank you for your reply. Okay, up to this point I don't know what v(x) is in y'. I don't see how I can apply Runge-Kutta to y' = v(x) if I do not know v(x) !

v(x) is y'(x). Now, since you're using Runge-Kutta, you know the first data points right? You know y(a) and y'(a)=v(a). Runge-Kutta then calculates the second data points: y(deltax) and v(deltax), and so forth. You then end up with 2 functions. y(x) is the solution and v(x) is just . . . well extra.

Forgive me. This is probably something obviously simple I am missing.

y'(x) = v(x).

But I am not given what y' is. I am given y'' = f(t, y).

For example, to a numerical ODE solver, we supply the g function,

dy/dt = g(t, y),

as a parameter to the ODE solver. So I don't get what I am to supply because I don't know what v(x) is or dy/dt. Are you saying it is just:

y'(x) = v

where v is just linear? Almost as in y'(x) = t ? If so why not just integrate directly then?

eckiller said:
Forgive me. This is probably something obviously simple I am missing.

y'(x) = v(x).

But I am not given what y' is. I am given y'' = f(t, y).

For example, to a numerical ODE solver, we supply the g function,

dy/dt = g(t, y),

as a parameter to the ODE solver. So I don't get what I am to supply because I don't know what v(x) is or dy/dt. Are you saying it is just:

y'(x) = v

where v is just linear? Almost as in y'(x) = t ? If so why not just integrate directly then?

Alright, I'm sorry you're having problems with my explanation. You know that for a second order ODE to have a "unique" solution, you MUST be give two conditions. Usually these are "initial conditions" in the form of y(0)=a and y'(0)=b. You need to have these values supplied in order to work the Runge-Kutta method. Your first post, as I interpreted it, indicated that you are given these two values.

I tell you what, even if you're not given them, try using just any values say y(0)=1 and y'(0)=0 or whatever and do the numeric analysis just to verify you have the algorithm down correctly.

You said:

"For example, to a numerical ODE solver, we supply the g function,

dy/dt = g(t, y)"

Well, even that you still need to supply an initial condition in the form (usually) of y(0)=a.

You know that for a second order ODE to have a "unique" solution, you MUST be give two conditions. Usually these are "initial conditions" in the form of y(0)=a and y'(0)=b. You need to have these values supplied in order to work the Runge-Kutta method. Your first post, as I interpreted it, indicated that you are given these two values.

Yes I am given the initial conditions. But I still need the function. For simplicity, the Euler step:

slope = feval(funcHandle, t(i-1), y(i-1));
y(i) = y(i-1) + slope*step;

where funcHandle is the f(t, y) in y' = f(t, y).

eckiller said:
Yes I am given the initial conditions. But I still need the function. For simplicity, the Euler step:

slope = feval(funcHandle, t(i-1), y(i-1));
y(i) = y(i-1) + slope*step;

where funcHandle is the f(t, y) in y' = f(t, y).

I think I see the problem now: You need to calculate Runge-Kutta for BOTH y(x) AND v(x) simultaneously. You're given the starting points, then run through one delta x, calculate y(x) AND v(x) at that point, go to the next step, calculate both again, and so forth. It's a little messy.

You need to calculate Runge-Kutta for BOTH y(x) AND v(x) simultaneously. You're given the starting points, then run through one delta x, calculate y(x) AND v(x) at that point, go to the next step, calculate both again, and so forth. It's a little messy.

Okay so going back to y'' = f(t, y)

Step each step:

(a) Solve v' = f(t, y) for this step
(b) Use solution from (a) to solve y' = v

Is that right?

eckiller said:
Okay so going back to y'' = f(t, y)

Step each step:

(a) Solve v' = f(t, y) for this step
(b) Use solution from (a) to solve y' = v

Is that right?

Ok, so we have:

$$y^{'}=v(x)$$

$$v^{'}=f(x,y)$$

Calculate y(x1) and v(x1). You can do this because you have their derivatives there and the initial conditions y(0) and v(0). The next step, x2, you do that all over, calculate y(x2) AND v(x2) at the same time. You can do that since again, you know what the slopes are and what the previously calculated values were. Then do y(x3) AND v(x3) and so forth. You'll think it's easy once you do a few. Hope that helps. Gotta check out . . .

I see now. Thank you.

## 1. What is a second order ordinary differential equation (ODE)?

A second order ODE is a mathematical equation that involves a function and its first and second derivatives with respect to a single independent variable. It can be written in the form y'' = f(x, y, y'), where y'' represents the second derivative of y with respect to x.

## 2. Why do we need numerical methods to solve second order ODEs?

Analytical solutions for second order ODEs are not always feasible or possible to obtain. In such cases, numerical methods are used to approximate the solution of the ODE. These methods involve breaking down the problem into smaller steps and using iterative calculations to obtain an approximation of the solution.

## 3. What is the difference between explicit and implicit methods for solving second order ODEs numerically?

In explicit methods, the next value of the solution is calculated solely based on the previous value, while in implicit methods, the next value is calculated using both the previous value and the next value. This can make implicit methods more accurate but also more computationally intensive.

## 4. How do boundary conditions affect the numerical solution of a second order ODE?

Boundary conditions are necessary to obtain a unique solution for a second order ODE. These conditions specify the values of the solution at certain points, and they can greatly affect the accuracy and stability of the numerical solution. Choosing appropriate boundary conditions is crucial for obtaining an accurate and meaningful solution.

## 5. Can numerical methods handle nonlinear second order ODEs?

Yes, numerical methods can handle both linear and nonlinear second order ODEs. However, for nonlinear equations, the choice of numerical method and initial values can greatly affect the accuracy and stability of the solution. In some cases, it may be necessary to use more advanced techniques, such as adaptive step-size control, to obtain an accurate solution.

• Differential Equations
Replies
3
Views
2K
• Differential Equations
Replies
5
Views
1K
• Differential Equations
Replies
16
Views
976
• Differential Equations
Replies
1
Views
837
• Differential Equations
Replies
3
Views
871
• Differential Equations
Replies
2
Views
2K
• Differential Equations
Replies
4
Views
3K
• Differential Equations
Replies
3
Views
1K
• Differential Equations
Replies
1
Views
959
• Differential Equations
Replies
3
Views
3K