Homework Set No. 10
1. Linear Shooting Method for a two-point boundary value problem
Consider the dierential equation
y = y + 2y + cos(x),
with boundary conditions
y ( ) = 0.1.
y (0) = 0.3,
Note that the exact solution is given as
y (x) = (sin(x)
Polynomial interpolation: simplest version
> X = [1,0,0;1,1,1;1,2/3,4/9]
% van der Monde matrix
> y = [1;0;1/2]
> a = X\y
SCE/MATH 451, Numerical Compu
Taylor series methods
x = x + et ,
x(0) = 0
Exact solution: x(t) = tet .
SCE/MATH 451, Numerical Computations
Taylor series methods
x = x
Systems of linear equations
Our Matlab function for naive Gaussian
elimination looks like this:
function x = naiv_gauss(A,b);
n = length(b); x = zeros(n,1);
for k=1:n-1 % forward elimination
xmult = A(i,k)/A(k,k);
A(i,j) = A(i,j)-x
Natural cubic spline
Computing zi :
function z = cspline(t,y)
n = length(t);
z = zeros(n,1);
h = zeros(n-1,1);
b = zeros(n-1,1);
u = zeros(n,1);
v = zeros(n,1);
h = t(2:n)-t(1:n-1);
b = (y(2:n)-y(1:n-1)./h;
u(2) = 2*(h(1)+h(2);
v(2) = 6*(b(2)-b(1);
Next example shows three dierent ways of
computing an inner product of two vectors.
zi = xi yi ,
i = 1, 2, . . . , n
Do not allocate memory space for z in advance.
Compute the elements in the new vector by a
x = ran
Homework Set No. 9
1. Scalar ODE
Consider the following ordinary dierential equation:
x = 2x2 + x 1,
x(1) = 1.
(a) Write out the Eulers method for this ODE. Compute the value x(1.2) by Eulers
method, with h = 0.1.
(b) Write out the Heuns method for this O
MATLAB is an advanced program package tool
for numerical computation og visualization.
easy to use and program.
can be run interactively or from a le.
2- and 3-dimensional plot.
many built-in numerical functions.
can be developed w
Homework Set No. 8
1. Simplest problem using least squares method
Use the method of least squares, nd the constant function that best ts the data
2. The method of least squares with polynomial regression
(a) What straight line best
Homework Set No. 7
1. Various methods
The linear system
4 x1 + 3 x2
3 x1 + 4 x2
x2 + 4 x3 = 24
should be solved by the following methods (do not use Matlab for this problem)
a) Gaussian elimination (tridiagonal system).
b) Jacobis method.
Homework Set No. 2
NB! If a problem is not specied to use Matlab, then you should not use Matlab.
Preparation for Matlab home works: Read chapter 3 in the notes of Gockenbach.
(a). The Taylor series for (1 + x)n is also known as the binomial s
Homework Set No. 4
The problems will be graded selectively.
NB! Problems marked with (*) are more challenging, extra points will be awarded for
them. For that reason, no hints will be given for those problems before the due date.
1. Trapezoid and Simpsons
Homework Set No. 3
Determine whether this function is a rst-degree spline:
1 x 0.5
S (x) =
0.5 + 2(x 0.5)
0.5 x 2
x + 1.5
Show that f (x) p(x) = 2 f ( )(x a)(x b) for some in the interval (a, b), where p
is a linear polynom
Homework Set No. 5, Numerical Computation
1. Bisection method
We consider the bisection method to nd a root for f (x) = 0. If f (0) < 0 and f (1) > 0,
then there is a root on the interval [0, 1], and we take [0, 1] as the initial interval. How