Sie sind auf Seite 1von 2

AME 404 F09 Final Exam: 12/9/09; 11-1 PM

1. (30 pts.) Consider a linear least-squares fit ( ) f x Ax B = + which is used to fit the
data ( , ); 1:
i i
x y i n = .
(a) Derive the analytical expressions for the constants A and B .
(b) Based on Part 1a develop an algorithm (flowchart) for a MATLAB function
[A,B]=lsline(x,y) which computes the constants for the least-squares fit.
(c) Develop a flowchart for MATLAB program ShowLSLine to fit the data
( , ); 1:
i i
x y i n = in the least square-sense of the form
1
( ) f x
Ax B
=
+
. Reduce the
problem to a linear least-squares fit and include the plot of the results.
2. (35 pts.) Equation of a cubic spline which interpolates the data ( , ); 1:
i i
x y i n = with
continuous second derivatives at all interior nodes is given by

3 3
1 1
1
1
1
( ) ( ) " ( ) "
6
" ( ) " ( )
6 6
; 1: 1
i i i i i
i
i i i i
i i i i
i i
i i
f x x x f x x f
h
y h y h
f x x f x x
h h
x x x i n
+ +
+
+
( = +

| | | |
+ +
| |
\ . \ .
s s =
(1.1)
(a) Show that the continuity of slopes at the interior nodes ; 2: 1
i
x i n = can be
written as

1 1 1 2
2 1 1
1
" 2( ) " "
6 6
( ) ( ); 1: 2
i i i i i i i
i i i i
i i
h f h h f h f
y y y y i n
h h
+ + + +
+ + +
+
+ + + =
+ =
(1.2)
(b) Using the result of Part 2a derive a system of equations for the unknown second
derivatives " ; 1:
i
f i n = for a not-a-knot spline.
(c) Develop a flowchart for MATLAB function S=MyNotAKnotSpline(x,y,z) which
evaluates the not-a-knot cubic spline at a single point z based on the nodes
( , ); 1:
i i
x y i n = . Assume the function MyGElim(A,b) is given.
3. (35 pts.) A single application of the Gauss-Legandre m-point quadrature can be
written as

1
1
1 1
( )
[ ,..., ]; [ ( ),..., ( )]
T
m
T T
m m
f d
w w f f

=
= =
}
w f
w f
(1.3)
where
k
w and ; 1:
k
k m = are the weights and abscissas, respectively.
(a) Show that the vectorized single application Gauss-Legandre (GL) m-point
rule can be written as

1
( )
1
( ) 1 1
( ) ( )
2 2 2
( ) / 2 ; [ ,..., ]; [ ( ),..., ( )]
; 1:
2 2
b
GL m
a
T T T
GL m m m
k k
b a b a b a
f x dx f d Q
Q b a w w f x f x
b a b a
x k m

+
= + ~
= = =
+
= + =
} }
w f w f (1.4)
where [ , ] a b denote the integral range.
(b) Using Eqn.(1.3) show that the composite application of GL quadrature over n
equal panels within the range [a,b] can be written as

1
1
1
( ) ( )
2 2 2
b
n
k k k k k k
k
a
b a b a b a
f x dx f d
=

+
= +

} }
(1.5)
where ( 1) ;
k k k
a a k b a = + A = +Adenotes the subintervals for each of the
integrals.
(c) Based on Part 3b develop a flowchart for a vectorized composite GL quadrature
for MATLAB function numI=VectCompQGL(fname,a,b,m,n) which evaluates
( )
b
a
f x dx
}
using a composite m-point GL rule over n panels of equal size. Assume
that the function [w,ksi]=WGL(m) is given.

Das könnte Ihnen auch gefallen