Given Applied Numerical Methods with MATLAB fo

23.10 The oscillations of a swinging pendulum can be sim- ulated with the following nonlinear model: d 2 θ dt 2 + g l sin θ = 0 where θ = the angle of displacement, g = the gravitational constant, and l = the pendulum length. For small angular displacements, the sin θ is approximately equal to θ and the model can be linearized as d 2 θ dt 2 + g l θ = 0 Use ode45 to solve for θ as a function of time for both the linear and nonlinear models where l = 0.6 m and g = 9.81 ms 2 . First, solve for the case where the initial condition is for a small displacement θ = π8 and dθdt = 0. Then repeat the calculation for a large displace- ment θ = π2. For each case, plot the linear and nonlinear simulations on the same plot. 23.11 Employ the events option described in Section 23.1.2 to determine the period of a 1-m long, linear pendulum see description in Prob. 23.10. Compute the period for the fol- lowing initial conditions: a θ = π8, b θ = π4, and c θ = π2. For all three cases, set the initial angular veloc- ity at zero. Hint: A good way to compute the period is to determine how long it takes for the pendulum to reach θ = 0 [i.e., the bottom of its arc]. The period is equal to four times this value. 23.12 Repeat Prob. 23.11, but for the nonlinear pendulum described in Prob. 23.10. 23.13 The following system is a classic example of stiff ODEs that can occur in the solution of chemical reaction kinetics: dc 1 dt = −0.013c 1 − 1000c 1 c 3 dc 2 dt = −2500c 2 c 3 dc 3 dt = −0.013c 1 − 1000c 1 c 3 − 2500c 2 c 3 Solve these equations from t = 0 to 50 with initial conditions c 1 = c 2 = 1 and c 3 = 0. If you have access to MATLAB software, use both standard e.g., ode45 and stiff e.g., ode23s functions to obtain your solutions. 23.14 The following second-order ODE is considered to be stiff: d 2 y d x 2 = −1001 d y d x − 1000y Solve this differential equation a analytically and b numerically for x = 0 to 5. For b use an implicit approach with h = 0.5. Note that the initial conditions are y = 1 and y ′ 0 = 0. Display both results graphically. 23.15 Consider the thin rod of length l moving in the x-y plane as shown in Fig. P23.15. The rod is fixed with a pin on one end and a mass at the other. Note that g = 9.81 ms 2 and l = 0.5 m. This system can be solved using ¨ θ − g l θ = Let θ0 = 0 and ˙ θ 0 = 0.25 rads. Solve using any method studied in this chapter. Plot the angle versus time and the angular velocity versus time. Hint: Decompose the second- order ODE. 23.16 Given the first-order ODE: d x dt = − 700x − 1000e −t xt = 0 = 4 Solve this stiff differential equation using a numerical method over the time period 0 ≤ t ≤ 5. Also solve analyti- cally and plot the analytic and numerical solution for both the fast transient and slow transition phase of the time scale. 23.17 Solve the following differential equation from t = 0 to 2 d y dt = − 10y with the initial condition y0 = 1. Use the following tech- niques to obtain your solutions: a analytically, b the ex- plicit Euler method, and c the implicit Euler method. For b and c use h = 0.1 and 0.2. Plot your results. 23.18 The Lotka-Volterra equations described in Sec- tion 22.6 have been refined to include additional factors that impact predator-prey dynamics. For example, over and above predation, prey population can be limited by other FIGURE P23.15 q m l PROBLEMS 615 factors such as space. Space limitation can be incorporated into the model as a carrying capacity recall the logistic model described in Prob. 22.5 as in d x dt = a 1 − x K x − bxy d y dt = −cy + dxy where K = the carrying capacity. Use the same parameter values and initial conditions as in Section 22.6 to integrate these equations from t = 0 to 100 using ode45 , and develop both time series and phase plane plots of the results. a Employ a very large value of K = 10 8 to validate that you obtain the same results as in Section 22.6. b Compare a with the more realistic carrying capacity of K = 200. Discuss your results. 23.19 Two masses are attached to a wall by linear springs Fig. P23.19. Force balances based on Newton’s second law can be written as d 2 x 1 dt 2 = − k 1 m 1 x 1 − L 1 + k 2 m 1 x 2 − x 1 − w 1 − L 2 d 2 x 2 dt 2 = − k 2 m 2 x 2 − x 1 − w 1 − L 2 where k = the spring constants, m = mass, L = the length of the unstretched spring, and w = the width of the mass. Com- pute the positions of the masses as a function of time using the following parameter values: k 1 = k 2 = 5, m 1 = m 2 = 2, w 1 = w 2 = 5, and L 1 = L 2 = 2. Set the initial conditions as x 1 = L 1 and x 2 = L 1 + w 1 + L 2 + 6. Perform the simulation from t = 0 to 20. Construct time-series plots of both the dis- placements and the velocities. In addition, produce a phase- plane plot of x 1 versus x 2 . 23.20 Use ode45 to integrate the differential equations for the system described in Prob. 23.19. Generate vertically stacked subplots of displacements top and velocities bottom. Employ the fft function to compute the discrete Fourier transform DFT of the first mass’s displacement. Generate and plot a power spectrum in order to identify the system’s resonant frequencies. 23.21 Perform the same computations as in Prob. 23.20 but for the structure in Prob. 22.22. 23.22 Use the approach and example outlined in Sec- tion 23.1.2, but determine the time, height, and velocity when the bungee jumper is the farthest above the ground, and generate a plot of the solution. k 2 k 1 L 1 w 1 L 2 w 2 x 1 x 2 x m 1 m 2 FIGURE P23.19 616 Boundary-Value Problems CHAPTER OBJECTIVES The primary objective of this chapter is to introduce you to solving boundary-value problems for ODEs. Specific objectives and topics covered are • Understanding the difference between initial-value and boundary-value problems • Knowing how to express an nth-order ODE as a system of n first-order ODEs. • Knowing how to implement the shooting method for linear ODEs by using linear interpolation to generate accurate “shots.” • Understanding how derivative boundary conditions are incorporated into the shooting method. • Knowing how to solve nonlinear ODEs with the shooting method by using root location to generate accurate “shots.” • Knowing how to implement the finite-difference method. • Understanding how derivative boundary conditions are incorporated into the finite-difference method. • Knowing how to solve nonlinear ODEs with the finite-difference method by using root-location methods for systems of nonlinear algebraic equations. YOU’VE GOT A PROBLEM T o this point, we have been computing the velocity of a free-falling bungee jumper by integrating a single ODE: dv dt = g − c d m v 2 24.1 Suppose that rather than velocity, you are asked to determine the position of the jumper as a function of time. One way to do this is to recognize that velocity is the first derivative 24.1 INTRODUCTION AND BACKGROUND 617 of distance: d x dt = v 24.2 Thus, by solving the system of two ODEs represented by Eqs. 24.1 and 24.2, we can simultaneously determine both the velocity and the position. However, because we are now integrating two ODEs, we require two conditions to obtain the solution. We are already familiar with one way to do this for the case where we have values for both position and velocity at the initial time: xt = 0 = x i v t = 0 = v i Given such conditions, we can easily integrate the ODEs using the numerical techniques described in Chaps. 22 and 23. This is referred to as an initial-value problem. But what if we do not know values for both position and velocity at t = 0? Let’s say that we know the initial position but rather than having the initial velocity, we want the jumper to be at a specified position at a later time. In other words: xt = 0 = x i xt = t f = x f Because the two conditions are given at different values of the independent variable, this is called a boundary-value problem. Such problems require special solution techniques. Some of these are related to the methods for initial value problems that were described in the previous two chapters. How- ever, others employ entirely different strategies to obtain solutions. This chapter is de- signed to introduce you to the more common of these methods.

24.1 INTRODUCTION AND BACKGROUND

24.1.1 What Are Boundary-Value Problems? An ordinary differential equation is accompanied by auxiliary conditions, which are used to evaluate the constants of integration that result during the solution of the equation. For an nth-order equation, n conditions are required. If all the conditions are specified at the same value of the independent variable, then we are dealing with an initial-value problem Fig. 24.1a. To this point, the material in Part Six Chaps. 22 and 23 has been devoted to this type of problem. In contrast, there are often cases when the conditions are not known at a single point but rather are given at different values of the independent variable. Because these values are often specified at the extreme points or boundaries of a system, they are customarily referred to as boundary-value problems Fig. 24.1b. A variety of significant engineering applications fall within this class. In this chapter, we discuss some of the basic approaches for solving such problems.

24.1.2 Boundary-Value Problems in Engineering and Science

At the beginning of this chapter, we showed how the determination of the position and ve- locity of a falling object could be formulated as a boundary-value problem. For that exam- ple, a pair of ODEs was integrated in time. Although other time-variable examples can be developed, boundary-value problems arise more naturally when integrating in space. This occurs because auxiliary conditions are often specified at different positions in space. A case in point is the simulation of the steady-state temperature distribution for a long, thin rod positioned between two constant-temperature walls Fig. 24.2. The rod’s cross- sectional dimensions are small enough so that radial temperature gradients are minimal and, consequently, temperature is a function exclusively of the axial coordinate x. Heat is transferred along the rod’s longitudinal axis by conduction and between the rod and the surrounding gas by convection. For this example, radiation is assumed to be negligible. 1 1 We incorporate radiation into this problem later in this chapter in Example 24.4. y y 1 y 2 t y 2, 0 y 1, 0 a b Initial conditions Boundary condition Boundary condition y y L x y L ⫽ f 1 t, y 1 , y 2 dy 1 dt ⫽ f 2 t, y 1 , y 2 dy 2 dt where at t ⫽ 0, y 1 ⫽ y 1, 0 and y 2 ⫽ y 2, 0 ⫽ f x, y d 2 y dx 2 where at x ⫽ 0, y ⫽ y x ⫽ L, y ⫽ y L FIGURE 24.1 Initial-value versus boundary-value problems. a An initial-value problem where all the conditions are specified at the same value of the independent variable. b A boundary-value problem where the conditions are specified at different values of the independent variable.