Baixe o app para aproveitar ainda mais
Prévia do material em texto
CSI 148 - NUMERICAL ANALYSIS ASSIGNMENT 3 Douglas do Amaral Monteiro - 11.2.8041 douglas.ammaral@yahoo.com.br April 3, 2017 Description A first-order ODE can be solved if the value of the dependent variable at one point is known, which we may call the initial value. In many cases, there is the need to solve differential equations of second and higher order that have constraints specified at different values of the independent variable. These problems are called boundary value problems (BVP). This document presents a brief overview about one of the most common methods to solve Boundary Value problems: the Shooting method. Some of the assignment objectives are 1. Understand the difference between initial-value and boundary-value problems. 2. Know how to express an nth-order ODE as a system of n first-order ODEs. 3. How to solve BVP with the shooting method. Introduction A boundary value problem can be solved by two different methods: the shooting method and the finite difference method. The shooting method consists of reducing the order of a n-differential order equation to n first order equations, each one with a initial value given. In other words, it consists of transforming a BVP in a multiple IVP. Usually, the two boundary conditions are the same as the endpoints of the domain. Knowing the first conditions is needed to perform the calculations for the solution. 1 The Boundary Value Problem Let’s consider the two-point boundary value problem d2y dt2 = −2tdy dt − 5y + cos(3t), (1) 1 CSI 148 - Numerical Analysis ICEA-UFOP with the boundary conditions y(0) = 1.5 and y(5) = 0. To solve the problem numerically, we introduce the variables y1 = y and y2 = dy dt which allows us to write a Eq. (1) as a system of two coupled first-order equations: dy1 dt = y2 (2) dy2 dt = −2ty2 − 5y1 + cos(3t) (3) with the boundary condtions y1(0) = 1.5 and y1(5) = 0. (4) To solve this problem, we are going to use the shooting method in two different ways: by means of the Euler method and the secant method and the built-in functions ODE45 and fzero. 1.1 Solution with ShootEulerSecant The steps to be followed to solve a two-point BVP by the shooting method with the Euler explicit method to in conjunction with the secant method are: 1. The ODE is transformed into a system of two first-order IVPs. we must have two equations of the form dy dx = w (5) and dw dx = f(x, y, w) (6) 2. A first estimate (guess) is made for the slope at x = a (first boundary condition). With this estimate, the system of equations (5) and (6) is solved numerically. 3. A second estimate (guess) is made for the slope at x = a, and the system is solved again. 4. A third estimate (guess) is made for the slope at x = a using the results of the previous two guesses. 2 CSI 148 - Numerical Analysis ICEA-UFOP in this step, a non-linear method can be used to estimate this third value. Common methods are linear interpolation, bisection and secant method. 5. Using w(a) = W3 as the initial slope, the system of equations is solved numerically again. If the numerical solution at x = b is equal to the boundary condition, Yb (or the error between the two is acceptable), then a solution has been obtained. Otherwise, as was done in Step 4, a new estimate for the initial value is determined. • Steps 4 and 5 are repeated until the numerical solution at x = b agrees to a required accuracy with the boundary condition. The script produced with the Euler explicit method and the secant method (ShootEulerSecantScript) gives the solution to the system shown in Figure 1. This script define all the system parameters and calls the ShootEulerSecant function, responsible for solving the ODEs and plotting the result. Figure 1 – Graph produced by the ShootEulerSecant function. 3 CSI 148 - Numerical Analysis ICEA-UFOP 1.2 Comparison between ShootEulerSecant and ShootODE45Fzero Now, the same system characterized by equations (2) and (3) was solved by the built-in functions included in Octave, that is, the ODE45 and fzero functions. A general script was made for the purpose of comparison of the two methods. The script is called generalScript, which calls both functions and plots the results on a single graph. The result is shown on Figure 2. Figure 2 – Graph produced to compare both methods. The ShootODE45fezero is shown in red, while the ShootEulerSecant is shown in blue. 4 CSI 148 - Numerical Analysis ICEA-UFOP References [1] GILAT, A.; SUBRAMANIAM, V.; Numerical Methods for Engineers and Scientits: An introduciton with applications using Matlab. 3 rd edition, John Wiley & Sons, New York, 2014. 5 The Boundary Value Problem Solution with ShootEulerSecant Comparison between ShootEulerSecant and ShootODE45Fzero
Compartilhar