Download presentation
Presentation is loading. Please wait.
1
NUMERICAL METHODS IN ELECTRICAL ENGINEERING
CEE203 NUMERICAL METHODS IN ELECTRICAL ENGINEERING Assist. Prof. Dr. Çağatay ULUIŞIK
2
OUTLINE Introducing MatLab Fundamental Terms, Basic Definitions
Solving Nonlinear Equations – Root Finding Solving Systems of Linear Equations Taylor Series Numerical Differentiation Numerical Integration Curve Fitting and Interpolation Ordinary Differential Equations
3
INTRODUCING MATLAB Vectors, Arrays and Matrices
Assign a value to a variable (observe the effect of the semicolon): Creating a row vector of size (14) Creating a column vector of size (41) Creating an array of size (19) using the colon sign (:)
4
INTRODUCING MATLAB Creating an array of size (19) using the for loop : Creating a matrix of size (33) : Creating a matrix of size (33) using 2 for loops :
5
BASIC MATRIX OPERATIONS IN MATLAB
6
GRAPHIC UTILITIES OF MATLAB
7
GRAPHIC UTILITIES OF MATLAB
8
COMPLEX NUMBERS IN MATLAB
Defining a Complex Number : Conjugate : Magnitude : Angle in Radians : Angle in Degrees : Addition : Subtraction : Multiplication : Division :
9
LOADING DATA FROM A FILE AND SAVING DATA TO A FILE
10
STATISTICS IN MATLAB Generation of Uniformly Distributed Random Numbers : Generation of Uniformly Distributed Random Integers : Mean Value : Variance : Standard Deviation :
11
INTRODUCING MATLAB Roots of a Polynom : Symbolic Integration :
Numeric Integration : clc : To clear the command window clear all : To clear all the variables in memory
12
FORMAT OF DATA round floor ceil Round towards nearest integer
Round towards minus infinity ceil Round towards plus infinity
13
EXAMPLES OF MATLAB SCRIPTS
Example 1 : Calculating of the sum of integers from 1 to a user-specifed value n a) using a formula b)using iterations Example 2 : Creating and Calling a function
14
EXAMPLES OF MATLAB SCRIPTS
Example 3 : Error of the first n terms in the Taylor Series of the function ex a) Calculating the error for a given n value b) Calculating the minimum required number of terms n for a given error. a) b)
15
FUNDAMENTAL TERMS Accuracy: Closeness of agreement between a measured / computed value and a true value. Measurement accuracy: the ability of an instrument to measure the true value to within some stated error specifications. Numerical accuracy: the degree to which the numerical solution to the approximate physical problem approximates the exact solution to the approximate physical problem.
16
MEASUREMENT ACCURACY Comparison of a measured value with the real value Meas. Value Meas. frequency Mean Value interval Accuracy = (%) True val. – Meas. val True value True value ?
17
ERROR It is the difference between a measured or calculated value of a quantity and its exact value. Systematic error plagues experiments or calculations caused by negative factors. For example, a DC voltage component, which unintentionally is present, e.g., because of a failure on the blockage capacitor, is a systematic error. These can be removed once understood/discovered via controls and calibration. Random error is an error which is always present, but varies unpredictably in size and direction. They are related to the scatter in the data obtained under fixed conditions which determine the repeatability (precision) of the measurement and follow well-behaved statistical rules.
18
ERROR Absolute error: It is an error that is expressed in physical units. It is the absolute value of the difference between the measured value and the true value (or the average value if the true value is not known) of a quantity. Relative error: An error expressed as a fraction of the absolute error to the true (or average) value of a quantity. It is always given as a percentage.
19
ERROR A number is represented with a finite (fixed) number of digits called word length. Precision of a measurement or the accuracy of a computation bounds the number of significant digits. All non-zero digits beyond the number of significant digits at the right of a number are removed in one of two ways; truncation or round-off. For example, has 6 significant digits. If it is going to be represented only by 4 significant digits both truncation and round-off processes yield On the other hand, if the number of significant digits will be 3, then truncation and round-off processes yield, 53.0 and 53.1, respectively.
20
ERROR CALCULATIONS A measurement/calculation result should be given as (a a), which means the value may be anything between (a - a) and (a + a). For example, if the measured speed is 98 3 km/hr, then the real value may be anything between 95 and 101 km/hr. Total error is the sum of individual errors for the arithmetic combination of two measurements. Total relative error is the sum of individual relative errors for the mulitlicative combination of two measurements.
21
ERROR CALCULATIONS A parameter (say “A”) is going to be estimated / calculated from two measurements (say “B” and “C”), with the measurement errors of “b” and “c”, respectively. If A = B + C then total error will be If A = B C then total error will be
22
ERROR CALCULATIONS In general, the total (propagated) error is obtained from these two properties as For a multi-variable function, the total error is calculated from
23
UNCERTAINTY Uncertainty is a range that is likely to contain the true value of a quantity being measured or calculated. Uncertainty can be expressed in absolute or relative terms. Modeling uncertainty is defined as the potential deficiency due to a lack of information. Modeling error is the recognizable deficiency not due to a lack of information but due to the approximations and simplifications made there. Measurement error is the difference between the measured and true values, while measurement uncertainty is an estimate of the error in a measurement.
24
UNCERTAINTY Modeling and simulation uncertainties occur during the phase of Conceptual modeling of the physical system Mathematical modeling of the conceptual model Discretization Computer modeling of the mathematical model Computer modeling of the discrete model Numerical solution Numerical uncertainties occur during computations due to round-off, turncation, non-convergence, artificial dissipations, etc.
25
ERROR / UNCERTAINTY Digital Voltmeter Accuracy:
(0.25 % Reading + 2 digit) Meaning; multiply the value you read on the multimeter by % (i.e., by ) . This is called scaling error. Add 2 times the value of the least significant digit to the result. This is called quantization error. Example: You read V from a 20 V scale. Measurement error : = V Quantization error : 2 0.01 = 0.02 V Total error : = V
26
MODELING ERROR Truncation error is also defined for mathematical modeling. For example, Taylor’s expansion or a Fourier-series representation are used to replace a function in terms of an infinite summation. Taking only a given number of low-order terms, and neglecting the rest of the higher-order terms, introduces a truncation error. For example, the Taylor expansion of the exponent function: yields (for n=3)
27
2Pt 3Pt + O(∆x) + O(∆x2) FDTD MODELING ERROR Derivative
f(x) Mathematical definition Finite difference approximation 2Pt + O(∆x) 3Pt + O(∆x2)
28
SOLVING NONLINEAR EQUATIONS
Fixed Point Iteration Method Bisection Method Secant Method Newton-Raphson Method MatLab Built-in Functions
29
FIXED POINT ITERATION METHOD
The equation f(x)=0 is rewritten in the form : The intersection point of the graphs of the functions y=x and y=g(x) is the solution and is called the fixed point . The numerical solution is obtained by an iterative process. First a xi value near the fixed point is chosen and substituted into g(x). The solution is substituted back into g(x). So the iteration formula is given by:
30
FIXED POINT ITERATION METHOD
g(x1) x g(x2) x3= g(x3) x4= g(x4) x5= g(x5) x6= x7= g(x6) g(x7) g(x) y=x
31
FIXED POINT ITERATION METHOD
Example: Convergence Test: i xi 1 6.0000 2 0.8571 3 3.2308 4 1.4182 5 2.4812 6 1.7235 7 2.2030 8 1.8732 9 2.0882 10 1.9429 11 2.0388 y=x g(x)=6/(x+1)
32
FIXED POINT ITERATION METHOD
Choosing the appropriate iteration function g(x) The fixed point iteration method converges if in the neighborhood of the fixed point the derivative of g(x) has an absolute value smaller than 1. (also called Lipschitz continious) Example: The plot of the function shows that the equation has a solution between 1 and 2. The actual solution is at x= f(x)=xe0.5x+1.2x-5 x
33
FIXED POINT ITERATION METHOD
Case A Case B Case C Divergent Convergent i xi 1 1.0000 2 2.7927 3 4 4.4849 5 6 4.1667 7 8 4.1668 9 10 11 i xi 1 1.0000 2 1.7552 3 1.3869 4 1.5622 5 1.4776 6 1.5182 7 1.4987 8 1.5080 9 1.5035 10 1.5057 11 1.5046 i xi 1 1.0000 2 2.3048 3 0.7057 4 2.9183 5 0.3482 6 3.8500 7 0.0554 8 4.7986 9 10 5.2606 11
34
BISECTION METHOD STEP 1: Choose two points a and b such that a solution exists between them : f(a) f(b) < 0 STEP 2: Find c=(a+b)/2 STEP 3: Determine whether the true solution is between a and c or between c and b. Then select the subinterval that contains the true solution If f(a) f(c) < 0 , solution is between a and c anew=a, bnew=c If f(b) f(c) < 0 , solution is between c and b anew=c, bnew=b STEP 4: Repeat steps 2 and 3 until (b-a) is less than a specified tolerance
35
BISECTION METHOD f(a) f(b) f(a) f(b) < 0 True Root f(a) f(b) f(b)
c=(a+b) /2 True Root f(a) f(b) f(b) f(a) f(b) f(a)
36
BISECTION METHOD a b c f(c) abs(b-a) 5.0000 12.0000 8.5000 18.7500
7.0000 6.7500 3.5000 7.6250 7.2656 1.7500 7.1875 2.0977 0.8750 6.9688 0.4375 7.0781 0.8655 0.2188 7.0234 0.2584 0.1094 6.9961 0.0547 7.0098 0.1075 0.0273 7.0029 0.0322 0.0137 6.9995 0.0068 7.0012 0.0134 0.0034 7.0004 0.0040 0.0017
37
NEWTON RAPSON METHOD f(x1) f(x) f(x2) Exact Root x x5 x4 x3 x2 x1
Slope: f’(x1) f(x2) Exact Root Slope: f’(x2) Slope: f’(x3) x x5 x4 x3 x2 x1 Slope: f’(x4)
38
NEWTON RAPSON METHOD xi f(xi) xi -xi-1 6.00000000 31.00000000
1.3976 1.3239 1.1453 0.7849 0.3094 0.0383 0.0005
39
SECANT METHOD f(x1) f(x) f(x2) f(x3) Exact Root f(x4) f(x5) x x6 x5 x4
40
SECANT METHOD xi f(xi) xi -xi-1 6.00000000 31.00000000 5.00000000
1.0000 0.9375 0.9017 0.8062 0.6558 0.4375 0.2046 0.0517 0.0049 0.0001
41
MATLAB BUILT-IN FUNCTIONS
The roots(p) command finds the roots of a polynomial, whose coefficients are defined in the row vector p. The following MatLab script find the roots of the polynom P(x)=x3-3x2-13x+15 >> coef=[ ]; >> xi=roots(coef) xi = 5.0000 1.0000 The fzero(‘function’,x0) command finds the roots of the ‘function’ near x0. The following MatLab script find the roots of the function f(x)=x3-3x2-13x+15 >> x=fzero('x^3-3*x^2-13*x+15',7) x = 5 >> x=fzero('x^3-3*x^2-13*x+15',3) x = 1
42
SYSTEMS OF LINEAR EQUATIONS
Gauss Elimination Method Gauss-Jordan Elimination Method LU Decomposition Method
43
GAUSS ELIMINATION METHOD
Backward Substitution :
44
LU DECOMPOSITION METHOD
A is the coefficients matrix. U is an upper triangular matrix and is obtained at the end of the Gauss elimination procedure. L is a lower triangular matrix which has all 1’s on the diagonal and the elements below the diagonal are the multipliers mij that multiply the pivot equation when it is used to eliminate the elements below the pivot coefficient at the Gauss elimination procedure. L is a lower triangular matrix and y is obtained from Ly=b using forward substitution. U is an upper triangular matrix and x is obtained from Ux=y using backward substitution.
45
LU DECOMPOSITION METHOD
Forward Substitution : Backward Substitution :
46
GAUSS-JORDAN ELIMINATION METHOD
47
GAUSS-JORDAN ELIMINATION METHOD
48
GAUSS-JORDAN ELIMINATION METHOD
MATLAB SCRIPT A=[ ; ; ]; [n,col]=size(A); % for i=1:n A(i,:)=A(i,:)/A(i,i); disp('A ='); disp(A); pause; for k=i+1:n dd=A(k,i); A(k,:)=A(k,:)-dd*A(i,:); A pause; end for i=n:-1:2 for k=i-1:-1:1 x=A(:,col); disp(' The unknowns are :'); disp(x); rref(A) % MatLab built-in function
49
TAYLOR SERIES Taylor Series : Maclaurin Series : Example :
50
TAYLOR SERIES
51
NUMERICAL DIFFERENTIATION
Two-Point Forward Difference Method Two-Point Backward Difference Method Two-Point Central Difference Method Three-Point Forward Difference Method Three-Point Backward Difference Method
52
NUMERICAL DIFFERENTIATION
xi xi+1 f(xi) h f(xi+1) True derivative Approximated f(x) True derivative xi xi-1 f(xi) h f(xi-1) True derivative Approximated f(x) Forward Difference Backward Difference Forward Difference: xi+1 xi-1 f(xi+1) 2h f(xi-1) Approximated derivative f(x) Central Difference Backward Difference: Central Difference:
53
NUMERICAL DIFFERENTIATION
Truncation Error: 2 Point Forward Difference: 2 Point Backward Difference: 2 Point Central Difference: 3 Point Forward Difference: 3 Point Backward Difference:
54
NUMERICAL DIFFERENTIATION
Example : For f(x)=ln(x) estimate the value of f’(0.2) taking h=0.01. xi-2 0.18 xi-1 0.19 xi 0.2 xi+1 0.21 xi+2 0.22 f(xi-2) ln(0.18) f(xi-1) ln(0.19) f(xi) ln(0.2) f(xi+1) ln(0.21) f(xi+2) ln(0.22) Method Used f’(0.2) Abs. Error 2 Point Forward Difference 4.879 0.121 2 Point Backward Difference 5.1293 0.1293 2 Point Central Difference 5.0042 0.0042 3 Point Forward Difference 4.9925 0.0075 3 Point Backward Difference 4.9906 0.0094
55
NUMERICAL DIFFERENTIATION
h f’(0.8) Abs. Error 0.7500 0.8819 0.3681 0.5000 0.9710 0.2790 0.4000 1.0137 0.2363 0.3000 1.0615 0.1885 0.2000 1.1157 0.1343 0.1000 1.1778 0.0722 0.0500 1.2125 0.0375 0.0100 1.2423 0.0077 0.0050 1.2461 0.0039 0.0010 1.2492 0.0008 0.0005 1.2496 0.0004 0.0001 1.2499 h f’(0.8) Abs. Error 0.7500 3.6968 2.4468 0.5000 1.9617 0.7117 0.4000 1.7329 0.4829 0.3000 1.5667 0.3167 0.2000 1.4384 0.1884 0.1000 1.3353 0.0853 0.0500 1.2908 0.0408 0.0100 1.2579 0.0079 0.0050 1.2539 0.0039 0.0010 1.2508 0.0008 0.0005 1.2504 0.0004 0.0001 1.2501 2 Point Forward Difference: 2 Point Backward Difference: h f’(0.8) Abs. Error 0.7500 2.2893 1.0393 0.5000 1.4663 0.2163 0.4000 1.3733 0.1233 0.3000 1.3141 0.0641 0.2000 1.2771 0.0271 0.1000 1.2566 0.0066 0.0500 1.2516 0.0016 0.0100 1.2501 6.51e-005 0.0050 1.2500 1.63e-005 0.0010 6.51e-007 0.0005 1.63e-007 0.0001 6.51e-009 h f’(0.8) Abs. Error 0.7500 1.0597 0.1903 0.5000 1.1311 0.1189 0.4000 1.1609 0.0891 0.3000 1.1903 0.0597 0.2000 1.2178 0.0322 0.1000 1.2399 0.0101 0.0500 1.2472 0.0028 0.0100 1.2499 0.0001 0.0050 3.21e-005 0.0010 1.298e-006 0.0005 3.25e-007 1.30e-008 2 Point Central Difference: 3 Point Forward Difference:
56
NUMERICAL DIFFERENTIATION
57
NUMERICAL DIFFERENTIATION
h f’(1.5) Abs. Error 1.0000 0.8000 0.2000 0.5000 0.1000 0.9000 0.0500 0.9500 0.0100 0.9900 0.0050 0.9950 0.0010 0.9990
58
NUMERICAL INTEGRATION
Rectangle Methods Midpoint Method Trapezoidal Method Simpsons Methods Simpsons 1/3 Method Simpsons 3/8 Method
59
NUMERICAL INTEGRATION
1. Rectangle Method a f(a) b f(b) f(x) a f(a) b f(b) f(x) 2. Rectangle Method Midpoint Method Trapezoidal Method a f(a) b f(b) f(x) a f(a) b f(b) f(x)
60
NUMERICAL INTEGRATION
1. Rectangle Method f(x) f(x2) f(x1) I1 I2 I3 Ii Ii+1 IN-1 IN h h h h h h h x1 a x2 x3 xi xi+1 xN-1 xN xN+1 b
61
NUMERICAL INTEGRATION
2. Rectangle Method x1 a x2 xi xi+1 xN-1 xN xN+1 b x3 f(x1) I1 I2 I3 Ii Ii+1 IN-1 IN h f(x2) f(x)
62
NUMERICAL INTEGRATION
Midpoint Method x1 a x2 xi xi+1 xN-1 xN xN+1 b x3 I1 I2 I3 Ii Ii+1 IN-1 IN h f(x) (x1+x2) 2 (x2+x3) 2
63
NUMERICAL INTEGRATION
Trapezoidal Method x1 a x2 xi xi+1 xN-1 xN xN+1 b x3 f(x1) I1 I2 I3 Ii Ii+1 IN-1 IN h f(x2) f(x)
64
NUMERICAL INTEGRATION
Simpson 1/3 Method A second order polynomial g(x) is used to approximate the integrand f(x) f(x) g(x) f(x1) h/2=k h/2=k x1 a x2 x3 b
65
NUMERICAL INTEGRATION
Simpson 3/8 Method A third order polynomial g(x) is used to approximate the integrand f(x) f(x) g(x) f(x1) h/3=k h/3=k h/3=k x1 a x2 x3 x4 b
66
NUMERICAL INTEGRATION
67
NUMERICAL INTEGRATION
1. Rectangular Method h Num Int. Abs. Error Rel. Error % 5 1115 325 22.569 2.5 1277.5 162.5 11.285 2 1310 130 9.0278 1 1375 65 4.5139 0.5 1407.5 32.5 2.2569 0.1 1433.5 6.5 0.05 1436.8 3.25 0.01 1439.3 0.65 0.005 1439.7 0.325 0.001 1439.9 0.065 0.0005 1440 0.0325 0.0001 0.0065 2. Rectangular Method h Num Int. Abs. Error Rel. Error % 5 1765 325 22.569 2.5 1602.5 162.5 11.285 2 1570 130 9.0278 1 1505 65 4.5139 0.5 1472.5 32.5 2.2569 0.1 1446.5 6.5 0.05 1443.3 3.25 0.01 1440.6 0.65 0.005 1440.3 0.325 0.001 1440.1 0.065 0.0005 1440 0.0325 0.0001 0.0065
68
NUMERICAL INTEGRATION
1. Rect. Method 2. Rect. Method h Num Int. Abs. Error 8 400 10.667 720 330.67 4 352 37.333 512 122.67 2 360 29.333 440 50.667 1 372 17.333 412 22.667 0.5 380 9.3333 0.1 387.36 1.9733 391.36 2.0267 0.05 388.34 390.34 1.0067 0.01 389.13 389.53 0.005 389.23 389.43 0.001 389.31 389.35 0.0005 389.32 389.34 0.0001 389.33 0.002 Midpoint Method h Num Int. Abs. Error 8 304 85.333 4 368 21.333 2 384 5.3333 1 388 1.3333 0.5 389 0.1 389.32 0.05 389.33 0.01 0.005 3.3333e-005 0.001 1.3333e-006 0.0005 3.3333e-007 0.0001 1.3332e-008 Trapezoidal Method h Num Int. Abs. Error 8 560 170.67 4 432 42.667 2 400 10.667 1 392 2.6667 0.5 390 0.1 389.36 0.05 389.34 0.01 389.33 0.005 6.6667e-005 0.001 2.6667e-006 0.0005 6.6667e-007 0.0001 2.6663e-008
69
NUMERICAL INTEGRATION
(h=0.1) Numerical Integration Absolute Error 1. Rectangle Method 387.36 1.9733 2. Rectangle Method 391.36 2.0267 Midpoint Method 389.32 Trapezoidal Method 389.36 Simpsons 1/3 Method 389.33 5.6843e-014 Simpsons 3/8 Method
70
CURVE FITTING WITH A LINEAR FUNCTION
f(x)=a1x+a0 (xi ,yi) yi rN yN ri (xN ,yN) (x1 ,y1) y1 r1 r2 y2 (x2 ,y2) x1 x2 xi xN A linear function f(x)=a1x+a0 is used to best fit the given data points (xi ,yi). A residual ri at point (xi , yi) is the difference between the value yi of the data point and the value of the function f(xi) used to approximate the data points : ri= yi -f(xi)
71
CURVE FITTING WITH A LINEAR FUNCTION
The overall error E is defined as the sum of the squares of the residuals : Linear least-squares regression : The coefficients a1 and a0 of the linear function f(x)=a1x+a0 are determined such that the error E has the smallest possible value. E is minimum if: The coefficients a1 and a0 are found as:
72
CURVE FITTING WITH A LINEAR FUNCTION
Example : Use linear least-squares regression to determine the coefficients a1 and a0 in the function f(x)=a1x+a0 that best fits the data given below. x 1 2 3 4 5 6 7 8 9 10 y 9.2 13 14.7 19.7 21.8 22.8 29.1 30.2 32.2
73
CURVE FITTING WITH A LINEAR FUNCTION
yi f(xi) ri= yi -f(xi) (ri)2 6.0000 6.5145 0.2648 9.2000 9.4824 0.0798 0.5497 0.3022 0.5158 1.3139 1.7264 0.4461 0.1990 2.3159 1.8103 3.2772 0.0033 1.0516 E= 9.736 f(x)=2.9679x +
74
CURVE FITTING WITH A LINEAR FUNCTION
Example : Use linear least-squares regression to determine the coefficients a1 and a0 in the function f(x)=a1x+a0 that best fits the data given below. x 2 5 6 8 9 13 15 y 7 10 11 12 14
75
CURVE FITTING WITH A LINEAR FUNCTION
f(x)=0.64x yi f(xi) ri= yi -f(xi) (ri)2 7.0000 6.9769 0.0231 0.0005 8.0000 8.8970 0.8046 9.5370 0.4630 0.2143 0.1829 0.0334 0.5428 0.2947 0.0003 0.0885 E= 1.4363 +
76
CURVE FITTING WITH A LINEAR FUNCTION
Example : Use linear least-squares regression to determine the coefficients a1 and a0 in the function f(x)=a1x+a0 that best fits the data given below. Use f(x) to determine the interpolated value n for x=4 and the extrapolated value m for x= -8. x -8 -7 -5 -1 2 4 5 6 y m 15 12 n -9
77
CURVE FITTING WITH A LINEAR FUNCTION
m f(x)=1.7786x n Interpolation : Using the data points for estimating the expexted values between the known points. Extrapolation : Using the data points for estimating the expexted values beyond the known points.
78
LAGRANGE POLYNOMIALS For n+1 data points (x0 , y0), (x1 , y1), (x2 , y2), ….. (xk , yk), ….. (xn , yn) a unique polynomial of order n can be found, which passes through these n data points. A Lagrange interpolating polynomial Pn(x) that passes through n points is defined as :
79
LAGRANGE POLYNOMIALS MATLAB SCRIPT
Example : Find the Lagrange interpolation polynomial that passes through the points : x 2 2.5 4 y 0.5 0.4 0.25 MATLAB SCRIPT x=[ ]; y=[ ]; polyfit(x,y,2)
80
LAGRANGE POLYNOMIALS x 2 2.5 4 y 0.5 0.4 0.25 The Lagrange interpolation polynomial that passes through the points :
81
LAGRANGE POLYNOMIALS Example : Find the Lagrange interpolation polynomial that passes through the points : x 1 2 y -1 7
82
LAGRANGE POLYNOMIALS x 1 2 y -1 7 The Lagrange interpolation polynomial that passes through the points :
83
LAGRANGE POLYNOMIALS Example : Find the Lagrange interpolation polynomial that passes through the points : x 1 3 4 y 15
84
LAGRANGE POLYNOMIALS x 1 3 4 y 15 The Lagrange interpolation polynomial that passes through the points :
85
LAGRANGE POLYNOMIALS Example : Find the Lagrange interpolation polynomial that passes through the points : x 3 4 5 y 8 -4 18
86
LAGRANGE POLYNOMIALS x 3 4 5 y 8 -4 18 The Lagrange interpolation polynomial that passes through the points :
87
ORDINARY DIFFERENTIAL EQUATIONS
A differential equation is an equation that contains derivatives of an unknown function. A differential equation that has one independent variable is called an ordinary differential equation (ODE). If an ODE involves only first derivatives of the dependent variable (y) with respect to the independent variable (x), it is a first – order ordinary differential equation. A first –order ODE is linear, if it is a linear function of y and dy/dx.
88
EULER’S METHOD yi+1 yi h xi xi+1 Numerical Solution Exact Solution
Slope =f(xi, yi) y(x) Numerical Solution Exact Solution
89
EULER’S METHOD Example : Use Euler’s method to solve the Ordinary Differential Equation below from x=0 to x=1 with the initial conditions x=0 and y=2. (Take h=0.2) Compute the errors in each step for the exact solution y=3ex-x-1
90
EULER’S METHOD h=0.25 h=0.1 h=0.05 h=0.2 xi yi (Euler) (Exact) Abs.
Error 2.0000 0.2500 2.5000 2.6021 0.1021 0.5000 3.1875 3.4462 0.2587 0.7500 4.1094 4.6010 0.4916 1.0000 5.3242 6.1548 0.8306 xi yi (Euler) (Exact) Abs. Error 2.0000 0.1000 2.2000 2.2155 0.0155 0.2000 2.4300 2.4642 0.0342 0.3000 2.6930 2.7496 0.0566 0.4000 2.9923 3.0755 0.0832 0.5000 3.3315 3.4462 0.1146 0.6000 3.7147 3.8664 0.1517 0.7000 4.1462 4.3413 0.1951 0.8000 4.6308 4.8766 0.2459 0.9000 5.1738 5.4788 0.3050 1.0000 5.7812 6.1548 0.3736 xi yi (Euler) (Exact) Abs. Error 2.0000 0.0500 2.1000 2.1038 0.0038 0.1000 2.2075 2.2155 0.0080 0.1500 2.3229 2.3355 0.0126 0.2000 2.4465 2.4642 0.0177 0.2500 2.5788 2.6021 0.0232 0.3000 2.7203 2.7496 0.0293 0.3500 2.8713 2.9072 0.0359 0.4000 3.0324 3.0755 0.0431 0.4500 3.2040 3.2549 0.0510 0.5000 3.3867 3.4462 0.0595 0.5500 3.5810 3.6498 0.0687 0.6000 3.7876 3.8664 0.0788 0.6500 4.0069 4.0966 0.0897 0.7000 4.2398 4.3413 0.1015 0.7500 4.4868 4.6010 0.1142 0.8000 4.7486 4.8766 0.1280 0.8500 5.0261 5.1689 0.1429 0.9000 5.3199 5.4788 0.1590 0.9500 5.6309 5.8071 0.1763 1.0000 5.9599 6.1548 0.1950 h=0.2 xi yi (Euler) (Exact) Abs. Error 2.0000 0.2000 2.4000 2.4642 0.0642 0.4000 2.9200 3.0755 0.1555 0.6000 3.5840 3.8664 0.2824 0.8000 4.4208 4.8766 0.4558 1.0000 5.4650 6.1548 0.6899
91
EULER’S METHOD
92
EULER’S METHOD Example : Use Euler’s method to solve the Ordinary Differential Equation below from x=0 to x=1.8 with the initial conditions x=0 and y=1. (Take h=0.6) Compute the errors in each step for the exact solution.
93
EULER’S METHOD h=0.6 h=0.1 h=0.3 xi yi (Euler) (Exact) Abs. Error xi
1.0000 0.6000 1.1628 0.1628 1.2000 1.2304 1.3856 0.1552 1.8000 1.0795 0.1869 0.8926 xi yi (Euler) (Exact) Abs. Error 1.0000 0.1000 1.0050 0.0050 0.2000 1.0099 1.0198 0.0099 0.3000 1.0293 1.0440 0.0147 0.4000 1.0575 1.0767 0.0192 0.5000 1.0934 1.1169 0.0235 0.6000 1.1355 1.1628 0.0272 0.7000 1.1821 1.2124 0.0303 0.8000 1.2305 1.2629 0.0323 0.9000 1.2778 1.3107 0.0329 1.3199 1.3513 0.0314 1.1000 1.3518 1.3787 0.0269 1.2000 1.3675 1.3856 0.0181 1.3000 1.3587 1.3620 0.0033 1.4000 1.3157 1.2955 0.0201 1.5000 1.2255 1.1698 0.0557 1.6000 1.0718 0.9634 0.1084 1.7000 0.8337 0.6481 0.1855 1.8000 0.4841 0.1869 0.2972 h=0.3 xi yi (Euler) (Exact) Abs. Error 1.0000 0.3000 1.0440 0.0440 0.6000 1.0819 1.1628 0.0809 0.9000 1.2118 1.3107 0.0989 1.2000 1.3203 1.3856 0.0652 1.5000 1.2773 1.1698 0.1075 1.8000 0.8395 0.1869 0.6526
94
EULER’S METHOD
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.