HW1. Mathematical Foundations: Functions, Calculus, and Linear Algebra¶
Due date: 2026-01-22 23:59.
This homework is designed to help you assess and refresh some of the background knowledge that will be important for the rest of the course. Completing this assignment will help identify any areas that may need review and set you up for success in the rest of the course.
Functions: Preimage Calculation in 1D¶
For the following problems, consider the definition of the preimage of a real-valued function in one dimension:
To visualize preimages in 1D, you will use the following program:
After running the program, you can select any function
f(x) that maps real numbers to real numbers, and any value y and closed interval domain X = [x1, x2] to visualize preimages.How to reason about preimages¶
The preimage of a value π¦ under a function π is the set of all inputs π₯ in the domain such that π(π₯) = π¦.
- Instead of asking "What output does this input produce?"
- You are asking: "Which inputs could have produced this output?"
A reliable way to check whether a particular point π₯ belongs to the preimage of π¦ is to substitute π₯ into the function and evaluate π(π₯).
- If π(π₯) = π¦, then π₯ is in the preimage.
- If π(π₯) β π¦, then π₯ is not in the preimage.
Example:
f(x) = (x - 5)^3 + 1.
\\\
To check whether π₯ = 6 belongs to the preimage of π(π₯) = 2, compute:
f(6) = (6 - 5)^3 + 1 = 1 + 1 = 2.
\\\
Since the result equals π¦, the point π₯ = 6 belongs to the preimage of π(π₯) = 2.
β οΈ Note About the Visualizer¶
No visualizer is perfect. Computing roots of real functions is prone to numerical errors and sampling limitations. As a result, the visualizer may:
- miss some preimages,
- report extra (false) roots,
- perform best for continuous functions rather than stepwise or discrete ones.
These limitations are common in numerical analysis. This is why it is equally important to learn how to reason about preimages analytically.
Calculus: Single-Variable Integration¶
For the next set of problems, we will consider a point moving along the real line. We will examine how the pointβs position, velocity, and acceleration change over time. We will use the following definitions:
To visualize the relationship between acceleration, velocity, and position, we will use the following program:
Initially, the program is set up with the following parameters. From time
t = 2 to t = 3, the acceleration of a point on the line is xΜ = 2. From time t = 3 to t = 4, its acceleration is xΜ = β3. At all other times, the acceleration is zero.The acceleration is double integrated over the time interval defined by
tβ = 0, tβ = 10. Thus, the acceleration can be expressed as xΜ(t) = (2 <= t)(t < 3)2 + (3 <= t)(t < 4)(-3) over this interval of time.The initial conditions are set as follows: at time
tβ = 0, the point is at position x(0) = 0, and its velocity is αΊ(0) = 1. The program then numerically computes the values of position and velocity at the end of the time interval, x(10) and αΊ(10), by integrating acceleration values.We will practice visualizing the integration process by running the program. You can define any acceleration function
xΜ(t), integration interval [tβ, tβ], and initial conditions x(tβ) and αΊ(tβ) to observe how the corresponding velocity αΊ(t) and position x(t) evolve over time. We will also practice how these results can be computed analytically.From Code to Mathematical Representation¶
In the visualizer, the acceleration of the point is specified using Python-style indicator expressions, such as
(2<=t)*(t<3)*2. The boolean expressions (2<=t) and (t<3) evaluate to either 0 or 1, depending on the value of π‘, which creates a compact way to describe piecewise-defined functions.The same acceleration can be written mathematically as a piecewise function:
\ddot{x}(t)=
\begin{cases}
2, & 2 \le t < 3, \\
-3, & 3 \le t < 4, \\
0, & \text{otherwise}.
\end{cases}
\\\
Together with the initial conditions
\dot{x}(0)=1, \qquad x(0)=0,
\\\
and the time interval
t \in [0,10],
\\\
this fully specifies the motion of the point along the line for this time interval.
The code-based representation used by the visualizer and the mathematical piecewise definition above describe exactly the same physical behavior. They are simply two different ways to describe the same motion of a point along the line.
Relationship between acceleration, velocity, and position¶
Finally, recall the fundamental relationships between acceleration, velocity, and position for motion along a line.
Velocity is obtained by accumulating acceleration over time. If the velocity at time tβ is known, then for any later time t it can be written as
\dot{x}(t) = \dot{x}(t_0) + \int_{t_0}^{t} \ddot{x}(s)ds.
\\\
Similarly, position is obtained by accumulating velocity over time. If the position at time tβ is known, then
x(t) = x(t_0) + \int_{t_0}^{t} \dot{x}(s)ds.
\\\
These expressions formalize the idea that acceleration determines how velocity changes, and velocity determines how position changes.
In the visualizer, these integrations are performed numerically. In the questions that follow, you will practice expressing the same relationships analytically by writing down the corresponding integrals over the time intervals where the acceleration is nonzero.
Linear Algebra: Singular Value Decomposition (SVD)¶
For any real-valued π Γ π matrix, π, the singular value decomposition (SVD) allows us to write:
M = U \, \Sigma \, V^{\mathsf{T}},
\\\
in which,
- π½α΅ is the transpose of the matrix π½, in which π½ is an π Γ π orthogonal matrix,
- Ξ£ is an π Γ π diagonal matrix with non-negative entries, which are called singular values,
- πΌ is an π Γ π orthogonal matrix.
In this part of the assignment, we will explore how SVD decomposes general 3Γ2 matrices into π = π Ξ£ πα΅, and how this decomposition helps us:
- visualize matrix transformations,
- as well as to compute inverses and pseudo-inverses of these matrices.
About Matrix Sizes¶
In this homework, π is a 3 Γ 2 matrix. It maps 2D inputs to 3D outputs. As a result:
- π½ is a 2 Γ 2 orthogonal matrix,
- Ξ£ is 3 Γ 2,
- πΌ is 3 Γ 3.
In general, SVD works for any real matrix, not just 3 Γ 2 ones.
Visualization Tool¶
You will use the following visualization tool:
This tool visualizes how a 2D unit circle in the input (π, π)-plane is mapped to a 3D ellipse by the matrix π. The program shows this transformation in two different ways:
- Direct transformation using the full matrix π.
- Step-by-step SVD transformation, where the matrices are applied in the following order:
- πα΅ first, followed by
- Ξ£, followed by
- π.
The visualizer animates these steps, so you can clearly observe the effect of each matrix independently.
Note: Just like other visual tools in this homework, this visualizer is also subject to numerical limitations.
Understanding the visualization is important, but it is equally important to be able to reason about matrix behavior analytically.
Example¶
Consider the matrix:
M=
\begin{bmatrix}
2 & 0\\
0 & 1\\
0 & 0
\end{bmatrix}.
\\\
This matrix takes a 2D point (π₯, π¦) and maps it into 3D by stretching the second coordinate more than the first, and embedding the result in a 3D space:
M
\begin{bmatrix}
x\\
y
\end{bmatrix} =
\begin{bmatrix}
2 & 0\\
0 & 1\\
0 & 0
\end{bmatrix}
\begin{bmatrix}
x\\
y
\end{bmatrix} =
\begin{bmatrix}
2x \\
y \\
0
\end{bmatrix}.
\\\
One of its singular value decomposition is:
M =
\begin{bmatrix}
1 & 0 & 0\\
0 & 1 & 0\\
0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
2 & 0\\
0 & 1\\
0 & 0
\end{bmatrix}
\begin{bmatrix}
1 & 0\\
0 & 1
\end{bmatrix},
\\\
in which:
- πα΅ = πΌ means no rotations is applied in the input 2D plane,
- Ξ£ stretches the unit circle into an ellipse in the input 2D plane:
\Sigma=
\begin{bmatrix}
2 & 0\\
0 & 1\\
0 & 0
\end{bmatrix},
\\\
- π = πΌ means no rotation is applied in the output 3D space either.
In this simple case, it is trivial to see how SVD separates identity rotations from scaling (singular values). More complicated matrices behave the same way, except that rotations become more complicated.
Authors¶
Anna LaValle.
Give feedback on this content
Comments about these exercises