How to program functions.
How do the built-in functions sqrt and diff
work?
What is the .^ operator?
Can a function return more than one array ?
Readings: Matlab by Gilat Chapter 6 (except 6.3)
3-2
1. Problem Definition
Write a function named trunc that t
CS 357
Numerical Methods - Homework 11
December 9, 2011
1. [25pt] Let be an eigenvalue of the n n matrix A and x = 0 be an associated eigenvector.
(a) Show that for any integer k 1, k is an eigenvalue of Ak with eigenvector x.
(b) Show that if A1 exists,
CS 357
Numerical Methods - Homework 10
November 10, 2011
1. [20pt] Derive the formulas for numerical dierentiation as well as the corresponding truncation errors for the
following cases:
(a) Approximation of f (x) using only the values f (x), f (x + h), f
Lecture 4
Rootnding: Newtons Method in higher dimensions, secant method,fractals,
Matlab - fzero
T. Gambill
Department of Computer Science
University of Illinois at Urbana-Champaign
?, 2011
T. Gambill (UIUC)
CS 357
?, 2011
1 / 43
Newtons Method in higher
Lecture 1
Introduction to Numerical Methods
T. Gambill
Department of Computer Science
University of Illinois at Urbana-Champaign
January 17, 2012
T. Gambill (UIUC)
CS 357
January 17, 2012
1 / 44
Course Info
http:/www.ews.uiuc.edu/cs357/
Book: Introduction
Lecture 13
Denite Integrals: Newton Cotes
T. Gambill
Department of Computer Science
University of Illinois at Urbana-Champaign
April 14, 2011
T. Gambill (UIUC)
CS 357
April 14, 2011
1 / 68
Theorem
The Fundamental Theorem of Calculus Given a continuous fun
CS 357
Numerical Methods - Homework 9
November 16, 2011
1. [30pt] Consider the function f (x) = x and the interpolation points (xi , f (xi ), i = 0, 1, . . . n. Let xi be
evenly spaced over the interval [1, 2], that is, xi = 1 + i h, h = 1/n. For each thr
CS 357
Numerical Methods - Homework 10
December 8, 2011
1. [20pt] Derive the formulas for numerical dierentiation as well as the corresponding truncation errors for the
following cases:
(a) Approximation of f (x) using only the values f (x), f (x + h), f
CS 357
October 16, 2011
Numerical Methods - Homework 6
1. [25pt]
(a) [15pt] Using the sparse matrix data structures CSR, COO, MSR as dened in class, store the following
matrix A using each storage method.
1
2
A = 0
0
0
0
5
0
9
0
0
0
8
0
5
0
0
3
0
3
3
6
4
CS 357
Numerical Methods - Homework 8
November 3, 2011
1. [10pt] Given the equation f (x) = 0 where f is continuous on an interval [a, b] such that the bisection method
is guaranteed to converge to a root of f , determine a formula that relates the number
CS 357
Numerical Methods - Homework 7
October 26, 2011
1. [25pt]
(a) [15pt] Show that the iterative method
xk+1 =
xk1 f (xk ) xk f (xk1 )
f (xk ) f (xk1 )
is mathematically equivalent to the secant method for solving a scalar nonlinear equation f (x) = 0.
CS 357
Numerical Methods - Homework 5
October 3, 2011
1. [30pt] Let Pij be an elementary row permutation matrix, and Ak,l (m) be an elementary row addition matrix
(as dened in class). Prove or disprove that B = Pij Ak,l (m) Pij is always a lower triangula
Lecture 7
Gaussian Elimination with Pivoting
T. Gambill
Department of Computer Science
University of Illinois at Urbana-Champaign
July 8, 2014
T. Gambill (UIUC)
CS 357
July 8, 2014
1 / 55
Naive Gaussian Elimination Algorithm
Forward Elimination
+ Backward
Lecture 6
Gaussian Elimination
T. Gambill
Department of Computer Science
University of Illinois at Urbana-Champaign
February ?, 2010
T. Gambill (UIUC)
CS 357
February ?, 2010
1 / 40
Gaussian Elimination
Solving Triangular Systems
Gaussian Elimination With
Lecture 9
Least Squares, QR and SVD
T. Gambill
Department of Computer Science
University of Illinois at Urbana-Champaign
March 15, 2011
T. Gambill (UIUC)
CS 357
March 15, 2011
1 / 22
Example 1: Finding a curve that best ts the data
Suppose we are given th
Error, Accuracy and Convergence
Error in Numerical Methods i
Every result we compute in Numerical Methods is inaccurate.
What is our model of that error?
Suppose the true answer to a given problem is x0 , and the
computed answer is x. What is the absolute
Making Models with Polynomials:
Interpolation
Reconstructing a Function From Point Values i
If we know function values at some points
f (x1 ), f (x2 ), . . . , f (xn ), can we reconstruct the function as
a polynomial?
f (x) = ? + ?x + ?x2 +
In particular
Floating Point
Wanted: Real Numbers. in a computer i
Computers can represent integers, using bits:
23 = 1 24 + 0 23 + 1 22 + 1 21 + 1 20 = (10111)2
How would we represent fractions, e.g. 23.625?
1
Fixed-Point Numbers i
Suppose we use units of 64 bits, wit
Error, Accuracy and Convergence
Error in Numerical Methods i
Every result we compute in Numerical Methods is inaccurate.
What is our model of that error?
Approximate Result = True Value + Error.
x = x0 + x.
Suppose the true answer to a given problem is x0
Making Models with Polynomials:
Taylor Series
Why polynomials? i
a3 x3 + a2 x2 + a1 x + a0
How do we write a general degree n polynomial?
Why polynomials and not something else?
1
Reconstructing a Function From Derivatives i
Given f (x0 ), f 0 (x0 ), f 00