{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Solution5 - ChE 132B HW5 Solutions 100pt Problem...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
ChE 132B HW5 Solutions 100pt Problem 1. (5pt) %HW5 #1 x0=-1;x1=1;x2=2; [email protected](x) (x-x1).*(x-x2)./((x0-x1).*(x0-x2)); [email protected](x) (x-x0).*(x-x2)./((x1-x0).*(x1-x2)); [email protected](x) (x-x0).*(x-x1)./((x2-x0).*(x2-x1)); x=-1:0.1:2; plot(x,L0(x),x,L1(x),x,L2(x)) legend( 'L0' , 'L1' , 'L2' ) xlabel( 'x' ) ylabel( 'y' ) title( 'HW5 #1' )
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Problem 2. (5pt) For N=2, the Chebyshev points are : 𝑥 0 = 1, 𝑥 1 = 0, 𝑥 2 = 1 (1) The Chebyshev polynomials are : 𝑇 0 = 1, 𝑇 1 = 𝑥 , 𝑇 2 = 2 𝑥 2 1 (2) Plug Eq.(2) into 𝑦 𝑁 = 𝑐 𝑖 𝑇 𝑖 ( 𝑥 ) 𝑁 𝑖=0 , 𝑦 = 𝑐 0 + 𝑐 1 𝑥 + 𝑐 2 (2 𝑥 2 1) (3) At x 0 , x 1 , and x 2 , the values of y(x) are : 𝑦 ( 𝑥 0 ) = 𝑦 0 = 𝑐 0 + 𝑐 1 + 𝑐 2 𝑦 ( 𝑥 1 ) = 𝑦 1 = 𝑐 0 − 𝑐 2 𝑦 ( 𝑥 2 ) = 𝑦 2 = 𝑐 0 − 𝑐 1 + 𝑐 2 (4) Solve the above system of equation with respect to the Chebyshev polynomial coefficients, 𝑐 0 = 𝑦 0 4 + 𝑦 1 2 + 𝑦 2 4 𝑐 1 = 𝑦 0 − 𝑦 2 2 𝑐 2 = 𝑦 0 − 𝑦 1 2 𝑦 0 − 𝑦 2 4 (5) Differentiate Eq.(3) and plug the Chebyshev polynomial coefficients into it, 𝑦 = 𝑐 1 + 4 𝑐 2 𝑥 (6) 𝑦 = 𝑦 0 2 𝑦 2 2 + �𝑦 0 2 𝑦 1 + 𝑦 2 4 � 𝑥 (7) At x 0 ,x 1 , and x 2 , the values of y’(x) are : 𝑦 ( 𝑥 0 ) = 3 2 𝑦 0 2 𝑦 1 + 𝑦 2 2 𝑦 ( 𝑥 1 ) = 𝑦 0 2 𝑦 2 2 𝑦 ( 𝑥 2 ) = 𝑦 0 2 + 2 𝑦 1 3 2 𝑦 2 (8)
Background image of page 2
In matrix form, 𝑦 0 𝑦 1 𝑦 2 = 3 2 2 1 2 1 2 0 1 2 1 2 2 3 2 𝑦 0 𝑦 1 𝑦 2 (9) Finally, the Chebyshev differentiation matrix for N=2 is : 𝐷 2 = 3 2 2 1 2 1 2 0 1 2 1 2 2 3 2 (10) Eq.(10) is confirmed using chebD.m >> chebD(2) ans = 1.5000 -2.0000 0.5000 0.5000 0 -0.5000 -0.5000 2.0000 -1.5000
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Problem 3. (20pt) % HW5 3.a (5pt) n=16; xfine = 0:.005:1; clf % a fine grid x = (0:n)/n; % x data values, equally spaced y = sin(2.*x).*cos(5.*x); % y values of data yfine = sin(2.*xfine).*cos(5.*xfine); % "exact" function on fine grid yfit = interp1(x,y,xfine, 'spline' ); plot(x,y, '.' , 'markersize' ,13) line(xfine,yfit) axis([0 1 -1 1]), title( 'HW5 #3.(a)' ) xlabel( 'x'
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}