function [ L, U, f ] = LUFactorization( A, f, n )
% LU Factorization Partial Pivoting
p = (1:n)';
P = zeros(n);
for k=1:n-1
[r,m] = max(abs(A(k:n,k);
m = m+k-1;
if (m~=k)
A([k m],:) = A([m k],:);
p([k m]) = p([m k]);
end
for i=k+1:n
A(i,k) = A(i,k)/A(k,k)
% HW06 - 5a
% Trapezoidal Approximation
j
x
n
h
f
=
=
=
=
=
0:1:10;
-1+2*j/10;
size(x,2);
2/10;
1./(1+25*x.^2);
T = 0;
for i = 1:length(x)-1
T = T + 0.5*h*(f(i) + f(i+1);
end
T
function [ c, s ] = rotate2x2_cs( a1, a2 )
% rotate2x2() finds the rotation of an n=2 array of the form:
% b = Qa = [ c s]*[a1] = [norm(a)]
%
[-s c] [a2]
[
0
]
% rotate2x2_cs() iteration of rotate2x2() that outputs the c and s values
% of the rotation mat
% HW06 - 5a
% Spline Approximation
nodes = 200; %precision
j
x
n
h
f
=
=
=
=
=
0:1:10;
-1+2*j/10;
size(x,2);
2/10;
1./(1+25*x.^2);
%
%
%
%
Interpolation nodes
Number of nodes
Interval width
F(x) at nodes
g = zeros(n-1,1);
for i = 2:n-1
g(i) = (f(i+1)-2*f(