Math Fundamentals
Numerical Methods
David Mayerich
Scalable Tissue Imaging and Modeling (STIM) Laboratory
Department of Electrical and Computer Engineering
Cullen College of Engineering
University of Houston
David Mayerich
STIM Laboratory, University of Houston

Taylor Series
Maclaurin Series
Error Terms
Approximating Complex Functions
David Mayerich
STIM Laboratory, University of Houston
Taylor Series
-
A special function has a standardized name and notation:
\(\quad \sin(x) \quad\quad e^x \quad\quad \tan^{-1}(x) \quad\quad \ln(x) \quad\quad \log_2(x) \quad\quad \text{erf}(x) \quad\quad J_n^{(1)}(x) \) -
Digital processors perform basic numerical operations (ex. addition, multiplication)
-
Special functions require specific algorithms to evaluate
-
Start with one you probably know: Taylor expansions
David Mayerich
STIM Laboratory, University of Houston
-
But now we have infinite summations...
-
Consists of basic mathematical operations executed in a loop
Maclaurin Series
-
Start with expansions about zero
-
Creating an n-order Maclaurin polynomial requires differentiating a function n times
David Mayerich
STIM Laboratory, University of Houston
- How does this work?
Expansion of a Polynomial
David Mayerich
STIM Laboratory, University of Houston
Truncation Error
-
The Taylor expansion for a degree d polynomial has at most d non-zero terms:
David Mayerich
STIM Laboratory, University of Houston
-
Many functions have infinite approximations:
-
Calculating these functions requires truncating to a finite number of terms:
we want this error to be small
Remainder Term
-
The error term can be expressed analytically using the Lagrange remainder:
David Mayerich
STIM Laboratory, University of Houston
-
We approximate the function by taking k terms in the series:
where z is some value \(0\leq z \leq x\)
-
What can we know about this error?
Lagrange Remainder Term
-
How will this term behave as the number of terms increases?
-
Consider: factorial vs. exponential growth, numerator as derivative increases
-
-
How does this term change with \(x\) and \(k\)?
-
Consider the error with the following functions:
David Mayerich
STIM Laboratory, University of Houston
Taylor Series
-
A Taylor series shifts the expansion away from zero
David Mayerich
STIM Laboratory, University of Houston
-
How can this benefit us?
Sets and Spaces
Sets of Numbers
Cartesian Products
Tensors
David Mayerich
STIM Laboratory, University of Houston
Number Sets
-
Natural Numbers (can start from 0 or 1)
-
Integers (includes negative numbers)
-
Rational Numbers
-
fractions of integers
-
-
Real Numbers
-
Complex Numbers
David Mayerich
STIM Laboratory, University of Houston
Building Sets
-
Set Builder Notation
-
variable: potential member of a set
-
predicate: condition for membership
-
-
Common conditional operations:
-
Real numbers in the range
-
A domain is commonly specified with the variable:
-
Evaluate the following sets:
David Mayerich
STIM Laboratory, University of Houston
logical and
logical or
"there exists"
variable
predicate
Cartesian Product and n-Tuples
David Mayerich
STIM Laboratory, University of Houston
2-tuple
3-tuple
Tensor and Outer Products
-
The tensor product is a Cartesian product
that also satisfies the following distributive properties:
-
For sets of numbers these conditions lead to the "outer product" in linear algebra:
David Mayerich
STIM Laboratory, University of Houston
Tensors and Arrays
-
A set produced using tensor products is a tensor
-
The number of tensor products defines the order of the tensor
-
0-order tensors are scalar values:
-
1-order tensors are vectors
-
2-order tensors are matrices
-
Higher-order (3+) tensors exist
-
Mathematics is just extended
-
Machine learning, image processing, physics
-
David Mayerich
STIM Laboratory, University of Houston
Manipulating Tensors
-
Representing tensors in algorithms:
David Mayerich
STIM Laboratory, University of Houston
-
Use notation to constrain your requirements when designing algorithms:
what is the vector space of B and D?
We don't know the set of B, but we do know it's size.
We know the sum is at least
float a[5];
float* a = (float*) malloc(5 * sizeof(float));
float* a = new float[5];float B[3][4][2];
float* B = (float*) malloc(3 * 4 * 2 * sizeof(float));
std::complex<float>* = new std::complex<float>[3 * 4];a = numpy.zeros((5, 1))a = numpy.zeros((3, 4), dtype=numpy.complex64)C/C++
Python
Functions
Continuous Functions
Domain and Range Sets
Discrete Functions
David Mayerich
STIM Laboratory, University of Houston
Continuous and Discrete
- Functions provide a mapping from one space to another
- Consider the Bessel function (often used in EM scattering):
- This function is difficult to calculate for any \(x\) and \(n\)
- Evaluate the series above and truncate
- Use another approximation:
- Pre-compute a discrete array and access the values as needed: \(J[n_i, x_j]\)
- I will use (...) to represent to continuous functions and [...] for discrete functions
- The values \( n_i \in \mathbb{N} \) and \(x_j \in \mathbb{N}\) are indices calculated from \(n\) and \(x\)
David Mayerich
STIM Laboratory, University of Houston
Discrete Function Examples
- How can we define the set for a 1024 x 768 color image?
- The "theoretical" image can be expressed as a continuous function:
\( \mathbf{m}(\mathbf{x})\in \mathbb{R}^3\) where \(\mathbf{x}\in\mathbb{R}^2\)- Each point returns a 3-tuple (representing red, green, and blue)
- This is equivalent to: \(\mathbf{m}(x, y)\in\mathbb{R}^3\) where \( x, y \in \mathbb{R}\)
- In computer memory the image will be represented as a series of samples:
\( \mathbf{m}[\mathbf{u}]\in \mathbb{R}^3\) where \(\mathbf{u}\in\mathbb{N}^2\)
David Mayerich
STIM Laboratory, University of Houston





Hilbert Spaces
Complete Sets
Inner Products
David Mayerich
STIM Laboratory, University of Houston
Complete Sets
A set \(\mathbb{M}\) is incomplete if a series of elements in \(\mathbb{M}\) converges to a result outside of \(\mathbb{M}\)
David Mayerich
STIM Laboratory, University of Houston
or calculating the arc-tangent:
A complete space includes all points in a series and the values they converge to
(\(\mathbb{R}\) and \(\mathbb{C}\) are complete, \(\mathbb{Q}\) is not)
Consider the Lebniz formula for \(\pi\):
(if \(x \in \mathbb{Z}\))
Inner Products
An inner product \(\langle\mathbf{a} , \mathbf{b}\rangle\) is an operation across some set \(\mathbb{M}\) with the following properties:
- maps two vector values to a scalar: \(\langle\mathbf{a},\mathbf{b}\rangle=c\) where \(\mathbf{a}\in\mathbb{M}^n\), \(\mathbf{b}\in\mathbb{M}^n\), and \(c\in\mathbb{M}\)
- conjugate symmetric: \(\langle\mathbf{a},\mathbf{b}\rangle = \overline{\langle\mathbf{b},\mathbf{a}\rangle}\), where \(\overline{x}\) is the conjugate transpose of \(x\)
- positive definite: \(\langle\mathbf{a},\mathbf{a}\rangle >0\), unless \(\mathbf{a} = \mathbf{0}\) in which case \(\langle \mathbf{a},\mathbf{a}\rangle = 0\)
- linear in the first argument: \(\langle \alpha\mathbf{a} +\alpha\mathbf{b}, \mathbf{c}\rangle = \alpha\langle \mathbf{a}, \mathbf{c}\rangle + \alpha \langle \mathbf{b}, \mathbf{c}\rangle\)
David Mayerich
STIM Laboratory, University of Houston
The inner product in \(\mathbb{R}\) and \(\mathbb{C}\) is usually defined as the "dot product":
Hilbert Spaces
A Hilbert space is a set that is:
- complete
- has an inner product
David Mayerich
STIM Laboratory, University of Houston
Real and complex vector spaces \(\mathbb{R}^n\) and \(\mathbb{C}^n\) are the most common examples.
Another example includes the set of all functions (ex. \(f(x)\in\mathbb{C}\)). The inner product between two functions \(f(x)\) and \(g(x)\) is:
which is a continuous extension of the vector dot product:
Discussion
-
Does the set of all polynomials \(\mathbb{P} = \{x^0, x^1, x^2, \cdots \}\) form a Hilbert space?
-
What is the upper bound (worst-case) error if we approximate \(e^x\) using a 5th-order Maclaurin series in the range \(x\in [0, 1]\)?
-
Assume that we are running a simulation to calculate the electric field \(\mathbf{E}(\mathbf{r})\), which describes the scattered field at a position \(\mathbf{r}\).
- What is the Hilbert space for \(\mathbf{E}\)?
- What is the Hilbert space for \(\mathbf{r}\)?
- How would these change when running the simulation on a discrete grid?
David Mayerich
STIM Laboratory, University of Houston
\(\mathbf{r}\in \mathbb{R}^3\)
\(\mathbf{E}(\mathbf{r},t)\in \mathbb{R}^3\)
\(\mathbf{E}(\mathbf{r})\in \mathbb{C}^3\)
Lagrange remainder:
A.2 Math Fundamentals
By STIM Laboratory
A.2 Math Fundamentals
- 256