Welcome to MATH 105A

Major topics covered:

  1. Basics of numerical approximations (numerical analysis)
  2. Computational linear algebra
  3. Introduction to MATLAB

The syllabus (w/tentative schedule) can be found on the main course webpage. The course materials can be found at this site or here.

This course consists of a lecture section (MWF 2-2:50pm, DBH 1500) with recitation (TuTh 2-2:50, HICF 100N) and a lab section (TuTh 5-5:50pm).

Office hours: M 3-4pm, W 3-5pm (TA hours soon)

Lab

In the lab we will work on more involved homework problems that require the translation of the mathematical ideas introduced in lecture into practical MATLAB code.

More detail was given in the lab, but the grade will be based on:

  1. Weekly homework problems
  2. Final project

Lecture

The lecture for this course is largely theoretical but due to the direct connection with MATLAB, I will try to illustrate the ideas presented in lecture with concrete coded examples.

Homework will be assigned each week (on Friday) and will NOT be collected. Homework is there to develop your understanding and it is expected that you will complete all of it (and more!).

Grades for the course are based on:

  1. 7 Quizzes (weekly on Thursdays in discussion, 25%)
  2. Midterm Exam (Oct. 28, 25%)
  3. Final Exam (Dec. 8, 50%)

A review of calculus

Limits and continuity

Definition

A function $~f$ defined on a set $~X$ has limit $~L$ at $~x_0$

$$ \lim_{x\to x_0} f(x) = L $$

if, given any real number $\epsilon > 0$, there exists a real number $~\delta > 0$ such that

$$ |f(x) - L| < \epsilon, ~~ \text{ whenever } ~~ x \in X ~~ \text{ and } ~~ 0 < |x - x_0| < \delta. $$

Given any real number $\epsilon > 0$, there exists a real number $~\delta > 0$ such that

$$ |f(x) - L| < \epsilon, ~~ \text{ whenever } ~~ x \in X ~~ \text{ and } ~~ 0 < |x - x_0| < \delta. $$

If $f(x) = \sin (x)$ and we are given $\epsilon = 10^{-5}$, let's test to see what $\delta$ should be:

In [1]:
f = @(x) sin(x);
epsilon = .00001;
x0 = 0;
x = 0.00001;

format long %display more digits
abs(f(x)-f(0))
abs(f(x)-f(0)) < epsilon %returns 0 for false, and 1 for true
ans =

     9.999999999833334e-06


ans =

     1

Definition

Let $f$ be a function defined on a set $X$ of real numbers and $x_0 \in X$. Then $f$ is continuous at $x_0$ if

$$ \lim_{x \to x_0} f(x) = f(x_0) $$



The set of all continuous functions defined on the set $X$ is denoted by $C(X)$ ($C[a,b]$ or $C(a,b]$ if $X$ is an interval).

The function $f(x) = |x|$ is continuous everywhere but the following function is not

$$ g(x) = \begin{cases} -1, & x < 0,\\ 1 & x \geq 0. \end{cases} $$
In [37]:
x = linspace(-1,1,100);
y1 = abs(x);  % evaluate f(x)
y2 = sign(x); % evlauate g(x)
plot(x,y1,'r') % plotted in red
hold on % don't erase the plot for the next plot command
plot(x,y2,'k') % plotted in black
xlabel('x'); ylabel('f(x) and g(x)') %label axes

Definition

Let $\{x_n\}_{n=1}^\infty$ be an infinite sequence of real numbers. The sequence has a limit $x$ (converges to $x$) if for any $\epsilon > 0$ there exists a positive integer $N(\epsilon)$ such that $|x_n-x| < \epsilon$ whenever $n \geq N(\epsilon)$. In this case, we write

$$ \lim_{n \to \infty} x_n = x, \quad \text{or} \quad x_n \to x ~~ \text{as} ~~ n \to \infty. $$



Theorem

If $f$ is defined on a set $X$ of real numbers and $x_0 \in X$, then the following are equivalent

  1. $f$ is continuous at $x_0$
  2. If $\{x_n\}_{n=1}^\infty$ is any sequence that converges to $x$ then $\lim_{n \to \infty} f(x_n) = f(x)$.

The function

$$ f(x) = \begin{cases} \cos(\pi/x), & x \neq 0,\\ 1 & x = 0, \end{cases} $$

is not continuous at $x = 0$. To show this, let $x_n = 1/n$. If $f$ is continuous then $\lim_{n \to \infty} f(1/n) = 1$

In [38]:
f = @(x) cos(pi./x);
ns = linspace(1,100,100);
plot(ns,f(1./ns))
xlabel('n'); ylabel('f(1/n)') %label axes

The function

$$ f(x) = \begin{cases} x\cos(\pi/x), & x \neq 0,\\ 1 & x = 0, \end{cases} $$

is continuous at $x = 0$. To see this, again, let $x_n = 1/n$. (Note: taking one sequence does not prove continuity)

In [36]:
f = @(x) x.*cos(pi./x);
ns = linspace(1,100,100);
plot(ns,f(1./ns))
xlabel('n'); ylabel('f(1/n)') %label axes

Theorem (Intermediate Value Theorem)

Let $f \in C[a,b]$. Assume $f(a) \neq f(b)$. For every real number $y$, $f(a) \leq y \leq f(b)$, there exists $c \in [a,b]$ such that $f(c) = y$.

In [65]:
x = linspace(-3,3,100);
f = @(x) sin(x);
c = @(x) 0*x+.1;
plot(x,f(x),'k')
hold on
plot(x,c(x)) %every value between f(-3) and f(3) is attained at least once

Differentiability

Definition

Let $f$ be a function defined on an open interval containing $x_0$. The function $f$ is differentiable at $x_0$ if

$$ f'(x_0) = \lim_{x \to x_0} \frac{f(x) - f(x_0)}{x-x_0} $$

exists. In which case, $f'(x_0)$ is the derivative of $f(x)$ at $x_0$. If $f$ has a derivative at each point in a set $X$ then $f$ is said to be differentiable on $X$.

In [47]:
format long %to see more digits
f = @(x) sin(x); df = @(x) cos(x);
x = .0001; x0 = 0;
(sin(x)-sin(x0))/(x-x0)
cos(x0)
ans =

   0.999999998333333


ans =

     1

Here are some of the most important theorems from single-variable calculus:

Theorem

If a function $f$ is differentiable at $x_0$, it is continuous at $x_0$.

Theorem (Rolle's Theorem)

Suppose $f \in C[a,b]$ and $f$ is differentiable on $[a,b]$. If $f(a) = f(b)$, the a number $c$ in $(a,b)$ exists with $f'(c) = 0$.

Theorem (Mean Value Theorem)

Suppose $f \in C[a,b]$ and $f$ is differentiable on $[a,b]$. There exists a point $c \in (a,b)$ such that

$$ f'(c) = \frac{f(b) - f(a)}{b-a}.$$

Theorem (Extreme Value Theorem)

If $f \in C[a,b]$, then $c_1,c_2 \in [a,b]$ exist with $f(c_1) \leq f(x) \leq f(c_2)$, for all $x \in [a,b]$. Furthermore, if $f$ is differentiable on $[a,b]$ then $c_1,c_2$ are either the endpoints ($a$ or $b$) or at a point where $f'(x) = 0$.

This theorem states that both the maximum and minimum values of $f(x)$ on a closed interval $[a,b]$ must be attained within the interval (at points $c_2$ and $c_1$).

A more involved theorem is the following:

Theorem

Suppose $f \in C[a,b]$ is $n$-times differentiable on $(a,b)$. If $f(x) = 0$ at $n+1$ distinct numbers $a \leq x_0 < x_1 < \cdots < x_{n} \leq b$, then a number $c \in (x_0,x_n)$, (and hence in $(a,b)$) exists with $f^{(n)}(c) = 0$.

Consider the 4th degree polynomial $f(x) = 8x^4-8x^2 + 1$:

In [1]:
f = @(x) 8*x.^4-8*x.^2+1; % has 4 zeros on (-1,1)
dddf = @(x) 8*4*3*2*x; % must have 1 zero on (-1,1)
x = linspace(-1,1,100);
plot(x,dddf(x))

Integration

Definition

The Riemann integral of the function $f$ defined on the interval $[a,b]$ is the following limit (if it exists):

$$ \int_a^b f(x) dx = \lim_{\max \Delta x_i \to 0} \sum_{i=1}^n f(\bar x_i) \Delta x_i,$$

where the numbers $x_0,x_1,\ldots,x_n$ satisfy $a = x_0 \leq x_1 \leq \cdots \leq x_n = b$, $\Delta x_i = x_i - x_{i-1}$ for $i = 1,2,\ldots,n$. And $\bar x_i$ is an arbitrary point in the interval $[x_{i-1},x_i]$.

Let's choose the points $x_i$ to be evenly spaced: $x_i = a + i\frac{b-a}{n}$ and $\bar x_i = x_{i}$. Then we have $\Delta x_i = \frac{b-a}{n}$ and

$$\int_a^b f(x) dx = \lim_{n \to \infty} \frac{b-a}{n} \sum_{i=1}^n f(x_{i}).$$
In [37]:
f = @(x) exp(x);
n = 10; a = -1; b = 1;
x = linspace(a,b,n+1); % create n + 1 points
x = x(2:end); % take the last n of these points
est = (b-a)/n*sum(f(x)) % evaluate f at these points and add them up
actual = exp(b)-exp(a) % the actual value
abs(est-actual)
est =

   2.593272082493666


actual =

   2.350402387287603


ans =

   0.242869695206063

Now choose and $\bar x_i = \displaystyle \frac{x_{i}+x_{i-1}}{2}$ to be the midpoint. We still have $\Delta x_i = \frac{b-a}{n}$ and

$$\int_a^b f(x) dx = \lim_{n \to \infty} \frac{b-a}{n} \sum_{i=1}^n f(\bar x_{i}).$$
In [3]:
f = @(x) exp(x);
n = 10; a = -1; b = 1;
x = linspace(a,b,n+1); % create n + 1 points
x = x(2:end); % take the last n of these points
x = x - (b-a)/(2*n); % shift to the midpoint
est = (b-a)/n*sum(f(x)) % evaluate f at these points and add them up
actual = exp(b)-exp(a) % the actual value
abs(est-actual)
est =

   2.346489615388305


actual =

   2.350402387287603


ans =

   0.003912771899298

Theorem (Weighted Mean Value Theorem)

Suppose $f \in C[a,b]$, the Riemann integral of $g$ exists on $[a,b]$, and $g(x)$ does not change sign on $[a,b]$. Then there exists a number $c$ in $(a,b)$ with

$$ \int_a^b f(x) g(x) dx = f(c) \int_a^b g(x) dx. $$

Theorem (Taylor's Theorem)

Suppose $f \in C^n[a,b]$, and that $f^{(n+1)}$ exists on $[a,b]$, and $x_0 \in [a,b]$. For every $x \in [a,b]$, there exists a number $\xi(x)$ between $x_0$ and $x$ with

$$ f(x) = P_n(x) + R_n(x),$$

where

$$ P_n(x) = f(x_0) + f'(x_0)(x-x_0) + \frac{f''(x_0)}{2!} (x-x_0)^2 + \cdots + \frac{f^{(n)}(x_0)}{n!} (x-x_0)^n,$$

and

$$ R_n(x) = \frac{f^{(n+1)}(\xi(x))}{(n+1)!} (x-x_0)^{n+1}. $$