NUMERICAL METHODS: SOLVING THE SECONDORDER ODE BVP Presentation by Addison Euhus, Nathan Feldman, Xiaoyue Pi, Zachary Rom, Guillaume Toujas Overview of Second-Order ODE BVPs Second Order ODE F(y”, y’, y, x) = 0 Boundary Value Conditions • Dirichlet: y(a) = α y(b) = β • Neumann: y’(a) = α y’(b) = β • Mixed: y(a) = α y’(b) = β • Robin: M*y(a) – N*y’(a) = α M*y(b) + N*y’(b) = β Real World Applications Electrically Conducting Solids y’’ = λeμy y(0) = y(1) = 0 This arises in applications involving the diffusion of heat generated by positive temperature-dependent sources Circular Membrane Theory y’’ + k/y2 + 3y’/x = 0, 0<x<1 At the edge we have y(1) = λ > 0, at the center we have y’(0) = 0 This is the equation for a circular membrane subject to normal uniform pressure Overview of Numerical Methods We will cover four basic methods used to solve second-order ODE BVPs in one-dimension space • Shooting Method Solving the IVP and tweaking the parameters to fit the BVP • Finite Difference Method Replacing derivatives with difference approximations and solving the resulting linear system • Finite Element Method Covered in class, subdivides domain into finite elements and minimizes associated error function • Quadrature Method Constructs an integral representation of the problem and applies numerical integration techniques Shooting Method BVP Problem Shooting: Core Idea • Convert BVP into an IVP problem. • This requires a guess y’(a) = θ • Reduce high order ODE into system first order ODEs • Solve the IVP (let y(b, θ) denote solution at be with our guess • y(b, θ) == β then IVP solution is equivalent to BVP solution • y(b, θ) != β then choose a new guess (pick smartly) • Taking a guess and “firing at a target” is where the method derives its name Shooting Advantages and Disadvantages • Advantages • Solves both linear and non-linear BVPs • Simple implementation • Effect when the interval [a,b] is short since its “easier” to shoot a target a short distance away • Disadvantages • Unstable for some problems. Typically those of highly nonlinear or unstable ODEs. • Requires a good initial guess for the IVP as the numerical method does not guarantee convergence. • The length of the interval of the boundary values has a high impact on the results. A large interval requires a large number of iterations. Reduction Solve the IVP • Numerical Scheme • Euler, RK23, RK45, etc • F(θ) represents the difference between IVP solution and β • F(θ)= y(b; θ)- β • If F contains a root with the value θ then the solution y(b; θ) to our IVP problem is also a solution to the BVP problem. • Linear ODE use Linear Interpolation (proof in paper) • Non-linear ODE use Secant, Newtons, or other root finding method Linear ODE • Guess y’(a) = 0 and y’(a) = 1 and reduce BVP to IVP along with high order to system first order ODEs • Linear combination of solutions of the ODE also satisfies the ODE • y(x) = y(x;0) + θy(x;1) • y(b) = y(b;0) + θy(b;1) = β • Result (proof in paper and its references) Nonlinear Using Secant Nonlinear Using Secant Procedure • Convert the BVP into IVP form as a system of first order • • • • ODEs. Choose two guesses θ1 and θ2 Solve an IVP1 where y’(a)=θ1 and IVP2 where y’(a)=θ2 Compute F(θ1) and F(θ2) While (we have not converged up to the tolerance we want) • Use the secant method to guess the next θ1 and θ2 • Solve the IVP using these two new guesses using the numerical scheme of your choice (Euler, RK, etc) • Compute Fθ1 and Fθ2 • Check for convergence of the root Nonlinear Using Newton’s Therefore we must know F’(θ) since we are finding the root of F(θ) Define z(x;θ) as It satisfies ODE Nonlinear Using Newton’s By differentiating the original BVP with respect to θ Notice that we can obtain Therefore in Newton’s method we can state F’(θ) in terms of z, and now we can use Newton’s method Another IVP! • Newton’s method requires another IVP to be solved during each iteration. • We make up for this additional computation by taking advantage of the fast convergence of Newton’s method IVPs Nonlinear Newton’s • First • Second Nonlinear Using Newton’s Procedure • Choose a numerical scheme for solving systems of first order ODEs, such as Euler or Runge-Kutta • Convert BVP into an IVP1 problem and then convert the BVP representing Newton’s method to the IVP2. See the above conversions • Until convergence do • Solve both IVP1 and IVP2 using numerical scheme • Use Newton’s Method to approximate the next guess for θ where F'θ=z(b) Example • BVP • Exact Shooting With RK4-5 and Secant Shooting with RK4-5 and Newton’s Dealing With Short Interval Problem • Multiple Shooting Method • We only discussed the single shooting method, but for those who are interested you can research the multiple-shooting method. • Split interval into pieces and solve an IVP on each piece. See references in paper Multiple Shooting Method Split the interval up and solve the IVP in each interval. The Finite Difference Method • Approximates the differential operator by replacing the derivatives in the equation using difference quotients • These difference quotients are derived from the Taylor Series of u(x+h) and u(x-h) Name Value Approximation Error Forward Difference u’ (un+1 – un)/h O(h) Backward Difference u’ (un – un-1)/h O(h) Central Difference u’ (un+1 – un-1)/(2h) O(h2) Consistent SecondOrder u’’ (un+1 – 2un + un-1)/h2 O(h2) • Example: u” – 2u = x2 becomes un+1/h2 – (2 – 2/h2)un + un-1/h2 = xi2 Finite Difference Procedure 1. Discretize x Dirichlet: Given u(a) and u(b) Neumann: Given u(a) and u’(b) 2. Discretize the ODE Example: un+1/h2 – (2 – 2/h2)un + un-1/h2 = xi2 3. Discretize the Boundary Conditions For Neumann only: 4. u½ ≅ (u0+u1)/2 u’N-½ ≅ (uN – uN-1)/h Construct a Linear System and Solve Characteristics of FD Method PROS CONS Very easy to implement Does not work very well on large intervals Results in solving a system with a tridiagonal matrix Accuracy is reduced due to computation of linear system Existence, Consistency and Accuracy: -u”(x) + c(x)u(x) = f(x) with Dirichlet Conditions • If c(x) > 0 for x ∈ [x0,xN] then A is symmetric positive definite, and therefore a solution exists • If u ∈ C4(x0,xN) then using the error terms, it can be shown that the finite difference numerical scheme is consistent and second-order accurate Example: Exact Solution: u(x) = x2sin(10x) Second-Order ODE: u” + 100u = 40xcos(10x) + 2sin(10x) u(0) = 0, u(1) = sin(10) N=5 N = 500 N = 50 The Finite Element Method • We have covered the procedure of the method in class before the third midterm, so everyone already has some familiarity with it • The method can be used to solve boundary value problem (BVP) by using Galerkin approximation • The Galerkin method can also be used to solve Initial Value Problem (IVP). Basically, we can achieve it by either using weak form combined with stabilizing techniques or using least-squares process The Positive-Definite Constraint • When the differential operator is self-adjoint (if and only if A = A*) the Galerkin method with weak form and least squares process are the only FEM that guarantee positive-definite coefficient matrix • When the differential operator is non-self adjoint or nonlinear the least square process is the only FEM that guarantees a positive-definite coefficient matrix • When considering an IVP, the differential operator is either non-self adjoint or nonlinear. It is never self-adjoint. Hence, the only FEM that can guarantee positive definite coefficient matrices for all IVPs is least squares process Practical Uses of the FEM • Many people are under the impression that the Galerkin method with weak form is the only FEM – this happens because almost all commercial FEM software is based on this method • The reason for this is because the differential operators of differential equations which describe elastic solid mechanics are always self-adjoint, hence the Galerkin method with weak form works very well • Around the late 1990s, the additional resources needed for least-squares were invented, and least-squares started being used in the research area. However, since so many companies were built on Galerkin method with weak form and they are only marketed towards solid mechanics applications, they still continue to use it Differences Between FDM and FEM • FEM uses calculations at each individual interval and tends to be more computationally expensive • FDM uses the current step to find the next one using finite difference formulation • For the most part FEM is a bit more accurate, but in dynamic problems based on time, FDM can be preferred for accuracy The Quadrature Method: The Goal • Find the integral form of the solution for a second-order boundary-value problem. Use quadrature rules to solve the equation for the boundary value problem • Essentially, solve the ODE numerically by converting it into an integral and solving the integral using already established numerical methods For a classic 2nd-order boundary problem… 1. Have the following form for a second-order BVP: 𝑦 ′′ = 𝑓(𝑥, 𝑦, 𝑦′), 𝑓 𝑥𝑜 = 𝑦𝑜 , 𝑓 𝑥𝑀 = 𝑦𝑀 ; 𝑥𝑜 < 𝑥𝑀 2. Approximate the Value of 𝑦′ 𝑥𝑖 at strategically chosen 𝑥𝑖 For instance, use Runge-Kutta to approximate y ′ 𝑥𝑖 , x0 < xi < xM for various 𝑥𝑖 3. Use numerical integration to approximate 𝑦 𝑥𝑗 For instance, given our values found for 𝑥𝑗 ′ ′ 𝑦 𝑥𝑗 , 𝑦 , 𝑦′ 0 , 2 use Simpson’s rule to approximate 𝑦(𝑥𝑗 ) A Basic Example • Let’s say we are given the equation 𝑦 ′′ = 𝑓 𝑥, 𝑦, 𝑦 ′ ; y 0 = e, y 1 = 0 • We have used Runge-Kutta to approximate the value y’(1/4) = 1/2 • Note: This isn’t the actual value obtained, but it is usable to illustrate the concept • We can then approximate y 1 2 =𝑦 0 + 0 𝑦′(𝑥) 1/2 = 1 ′ 1 𝑦 + 𝑦 0 = 𝑒 + .25 2 4 • Note: This is just using the midpoint rule, an extremely poor method of approximation • We can use this technique to approximate any values of y in (0,1) Advantages and Disadvantages Pros: • This method allows us to use any method of numerical integration. For instance, if we want to use Gaussian 2-point quadrature rules, we can use that instead of the midpoint method (which is obviously a vast improvement) • The method allows us to approximate the solutions to difficult differential equations, where the actual value of the integral may be difficult to find Cons: • The different values of 𝑥𝑖 we find limit the method of numerical integration that we can use. For instance, if we have a differential equation over (0,1) and y’(0.00001), then using the midpoint method only approximates y(0.00002). This means it becomes more difficult to get accuracy near the endpoints of the interval without extremely small step sizes, which take large amounts of computational time • Taking large step sizes isn’t easy either. If we want to use our midpoint method again, we are stuck only using values of y’(x < ½) Conclusion • There are a variety of different methods that can be used to determine numerical solutions to second-order ODE BVPs. Each method has strengths and weaknesses, and the selection of the method is greatly influenced by the specific problem that is being analyzed. • As we have seen throughout the presentation, many established numerical procedures – such as solutions to matrix equations and numerical integration techniques – are incorporated into the analysis and computation of the approximations to these ODEs.