CPSC 302, Fall, 2014
Assignment 3, due Monday, September 29
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your progr
CPSC 302 Exercise 3.13 and its solution
Uri Ascher & Chen Greif
January 2014
Question
Write a Matlab program to nd all the roots of a given, twice continuously dierentiable, function
f C 2 [a, b].
Your program should rst probe the function f (x) on the gi
CPSC 302, Fall, 2015
Assignment 1, due Wednesday, September 16
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your pr
CPSC 302 Assignment 1 Solution
Uri Ascher
September 2015
Question 1
(a) Taylor series expansions for h give
h2
f (x0 ) +
2
h2
f (x0 h) = f (x0 ) hf (x0 ) + f (x0 )
2
Subtracting the 2nd expression from the rst, we obtain
f (x0 + h) =
f (x0 ) + hf (x0 )
CPSC 302, Fall, 2014
Assignment 1, due Wednesday, September 10
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your pr
CPSC 302 Assignment 2 Solution
Uri Ascher
September 2015
Question 1
(a) In the base = 13, we have 12 = 0/130 + (12)/131 + 0. In normalized repre13
12
sentation we write this as 13 = [(12)/130 ] 131 . Thus, set d0 = 12 (this is one
digit in base 13), and a
CPSC 302 Assignment 4 Solution
Uri Ascher
October 2014
Question 1
(
)
(
)
a b
d b
1
1
(a) The inverse of a 2 2 matrix B =
is B = adbe
. Here the
e d
e a
inverse of the rotation matrix G is directly veried to be
(
)
1
c s
1
G = 2
= GT .
c + s2 s c
Hence G
CPSC 302, Fall Term, 2014
Assignment 4, due Wednesday, October 8
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your
CPSC 302 Assignment 3 Solution
Uri Ascher
October 2014
Question 1
(a) We have x = g(x ) and xk+1 = g(xk ). Let the error be en = xn x for any n. Then
1 00 2
3
0
ek+1 = g(xk ) g(x ) = g(x ) + g (x )ek + g (x )ek + O(ek ) g(x ).
2
So, if the first two deri
CPSC 302 Assignment 7 Solution
Uri Ascher
November 2015
Question 1
(a) Equating the determinant of A I to 0 we get
(1 )3 3a2 (1 ) + 2a3 = 0.
Let us set = 1. We have to show that the roots of the polynomial equation
() = 3 3a2 + 2a3 = 0
are 1 = 2a and 2 =
CPSC 302, Fall, 2015
Assignment 6, due Monday, November 9
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your program
CPSC 302, Fall, 2014
Assignment 2, due Wednesday, September 17
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your pr
CPSC 302, Fall, 2015
Assignment 2, due Wednesday, September 23
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your pr
CPSC 302, Fall, 2015
Assignment 7, due Friday, November 27
Note: this is our last assignment. It is longer and more involved than the previous
ones. Its grade will correspondingly weigh double.
Please show all your work: provide a hardcopy of the entire a
CPSC 302 Assignment 6 Solution
Uri Ascher
November 2015
Question 1
(a) The script
x = 0:.1:1.3;
y = [0.95,1.01,1.05,0.97,0.0,-0.1,0.02,-0.1,0.01,-0.15,0.72,0.79,0.91,1.0];
plot (x,y,o)
gives the data in blue circles in the left plot of Figure 1. Based on
CPSC 302 Assignment 4 Solution
Uri Ascher
October 2015
Question 1
For the constant vector, ui = , i = 1, 2, . . . , n, with = 0 some nonzero constant,
we obviously have that v is a vector of n 1 zeros. But the 2-norm of the zero vector
is zero, hence g(u)
CPSC 302 Assignment 5 Solution
Uri Ascher
October 2015
Question 1
The matrix A is given by
1 2 3
A = 4 5 6 .
7 8 10
(a) We have
M (1)
1 0 0
= 4 1 0
7 0 1
1 2
3
M (1) A = 0 3 6 .
0 6 11
Next, we have
M (2)
1 0 0
= 0 1 0 ,
0 2 1
and hence
1 0 0
L = 4 1 0 ;
CS 302
Term I, 2015-2016
3. Nonlinear equations in one variable
Uri M. Ascher
Department of Computer Science
The University of British Columbia
[email protected]
https:/www.cs.ubc.ca/cs302/302/
Goals of this chapter
Outline
1. Goals of this chapter
2. Nonl
CS 302
Term I, 2015-2016
7. Linear systems: Iterative methods
Uri M. Ascher
Department of Computer Science
The University of British Columbia
[email protected]
https:/www.cs.ubc.ca/cs302/302/
Goals and motivation
Outline
1. Goals and motivation
Goals of th
.
.
Chapter 1: Numerical Algorithms
Uri Ascher
UBC Computer Science
Department of Computer Science
University of British Columbia
[email protected]
http:/www.cs.ubc.ca/cs302/302/index.html
Uri Ascher (UBC Computer Science)
CS302
Fall 2015
1 / 19
Numerical
CPSC 302, Fall, 2014
Assignment 8, due Monday, November 24
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your progra
CPSC 302 Assignment 8 Solution
Uri Ascher
November 2014
Question 1
Note that n = 40 here replaces n = 32 in Examples 8.2 and 8.4 in the text.
(a) function lam=PowerMethod(A,tol);
[n n]=size(A);
x=randn(n,1);
x=x/norm(x);
lam0=x*A*x;
% random initial guess
CPSC 302 Assignment 7 Solution
Uri Ascher
November 2014
Question 1
(a) It is not dicult to show that the eigenvalues of A are 1 + 2a, 1 a
and 1 a. Therefore, A is symmetric positive denite if and only if
1 < a < 1. On the other hand, the Jacobi iteration
CPSC 302 Assignment 6 Solution
Uri Ascher
October 2014
Question 1
(a) The script
x = 0:.1:1.3;
y = [0.95,1.01,1.05,0.97,1.0,-0.1,0.02,-0.1,0.01,0.6,0.72,0.79,0.91,1.0];
plot (x,y,o)
gives the data in blue circles in the top plot of Figure 1. Based on this
CPSC 302, Fall, 2014
Assignment 7, due Friday, November 14
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your progra
CPSC 302, Fall, 2014
Assignment 6, due Friday, October 31
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your program
CPSC 302 Assignment 5 Solution
Uri Ascher
October 2014
Question 1
Here is my Matlab function:
function x = trid (md,ld,ud,b)
%
% Solve Ax = b for a tridiagonal A
% md = diagonal vecotor of A (length n)
% ld = lower diagonal of A (length (n-1)
% ud = upper
CPSC 302, Fall, 2014
Assignment 5, due Friday, October 24
Please show all your work: provide a hardcopy of the entire assignment (including
plots and programs); in addition, e-mail your Matlab programs to [email protected]
When e-mailing your program
CPSC 302 Assignment 2 Solution
Uri Ascher
September 2014
Question 1
(a) In the base = 7, with t 2, we have 8 = 1/70 + 1/71 = 1.1 70 . Thus, d0 = 1, d1 = 1,
7
and all other digits are zero, with the exponent e = 0.
(b) A rational number can be written as p
CS 302
Term I, 2015-2016
5. Linear systems: Direct methods
Uri M. Ascher
Department of Computer Science
The University of British Columbia
[email protected]
https:/www.cs.ubc.ca/cs302/302/
Goals of this chapter
Outline
1. Goals of this chapter
2. Gaussian