PREVIOUS: Variable Time Steps | UP: Course Outline | NEXT: Matrix Methods |
y'' = -y y(0) = 1, y(1) = 2What value of y'(0) solves the system? Add one or two applications of the secant method once bisection has converged to the desired tolerance to improve the accuracy of the method. Solution. Animated solution.
y'' = -y - 10 y3 y(0) = 1, y(1) = 2with 0 < y'(0) < 50. Be careful with your starting point for the bisection search. Solution
y'' = -y - 10 y3 y(0) = 1, y(1) = 2with -100 < y'(0) < 100, using the shooting method. Plot the solutions on a single graph, with a legend (or labels) stating which is which.
dy[0]/dx = y[1] dy[1]/dx = -y[2]*y[0] dy[2]/dx = 0Thus the function f must be modified to return a zero in its new (third) component. We continue to bisect on z using the (unchanged) function g(z). The function integrate changes from
def integrate(func, a, ya, za, b, dx): x = a y = np.array([ya, za]) while x < b-0.5*dx: x, y = rk4_step(f, x, y, dx) return x, yto
def integrate(func, a, ya, z, b, dx): x = a y = np.array([ya, 1.0, z]) # <--- while x < b-0.5*dx: x, y = rk4_step(f, x, y, dx) return x, y
y'' = -z y y(-1) = 0, y(1) = 0Solution Animated solution.
y'' = -E y + U(x) y U(x) = x2, -5 < x < 5 y(-5) = 0, y(5) = 0Solution
U(x) = 0, |x| < a U(x) = U0, |x| > a,and 0 < E < U0, we know that the exterior solution must be of the form
y = A exp(-eta*x)where eta^2 = U0 - E = U0 - z here. Differentiating, we have
y' + eta y = 0This is the boundary condition to be applied at |x| = a. This general approach applies to any system in which U(x) tends to a constant as |x| goes to infinity.
applying the above boundary condition at |x| = 5.
y ~ e-x2/2and
y' ~ xyso we can take y = 0 at x = x0 (i.e. we simply adopt the "confined" oscillator presented earlier). In this case, however, the rapidly falling functional form of the solution means that shooting from -x0 to x0 can become numerically unstable, and it is better to shoot from the center to x = x0. This is particularly simple in cases (like all those we have seen) where the potential is symmetric about x = 0. We then expect even or odd solutions for y, which we can select by choosing
y = 1, y' = 0 (even) y = 0, y' = 1 (odd)at x = 0.
U(x) = x2by shooting from x = 0 to x = x0 = 6, with y(x0) = 0.