How to Solve a Shooting Method Problem with Specific Boundary Conditions?

In summary: Newton's Method as Chet said it is an approximation and does the job, what I am doing is I am approximating the derivative at each step and then go to the next point?Yes, that's correct.
  • #1
electronic engineer
145
3
Hello, can anyone give me the general instructions of solving shooting method problem:

dy1/dx=-y1^2*y2
dy2/dx=y1*y2^2

with the boundary conditions: y1(0)=1, y2(1)=2
 
Physics news on Phys.org
  • #2
To solve a set of differential equations like this numerically, you generally start at some point and then step forward through your domain of interest, using a method like Euler's method or Runge-Kutta. The problem here is that you don't know the starting boundary conditions at any point, you know them at two different points. So to use the shooting method, you start at some point, like x=0. You know y1(0) = 1, but you don't know y2(0). So you guess a value, say y2(0)=1. Then you numerically step forward to x=1, and see what the value of y2 is. If y2(1) =2, you are done, but probably it is greater or less than 2. Based on y2(1), you adjust your initial guess of y2(0) and step forward again. Hopefully this time you are closer. You keep iterating until y2(1) = 2 to the desired degree of precision. Alternatively, you could start at x=1, guess a value for y1(1) and step down to x=0. The process is the same.
 
  • #3
Thanks but still not clear how to step forward to the other boundary point. We have two equation, i don't know from which one to start and how. What assumptions should be made and what concrete processes? Can you make it a little bit more clear?! Thank you.
 
  • #4
Are you familiar with Euler's method? It is well explained there, but I'll summarize. You know y1(0) and y2(0). From your Diff. Eq, you can calculate y1'(0) and y2'(0). Since y1' = Δy/Δx, you can write Δy1 = y1'(0) * Δx, Δy2 = y2'(0) * Δx. Then y1(Δx) = y1(0) + Δy1, y2(Δx) = y2(0) + Δy2. You just keep doing this, incrementing x by small steps (which I called Δx, and the Wiki article calls h), until you arrive at x=1.

Edit: Corrected the expressions for Δy1 and Δy2.
 
Last edited:
  • #5
Are you allowed to solve this problem analytically?

Chet
 
  • #6
Chestermiller said:
Are you allowed to solve this problem analytically?

Chet
A good question. I kind of got interested in this problem. It can be solved both numerically and analytically, and it is very instructive to compare the two methods and see how close the numerical method comes to the analytical solution.
 
  • #7
Chestermiller said:
Are you allowed to solve this problem analytically?

Chet

No, only numerically.
 
  • #8
In iterating to get the initial value of y2 at x = 0, you are essentially solving a non-linear algebraic equation. What I usually do is apply Newton's method, approximating the derivative of the function numerically. Another approach would be to make use of the half-interval method (if you can get the solution for y2(0) bracketed).

Chet
 
  • #9
You can find all sorts of shooting method BVPs online. It essentially turns a BVP into an initial condition problem

The problem you posted is a very simple one and tons of examples can be found on google.
 
  • #10
electronic engineer said:
Thanks but still not clear how to step forward to the other boundary point. We have two equation, i don't know from which one to start and how. What assumptions should be made and what concrete processes? Can you make it a little bit more clear?! Thank you.

You have to treat them as the single vector equation [tex]
\begin{pmatrix} y_1' \\ y_2' \end{pmatrix} = \begin{pmatrix} -y_1^2 y_2 \\ y_1y_2^2 \end{pmatrix}.
[/tex] Every numerical ODE solution method deals with vector ODEs.

The point of the exercise is to take a guess for [itex]y_2(0)[/itex] and see whether [itex]y_2(1) = 2[/itex]. You do need to do some analysis of the phase space first in order to obtain a plausible initial guess. Here the phase space is the [itex](y_1,y_2)[/itex]-plane. You can see that both the [itex]y_1[/itex]-axis and the [itex]y_2[/itex]-axis consist of fixed points, so a trajectory which starts with [itex]y_1 = 1 > 0[/itex] and ends with [itex]y_2 = 2 > 0[/itex] must remain in the region [itex]y_1 > 0[/itex] and [itex]y_2 > 0[/itex].

It then follows that [itex]y_1'[/itex] will be strictly negative, so [itex]y_1[/itex] is strictly decreasing with [itex]x[/itex], whilst [itex]y_2'[/itex] is strictly positive, so [itex]y_2[/itex] is strictly increasing with [itex]x[/itex]. This means that you can confine your attention to [itex]0 < y_2(0) < 2[/itex].
 
  • #11
phyzguy said:
Are you familiar with Euler's method? It is well explained there, but I'll summarize. You know y1(0) and y2(0). From your Diff. Eq, you can calculate y1'(0) and y2'(0). Since y1' = Δy/Δx, you can write Δy1 = y1'(0) * Δx, Δy2 = y2'(0) * Δx. Then y1(Δx) = y1(0) + Δy1, y2(Δx) = y2(0) + Δy2. You just keep doing this, incrementing x by small steps (which I called Δx, and the Wiki article calls h), until you arrive at x=1.

Edit: Corrected the expressions for Δy1 and Δy2.

So when i applied your equations I got y1(1)=0 and y2(1)=2 assuming y2(0)=1 for increments h=0.2. Which is quite logical because y1 is strictly decreasing with x and y2 is strictly increasing with x as pasmith said.
 
  • #12
electronic engineer said:
So when i applied your equations I got y1(1)=0 and y2(1)=2 assuming y2(0)=1 for increments h=0.2. Which is quite logical because y1 is strictly decreasing with x and y2 is strictly increasing with x as pasmith said.
Shouldn't the product of y1 and y2 be constant?

Chet
 
  • #13
Chestermiller said:
Shouldn't the product of y1 and y2 be constant?

Chet

I don't think so but why do you ask?
 
  • #14
The analytic solution says that the product is constant. I ask because you got y1(1) = 0. It doesn't look like you updated the derivatives during the Euler integration.

Chet
 
  • #15
electronic engineer said:
So when i applied your equations I got y1(1)=0 and y2(1)=2 assuming y2(0)=1 for increments h=0.2. Which is quite logical because y1 is strictly decreasing with x and y2 is strictly increasing with x as pasmith said.

This is incorrect. Your increments are probably too large. I used h = .001. Chestermiller is right - the product y1*y2 is constant, which you can see by adding y2 *(first equation) + y1 * (second equation).
 
  • #16
phyzguy said:
This is incorrect. Your increments are probably too large. I used h = .001. Chestermiller is right - the product y1*y2 is constant, which you can see by adding y2 *(first equation) + y1 * (second equathion).

By calculating manually with the same steps for h=0.2 (which is quite large as you said) I got y2(1)=2,..(something) I don't remember but i think it's still acceptable for this large assumtption of h, so the guess that y2(0)=1 was not bad I think.

Yes and y1(1) is almost 0.5 which ensures that y1(0)*y2(0)=y1(1)*y2(1)=C=1
 
  • #17
electronic engineer said:
By calculating manually with the same steps for h=0.2 (which is quite large as you said) I got y2(1)=2,..(something) I don't remember but i think it's still acceptable for this large assumtption of h, so the guess that y2(0)=1 was not bad I think.

Yes and y1(1) is almost 0.5 which ensures that y1(0)*y2(0)=y1(1)*y2(1)=C=1
The analytic solution for the initial condition on y2 you used is y2(1)= e = 2.72

Chet
 

1. What is the Shooting Method for BVP?

The Shooting Method for BVP (Boundary Value Problem) is a numerical method used to solve ordinary differential equations (ODEs) with given boundary conditions. It involves converting the ODE into a system of first-order equations, and then using an initial value solver on the resulting system to obtain a solution that satisfies the boundary conditions.

2. When is the Shooting Method used?

The Shooting Method is typically used when analytical solutions to the boundary value problem are not available or are difficult to obtain. It is also useful when the boundary value problem involves nonlinear boundary conditions, making other methods such as finite difference or finite element methods more challenging to use.

3. How does the Shooting Method work?

The Shooting Method works by guessing the initial values for the ODEs and then iteratively adjusting these values until the resulting solution satisfies the given boundary conditions. This is done by using a root-finding algorithm, such as the bisection method or Newton's method, to find the correct initial values that will produce a solution that satisfies the boundary conditions.

4. What are the advantages of using the Shooting Method?

One advantage of the Shooting Method is that it can be applied to a wide range of boundary value problems, including nonlinear and singular problems. It also does not require the problem to be discretized, making it more efficient compared to other numerical methods. Additionally, the Shooting Method is relatively easy to implement and can provide accurate solutions with proper adjustments of the initial values.

5. What are the limitations of the Shooting Method?

One limitation of the Shooting Method is that it may not converge to a solution if the initial value guesses are not close enough to the actual solution. This can be time-consuming as multiple initial value guesses and iterations may be needed to obtain a satisfactory solution. The Shooting Method can also be sensitive to changes in the boundary conditions, making it less robust for certain types of boundary value problems.

Similar threads

  • Differential Equations
Replies
1
Views
1K
Replies
4
Views
758
  • Differential Equations
Replies
8
Views
4K
  • Differential Equations
Replies
2
Views
4K
Replies
4
Views
1K
Replies
8
Views
2K
Replies
2
Views
1K
Replies
7
Views
2K
  • Differential Equations
Replies
4
Views
955
Back
Top