Download presentation
Presentation is loading. Please wait.
Published byWillis Bruce Modified over 9 years ago
1
數值方法 2008, Applied Mathematics NDHU 1 Numerical Differentiation
2
數值方法 2008, Applied Mathematics NDHU 2 Composite Simpson rule h=(b-a)/2n Simpson's Rule for Numerical Integration
3
數值方法 2008, Applied Mathematics NDHU 3 A procedure for CSR ► function Q=CSR(fs,a,b,n) ► fx=inline(fs); ► h=(b-a)/(2*n); ► ind=0:1:2*n; ► Q=fx(a)+fx(b); ► % Red ► ind_odd=1:2:(2*n-1); ► % white ► ind_even=2:2:2*(n-1); ► Q=Q+sum(4*fx(a+ind_odd*h)); ► Q=Q+sum(2*fx(a+ind_even*h)); ► Q=Q/3*h;
4
數值方法 2008, Applied Mathematics NDHU 4 Symbolic Differentiation demo_diff.m
5
數值方法 2008, Applied Mathematics NDHU 5 Example function of x:tanh(x) fx1 = Inline function: fx1(x) = 1-tanh(x).^2
6
數值方法 2008, Applied Mathematics NDHU 6 Numerical differentiation
7
數值方法 2008, Applied Mathematics NDHU 7 Truncation error The truncation error linearly depends on h
8
數值方法 2008, Applied Mathematics NDHU 8 Better approximation
9
數值方法 2008, Applied Mathematics NDHU 9 Truncation error O(h 2 ) : big order of h square The truncation error linearly depends on h 2
10
數值方法 2008, Applied Mathematics NDHU 10 Richardson extrapolation Richardson extrapolation is with O(h 3 ) Start at the formula that is with O(h 2 ) Strategy: elimination of h 2 term
11
數值方法 2008, Applied Mathematics NDHU 11 Halving step-size
12
數值方法 2008, Applied Mathematics NDHU 12 Richardson extrapolation
13
數值方法 2008, Applied Mathematics NDHU 13 Richardson extrapolation
14
數值方法 2008, Applied Mathematics NDHU 14 Demo_Richardson demo_Richardson.m
15
數值方法 2008, Applied Mathematics NDHU 15 Example >>demo_Richardson function of x:sin(x) fx1 = Inline function: fx1(x) = cos(x) h:0.01
16
數值方法 2008, Applied Mathematics NDHU 16 Example: differentiation of sin [-5 5] h=0.01
17
數值方法 2008, Applied Mathematics NDHU 17 Exercise Due to 12/26 ► Implement the Richardson extrapolation method for numerical differentiation ► Give two examples to verify your matlab functions for Richardson extrapolation implementation
18
數值方法 2008, Applied Mathematics NDHU 18 Line fitting
19
數值方法 2008, Applied Mathematics NDHU 19 Problem statement ► S={(u i v i )} i ► Find a line to fit a set of 2D points,
20
數值方法 2008, Applied Mathematics NDHU 20 Paired data m=100; u=rand(1,m); v=1.5*u+2+rand(1,m)*0.1-0.05; plot(u,v,'.')
21
數值方法 2008, Applied Mathematics NDHU 21 Linear model
22
數值方法 2008, Applied Mathematics NDHU 22 Over-determined Linear system
23
數值方法 2008, Applied Mathematics NDHU 23 Form A and b A=[u' ones(100,1)]; b=v';
24
數值方法 2008, Applied Mathematics NDHU 24 Line fitting >> x=inv(A'*A)*A'*b x = 1.4816 2.0113
25
數值方法 2008, Applied Mathematics NDHU 25 Demo_line_fitting demo_line_fitting.m
26
數值方法 2008, Applied Mathematics NDHU 26 Stand alone executable file mcc -m demo_line_fitting.m
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.