INTRODUCTION TO NUMERICAL ANALYSIS
Cho, Hyoung Kyu
Department of Nuclear Engineering Seoul National University 10. NUMERICAL INTEGRATION
10.1 Background 10.11 Local Truncation Error in Second‐Order 10.2 Euler's Methods Range‐Kutta Method 10.3 Modified Euler's Method 10.12 Step Size for Desired Accuracy 10.4 Midpoint Method 10.13 Stability 10.5 Runge‐Kutta Methods 10.14 Stiff Ordinary Differential Equations 10.6 Multistep Methods 10.7 Predictor‐Corrector Methods 10.8 System of First‐Order Ordinary Differential Equations 10.9 Solving a Higher‐Order Initial Value Problem 10.10 Use of MATLAB Built‐In Functions for Solving Initial‐Value Problems 10.1 Background Ordinary differential equation A differential equation that has one independent variable A first‐order ODE . The first derivative of the dependent variable with respect to the independent variable
Example Rates of water inflow and outflow
The time rate of change of the mass in the tank
Equation for the rate of height change 10.1 Background Time dependent problem
Independent variable: time Dependent variable: water level
To obtain a specific solution, a first‐order ODE must have an initial condition or constraint that specifies the value of the dependent variable at a particular value of the independent variable.
In typical time‐dependent problems . Initial condition . Initial value problem (IVP) 10.1 Background First order ODE statement General form
Ex)
. Flow lines
Analytical solution In many situations an analytical solution is not possible!
Numerical solution of a first‐order ODE A set of discrete points that approximate the function y(x) Domain of the solution: , N subintervals 10.1 Background Overview of numerical methods used/or solving a first‐order ODE Start from the initial value Then, estimate the value at a second nearby point third point …
Single‐step and multistep approach
. Single step approach: . Multistep approach: ⋯, , ,
Explicit and implicit approach . Right hand side in explicit method: known values
. Right hand side in implicit method: unknown value
– In general, non‐linear equation non‐linear equation solution method !
. Implicit methods provide improved accuracy over explicit methods, but require more effort at each step. 10.1 Background Errors in numerical solution of ODEs Round‐off errors Truncation errors . Numerical solution of a differential equation calculated in increments (steps) . Local truncation error: in a single step . Propagated, or accumulated, truncation error – Accumulation of local truncation errors from previous steps
Single‐step explicit methods
Euler’s explicit method: slope at , Modified Euler’s explicit method: average slope at , and , Midpoint method: slope at /2 Runge‐Kutta methods . A weighted average of estimates of the slope of at several points 10.2 Euler’s Method Euler’s method step size is exaggerated ! Simplest technique for solving a first‐order ODE . Explicit or implicit
Euler's Explicit Method
The error in this method depends on the value of and is smaller for smaller h.
Derivation Numerical integration or finite difference approximation of the derivative
(rectangle method)
(forward Euler method) 10.2 Euler’s Method Example 10‐1: Solving a first‐order ODE using Euler's explicit method. 10.2 Euler’s Method Example 10‐1: Solving a first‐order ODE using Euler's explicit method.
% Solving Example 8-1 clear all a=0; b=2.5; h=0.1; yINI = 3; [x, y] = odeEULER(@Chap8Exmp1ODE,a,b,h,yINI); xp=a:0.1:b; yp=70/9*exp(-0.3*xp)-43/9*exp(-1.2*xp); plot(x,y,'--b',xp,yp) xlabel('x'); ylabel('y')
function dydx = Chap8Exmp1ODE(x,y) dydx = -1.2*y + 7*exp(-0.3*x);
function [x, y] = odeEULER(ODE,a,b,h,yINI)
x(1) = a; y(1) = yINI; N = (b-a)/h; for i = 1:N x(i+1) = x(i) + h; y(i+1) = y(i) + ODE(x(i),y(i))*h; end 10.2 Euler’s Method Analysis of truncation error in Euler's explicit method Local truncation error Global truncation error
Taylor series expansion at position 1
Numerical solution
Local truncation error
Total error . The difference between the numerical solution and the true solution. 10.2 Euler’s Method Analysis of truncation error in Euler's explicit method Global truncation error . Truncation error is propagated or accumulated !
Mean value theorem 10.2 Euler’s Method Analysis of truncation error in Euler's explicit method Global truncation error
. Suppose
. Propagation of error – At the first point to the second point to the third point
– At the fourth point
– At the point
. Suppose 10.2 Euler’s Method Analysis of truncation error in Euler's explicit method Global truncation error . Suppose
– Difficult to determine the order of magnitude directly – Possible to determine the bound