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

electronic engineer
Messages
145
Reaction score
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
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.
 
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.
 
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:
Are you allowed to solve this problem analytically?

Chet
 
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.
 
Chestermiller said:
Are you allowed to solve this problem analytically?

Chet

No, only numerically.
 
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
 
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 <br /> \begin{pmatrix} y_1&#039; \\ y_2&#039; \end{pmatrix} = \begin{pmatrix} -y_1^2 y_2 \\ y_1y_2^2 \end{pmatrix}.<br /> Every numerical ODE solution method deals with vector ODEs.

The point of the exercise is to take a guess for y_2(0) and see whether y_2(1) = 2. 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 (y_1,y_2)-plane. You can see that both the y_1-axis and the y_2-axis consist of fixed points, so a trajectory which starts with y_1 = 1 &gt; 0 and ends with y_2 = 2 &gt; 0 must remain in the region y_1 &gt; 0 and y_2 &gt; 0.

It then follows that y_1&#039; will be strictly negative, so y_1 is strictly decreasing with x, whilst y_2&#039; is strictly positive, so y_2 is strictly increasing with x. This means that you can confine your attention to 0 &lt; y_2(0) &lt; 2.
 
  • #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
 
Back
Top