CPE CPE 332 332 Computer Computer Engineering Engineering Mathematics Mathematics IIII Week 10 Part III, Chapter 7 Error, Transcendental Function and Power Series Today Topics
Numerical Methods Errors Transcendental Function Series Power Series Taylor Series MacLaurin Series Function Approximation HW VII QZ IV Next Week MT Exam and Cumulative Grades Numerical Methods Solution
Derivative Integrate Differential Equation Fourier Transform, Laplace Transform Z-Transform Analytical Method ( Explicit Form) Numerical Method Numerical Methods Numerical Graphical Method Interpolation Algorithm
(Error Analysis) Convergence Complexity Algorithm Y=f(x)=2x -4x -7x+5 3 2 f(k) f(0), f(-2), f(7) f(x)=k x f(x) = 0 Quadratic Equation Polynomial Degree = 1, Straight Line y = f(x) = mx+b; x = (y-b)/m Polynomial Degree = 2 y = f(x) = ax2+bx+c y = f(x) = 3 y = f(x) = ax2+bx+(c-3) = 0
x = [-b(b2-4a(c-3))]/2a Polynimial Degree = n, n > 2 , Algorithm Numerical Method Algorithm Iterative Method Numerical Method Iteration () Algorithm Converge Start Iteration = 0 Set et Iterative Technique Init. X0 [Iteration i]
Iteration += 1 Calculate xi Converge ei < ei-1 Estimate ei N Error ei < es Y Stop Errors
Algorithm Error Round-Off Error Truncation Error Errors Round-Off Error Memory Memory Integer, Long Integer, Float, Double Errors Truncation Error Algorithm
Infinite Terms Precision, Accuracy, Significant Digit Error Significant Digit Significant Digit Accuracy
Precision Precision Significant Digit Error Accuracy Precision = Accuracy = Precision = Accuracy = Precision = Accuracy = Precision = Accuracy = ccuracy Error Data Precision Variance SD Data
Significant Digits (Figures) Precision s.f. bar Examples 11.152 = 5 s.f. 0.00879 = 3 s.f. 000125600. = 6 s.f. 0123400000 = 7 s.f.
s.f. Round-Off 456.389864 (6 s.f.) = 456.390 1287563.94 (3 s.f.) = 1290000 Error Accuracy Absolute Error, Et Relative Error (%), et Estimated Error, ea Error (Relative Error) Absolute Error Relative Error
Error Estimation Convergence Divergence Mean Square Error(MSE) Error Error Mean Square Error Y Y N 1 MSE N
N1 2 ( Y Y ) i i i 0 RMSE Root Mean Square Error Square Root MSE 1 RMSE N N1
2 ( Y Y ) i i i 0 Functions Set Input Set Output Function Input Set () Mapping Map Function Inverse Function Inverse Function x
y f(.) x=f-1(y) y=f(x) Polynomial Functions Function Polynomial function Degree n (One n n 1 Argument) 2 y f ( x) an x an 1 x n n
i 0 i 1 ai x i a0 ai x i a2 x a1 x a0 Polynomial of degree 2: f(x) = x2 - x - 2 = (x+1)(x-2) Polynomial of degree 3: f(x) = x3/4 + 3x2/4 - 3x/2 - 2 = 1/4 (x+4)(x+1)(x-2) Polynomial of degree 4: f(x) = 1/14 (x+4)(x+1)(x-1)(x-3) + 0.5 Polynomial of degree 5: f(x) = 1/20 (x+4)(x+2)(x+1)(x-1)(x-3) + 2
http://en.wikipedia.org/wiki/Polynomial olynomial of degree 6: x) = 1/30 (x+3.5)(x+2)(x+1)(x-1)(x-3)(x-4) + 2 Polynomial of degree 7: f(x) = (x-3)(x-2)(x-1)(x)(x+1)(x+2)(x+3 Transcendental Function Function Algebraic Algebraic function Function Root Polynomial Transcendental Function Solution Polynomial Exponential Function Logarithm Trigonometric Functions
Function Transcendental Examples f1 ( x) x x f 2 ( x) c , c 0,1 f3 ( x) x f 4 ( x) x x 1 x f 5 ( x) log c x, c 0,1 f 6 ( x) sin x
Function Review Infinite Series Power Series Taylor Series Maclaurin Series Series Series Infinite Series Series Sequence Infinite Series Sequence an
Series a1+a2+a3+ S an a1 a2 a3 n 1 1 1 1 1 1 an n ; S n 2 2 4 8 n 1 2 NOTE: Index Summation 0 Convergence of Series Series Converge Term N Limit
S an lim S N lim n 0 N N N a n n 0 Series Converge Diverge Power Series
Power Series Infinite Series (c = Constant, an = coefficient, x Variable c) f ( x) an ( x c) n n 0 Power Series Taylor Series c=0 f ( x) an x n a0 a1 x a2 x 2 a3 x 3 n 0 Maclaurin Series Taylor Series/Maclaurin Series f(x) Function
Derivative a Taylor Series f(x) Power Series ( 3) (n) f ' (a ) f ' ' (a) f (a ) f (a) 2 3 f (a) ( x a) ( x a) ( x a ) ( x a) n 1! 2!
3! n! n 0 a = 0 Maclaurin Series f ' (0) f ' ' (0) 2 f (3) (0) 3 f ( n ) (0) n f ( x) f (0) x x x x 1! 2! 3! n! n 0
Example 1 f ' ' (a) f ( 3) ( a ) f ( 4) (a) 2 3 f ( x) f (a) f ' (a)( x a ) ( x a) ( x a) ( x a) 4 ... 2! 3! 4! f ' ' (0) 2 f (3) (0) 3 f ( 4) (0) 4 f ( x) f (0) f ' (0) x x x x .. 2! 3! 4!
Suppose f ( x) e x , f ' ( x) e x ,..., f ( n ) ( x) e x f ( n ) (0) 1 x2 x3 x4 xk We have f ( x) e 1 x ... 2! 3! 4! k 0 k! x Example find f (2) e 2 4 5 2 4 8 16 Forth Order Approximat ion : e 2 1 2 7 2 6 24 4 8 16 32
64 Sixth Order Approximat ion : e 2 1 2 7.356 2 6 24 120 720 4 8 16 32 64 128 256 Eighth Order Approximat ion : e 2 1 2 7.3873 2 6 24 120 720 5040 40320 Actual Value : e 2 7.389056099 Second Order Approximat ion : e 2 1 2 e-2 4 Significant Digit
Example 2: f ' ' ( 0) 2 f ( 3 ) ( 0) 3 f ( 4 ) ( 0) 4 f ( x) f (0) f ' (a ) x x x x .. 2! 3! 4! Suppose f ( x) sin x, f ' ( x) cos x, f ' ' ( x) sin x, f ' ' ' ( x) cos x, f ( 4) sin( x),... x3 x5 x7 ( 1) n 2 n 1
We have f ( x) sin x 0 x 0 0 0 ... x 3! 5! 7! ( 2 n 1 )! n 0 Example find f (0.5) sin 0.5 radian Second Order Approximat ion : sin 0.5 0.5 0.5 3 Forth Order Approximat ion : sin 0.5 0.5 0.47916667
3! 0.5 3 0.5 5 Sixth Order Approximat ion : sin 0.5 0.5 0.47942708 3! 5! 0.5 3 0.5 5 0.5 7 Eighth Order Approximat ion : sin 0.5 0.5 0.479425533 3! 5! 7! Actual Value : sin 0.5 0.479425538 cos 0.5 8 Significant Digit Taylor (Maclaurin) Series xn
x2 x3 x 4 e 1 x ; x n ! 2! 3! 4! n 0 x xn log( 1 x) ; 1 x 1 n 1 n log( 1 x) ( 1) n 1
n 1 xn ; 1 x 1 n 1 x n ; x 1 1 x n 0 1 x m 1 m n x ; x 1 1 x n 0 x n nx
; x 1 (1 x) 2 n 0 ( 1) n (2n)! 1 x x n 1 12 x 2 n 0 (1 2n )( n!) ( 4 n) 1 8 x 2 161 x 3 ( 1) n 2 n 1 x3 x5 sin x x x
; x 3! 5! n 0 ( 2 n 1)! ( 1) n 2 n x2 x4 cos x x 1 ; x ( 2 n )! 2 ! 4! n 0 5
128 x 4 ; x 1 MATLAB Program Function MATLAB Function Vector x Vector y return z1 z2; x=-3:.1:3; y = -3:.1:3 z1 = 2sin(x^2+y^2)/(x^2+y^2) z2 = xsiny-ycosx mesh (x,y,z1), (x,y,z2), (x,z1), (y,z2) (z1,z2) Surf function, shading modes Contour plot Function MATLAB Tutorial 4-5 END OF WEEK 10 Download HW 7 Next Week Chapter 8: Zeros of Functions
MATLAB Program function [z1,z2]=test(x,y) % function [z1,z2]=test(x,y) % Test matlab program calculate z1=f(x,y)=sin(x^2+y^2)/(x^2+y^2) % and z2=f(x,y)=xsiny-ysinx
n=length(x); m=length(y); z1=zeros(n,m); z2=zeros(n,m); for i = 1:n for j= 1:m t=x(i)^2+y(j)^2; if (t ~= 0) z1(i,j)=sin(t)/t; else z1(i,j)=1; end
z2(i,j)=x(i)*sin(y(j))-y(j)*cos(x(i)); end end MATLAB Program function view2(x,y,z,az) mesh(x,y,z); view(0,az); for i = 0:10:360 view(i,az); pause(0.05); end MATLAB Program function view3(az) view(0,az); for i = 0:10:360 view(i,az);
pause(0.05); end