Skip to main content

MATH 345: Linear Algebra and Optimization

Section 3.1 General functions and domains

Subsection Function types and component functions

Unit 1 and Unit 2 studied maps of the form \(\mathbf{x}\mapsto A\mathbf{x}\text{.}\) We now allow more general rules. The output may be a scalar, a vector, or several scalar component functions collected together.

Definition 3.1.1.

A vector-valued map is usually written \(F:\R^n\to\R^m\text{.}\) A scalar-valued function is usually written \(f:\R^n\to\R\text{.}\) Any vector-valued map \(F:\R^n\to\R^m\) has \(m\) component functions, or coordinate functions, the scalar-valued functions \(F_1,\dots,F_m:\R^n\to\R\) such that
\begin{equation*} F(\mathbf{x}) = \begin{bmatrix} F_1(\mathbf{x}) \\ \vdots \\ F_m(\mathbf{x}) \end{bmatrix}\text{.} \end{equation*}
More generally, vector-valued and scalar-valued functions may only be defined on a subset of vectors in \(\R^n\text{,}\) rather than defined everywhere, so their domain may be a proper subset of \(\R^n\text{.}\)
In other words, a scalar-valued function takes in an input and outputs scalars, and a vector-valued function takes in an input and outputs vectors (recall DefinitionΒ 1.1.1).

Activity 3.1.1.

If \(\mathbf{x}\) is a point in \(\R^n\text{,}\) recall the length of \(\mathbf{x}\text{,}\) denoted \(\| \mathbf{x} \|\text{,}\) from DefinitionΒ 1.1.3. The length of a vector defines a scalar-valued function from \(\R^n\) to \(\R\text{.}\) Find two different vectors with the same length. What does this say about whether the output determines the input?
Solution.
There are many different choices one could make here. For instance, the vector \((3,4)\) and the vector \((5,0)\) both have the same length. Other examples are the vectors \((1,2)\) and \((-1,2)\text{.}\)

Activity 3.1.2.

Let \(A\) be an \(m \times n\) matrix. The linear map (recall DefinitionΒ 1.3.15) \(T: \R^n \to \R^m\) defined by \(T(\mathbf{x}) = T_A(\mathbf{x}) = A\mathbf{x}\) is a vector-valued map. Each component function is a row dot product.
(a)
If \(\mathbf{a}_1, \dots, \mathbf{a}_m\) are the rows of \(A\text{,}\) and \(T_1, \dots, T_m\) are the component functions of \(T\text{,}\) then for each \(j\text{,}\) express the function \(T_j\) in terms of the row \(\mathbf{a}_j\text{.}\)
Solution.
Recalling the definition of matrix vector multiplication from DefinitionΒ 1.3.1, we can write
\begin{equation*} T_j(\mathbf{x}) = a_{j1} x_1 + \cdots + a_{jn} x_n = \mathbf{a}_j \cdot \mathbf{x}\text{.} \end{equation*}
(b)
Consider the matrix
\begin{equation*} A = \begin{bmatrix} 1 & 2 & -1 \\ 0 & 3 & 4 \end{bmatrix}\text{,} \end{equation*}
which defines a linear map \(T_A: \R^3 \to \R^2\text{.}\) Compute its component functions for a general input \(\mathbf{x}\text{,}\) and its output for the specific input \(\mathbf{x} = (3, -1, 2)\text{.}\)
Solution.
The component functions are:
\begin{equation*} T_1(\mathbf{x}) = (1,2,-1) \cdot \mathbf{x} = x_1 + 2 x_2 - x_3 \end{equation*}
and
\begin{equation*} T_2(\mathbf{x}) = (0,3,4) \cdot \mathbf{x} = 3x_2 + 4x_3\text{.} \end{equation*}
For an input \(\mathbf{x} = (3, -1, 2)\text{,}\) we compute that
\begin{equation*} T(\mathbf{x}) = \begin{bmatrix} 1 \amp 2 \amp -1 \\ 0 \amp 3 \amp 4 \end{bmatrix} \begin{bmatrix} 3 \\ -1 \\2 \end{bmatrix} = \begin{bmatrix} -1 \\ 5 \end{bmatrix}\text{.} \end{equation*}

Activity 3.1.3. Corners are not enough.

Unit 1 used the unit-square visualization for \(2\times 2\) matrices. For nonlinear maps, the corners of a square do not tell the whole story.
Let \(T,F:\mathbb R^2\to\mathbb R^2\) be defined by
\begin{equation*} T\left(\begin{bmatrix}x\\y\end{bmatrix}\right) = \begin{bmatrix} x+y\\ y \end{bmatrix}, \qquad F\left(\begin{bmatrix}x\\y\end{bmatrix}\right) = \begin{bmatrix} x+y^2\\ y \end{bmatrix}. \end{equation*}
  1. Compute the images of the four corners of the unit square under \(T\text{.}\)
  2. Compute the images of the four corners of the unit square under \(F\text{.}\)
  3. Compute the images of \(\begin{bmatrix}0\\1/2\end{bmatrix}\) under both maps.
  4. What does \(F\) do to a point \(\begin{bmatrix}0\\y\end{bmatrix}\) on the left edge of the unit square?
Solution.
The four corners are
\begin{equation*} \begin{bmatrix}0\\0\end{bmatrix}, \begin{bmatrix}1\\0\end{bmatrix}, \begin{bmatrix}1\\1\end{bmatrix}, \begin{bmatrix}0\\1\end{bmatrix}. \end{equation*}
For \(T\text{,}\)
\begin{gather*} T\left(\begin{bmatrix}0\\0\end{bmatrix}\right)=\begin{bmatrix}0\\0\end{bmatrix}, \quad T\left(\begin{bmatrix}1\\0\end{bmatrix}\right)=\begin{bmatrix}1\\0\end{bmatrix},\\ T\left(\begin{bmatrix}1\\1\end{bmatrix}\right)=\begin{bmatrix}2\\1\end{bmatrix}, \quad T\left(\begin{bmatrix}0\\1\end{bmatrix}\right)=\begin{bmatrix}1\\1\end{bmatrix}. \end{gather*}
For \(F\text{,}\) the four corner images are the same:
\begin{gather*} F\left(\begin{bmatrix}0\\0\end{bmatrix}\right)=\begin{bmatrix}0\\0\end{bmatrix}, \quad F\left(\begin{bmatrix}1\\0\end{bmatrix}\right)=\begin{bmatrix}1\\0\end{bmatrix},\\ F\left(\begin{bmatrix}1\\1\end{bmatrix}\right)=\begin{bmatrix}2\\1\end{bmatrix}, \quad F\left(\begin{bmatrix}0\\1\end{bmatrix}\right)=\begin{bmatrix}1\\1\end{bmatrix}. \end{gather*}
For the midpoint,
\begin{equation*} T\left(\begin{bmatrix}0\\1/2\end{bmatrix}\right)=\begin{bmatrix}1/2\\1/2\end{bmatrix}, \qquad F\left(\begin{bmatrix}0\\1/2\end{bmatrix}\right)=\begin{bmatrix}1/4\\1/2\end{bmatrix}. \end{equation*}
On the left edge,
\begin{equation*} F\left(\begin{bmatrix}0\\y\end{bmatrix}\right)=\begin{bmatrix}y^2\\y\end{bmatrix}. \end{equation*}
So \(F\) bends the left edge into a curve. A grid gives more information than the corners alone.

Note 3.1.2.

A matrix sends grid lines to grid lines. A nonlinear map can bend grid lines. The square-grid visualization samples points and grid lines, not only the corners.

Activity 3.1.4. Reading a square-grid computation.

The following code applies the nonlinear map
\begin{equation*} F\left(\begin{bmatrix}x\\y\end{bmatrix}\right) = \begin{bmatrix} x+y^2\\ y \end{bmatrix} \end{equation*}
to several input points stored as columns.
import numpy as np

def F(P):
    x = P[0, :]
    y = P[1, :]
    return np.vstack([x + y**2, y])

P = np.array([
    [0.0, 1.0, 1.0, 0.0, 0.0],
    [0.0, 0.0, 1.0, 1.0, 0.5],
])

F(P)
Output:
array([[0.  , 1.  , 2.  , 1.  , 0.25],
       [0.  , 0.  , 1.  , 1.  , 0.5 ]])
  1. What points are stored in the first four columns of \(P\text{?}\)
  2. What point is stored in the last column of \(P\text{?}\)
  3. What output corresponds to the last column?
  4. Why do the first four columns not detect the difference between \(F\) and the shear \(T(x,y)=(x+y,y)\text{?}\)
  5. Why is a grid more informative than the four corners?
Solution.
The first four columns are the corners
\begin{equation*} \begin{bmatrix}0\\0\end{bmatrix}, \begin{bmatrix}1\\0\end{bmatrix}, \begin{bmatrix}1\\1\end{bmatrix}, \begin{bmatrix}0\\1\end{bmatrix}. \end{equation*}
The last column is
\begin{equation*} \begin{bmatrix} 0\\ 1/2 \end{bmatrix}. \end{equation*}
Its output is
\begin{equation*} F\left(\begin{bmatrix}0\\1/2\end{bmatrix}\right) = \begin{bmatrix} 1/4\\ 1/2 \end{bmatrix}. \end{equation*}
The four corners have the same images under \(F\) and under \(T(x,y)=(x+y,y)\text{.}\) The midpoint does not. A grid includes edge and interior points, so it can show bending that the four corners miss.

Note 3.1.3. Reading square-grid diagrams.

A square-grid diagram keeps track of input points and output points at the same time. The color identifies the original input point. The grid lines show how nearby input points move.
For a matrix map, grid lines stay straight and the whole grid is controlled by one matrix. For a smooth nonlinear map, grid lines may bend.
The purpose of the diagram is not to replace computation. It shows what the computation is doing.
Unit square grid compared under a linear shear and a nonlinear shear.
A colored grid in the unit square is shown next to its images under a linear shear and a nonlinear shear. The linear shear sends the grid to straight slanted grid lines. The nonlinear shear bends some grid lines even though the four corners match the linear shear.
Figure 3.1.4. Square-grid visualization for \(T(x,y)=(x+y,y)\) and \(F(x,y)=(x+y^2,y)\text{.}\) The color identifies the original input point. The two maps agree on the four corners, but the nonlinear map bends grid lines.

Subsection Domains, ranges, graphs, and level curves

Subsubsection Domain and range

Definition 3.1.5. Domain and range.
The domain of a function is the set of all inputs for that function, and the range is the set of all possible outputs. More formally, if a function \(f\) takes inputs from a set \(X\) and outputs elements in a set \(Y\text{,}\) then the domain of \(f\) is the set \(X\text{,}\) and the range is the set of all \(y \in Y\) for which \(y = f(x)\) for some \(x \in X\text{,}\) which we might write in set notation as \(\{ y \in Y: y = f(x)\ \text{for some}\ x \in X \}\text{.}\)
In calculus, we often define the domain of a function \(f\) implicitly, by defining \(f\) in terms of an expression, and then letting the domain of \(f\) be the set of all values which, when substituted into that expression, lead to a well-defined quantity. For instance, we might discuss β€˜the function’ \(f(x,y) = x/y\text{,}\) by which we mean the function with domain \(\{ (x,y) \in \R^2 : y \neq 0 \}\) and range \(\R\text{.}\)
For scalar-valued functions of two variables, domains and level curves are subsets of the plane. These pictures help us see where a function is defined and how its outputs change.
Activity 3.1.5.
Sketch the domains of the following functions:
(a)
\(f(x,y) = \ln(y - x^2) + \sqrt{x} \text{.}\)
Solution.
The expression that defines the function \(f\) consists of the sum of two terms, and so to find the domain of \(f\text{,}\) we must identify where both terms are well defined.
The term \(\ln(y - x^2)\) is well defined when the input to \(\ln\) is positive, i.e., when \(y - x^2 > 0\text{.}\) We may rearrange this inequality to read \(y > x^2\)
The term \(\sqrt{x}\) is well-defined when the input to \(\sqrt{\cdot}\) is non-negative, i.e., when \(x \geq 0\text{.}\)
So \(f\) is well-defined when both \(y > x^2\) and when \(x \geq 0\text{,}\) and so the domain of \(f\) is the set of all points \((x,y)\) such that \(x \geq 0\) and \(y > x^2\text{.}\) Using set notation, we can also write the domain as the set
\begin{equation*} \{ (x,y) \in \R^2: x \geq 0\ \text{and}\ y > x^2 \}\text{.} \end{equation*}
The set is the region in the plane bounded from below by the parabola \(y = x^2\text{,}\) and on the left by the \(y\)-axis, as depicted in FigureΒ 3.1.6.
Shaded domain to the right of the y-axis and above a parabola.
The figure shows coordinate axes with a vertical boundary at \(x=0\) and an upward-opening parabola \(y=x^2\text{.}\) The shaded purple region lies to the right of the \(y\)-axis and above the parabola. The drawing emphasizes that the domain requires both \(x\geq 0\) and \(y>x^2\text{.}\)
Figure 3.1.6. Domain of \(f(x,y) = \ln(y - x^2) + \sqrt{x}\text{.}\) Figure by Melissa Lindsey.
(b)
\(f(x,y) = e^x \sin y\)
Solution.
The expression defining the function \(f\) consists of the product of \(e^x\) and \(\sin y\text{,}\) and so \(f\) is well-defined precisely when \(e^x\) and \(\sin y\) are both well-defined. Both expressions are well-defined for all inputs. And so the domain of \(f\) is the set \(\R^2\text{.}\)
(c)
\(f(x,y) = \frac{\sqrt{x}}{\sqrt{y}}\)
Solution.
The expression defining \(f\) is a fraction with numerator \(\sqrt{x}\) and denominator \(\sqrt{y}\text{.}\) The expression is therefore well-defined when both the numerator and denominator are well defined, and when the denominator is non-zero.
The numerator \(\sqrt{x}\) is well-defined when \(x \geq 0\text{.}\) The denominator \(\sqrt{y}\) is well-defined when \(y \geq 0\text{,}\) and is non-zero when \(y > 0\text{.}\)
So the domain of \(f\) is the set of all \((x,y) \in \R^2\) with \(x \geq 0\) and \(y > 0\text{,}\) or in set notation, the set
\begin{equation*} \{(x,y) \in \mathbb{R}^2 : x \geq 0\ \text{ and }\ y > 0\}\text{.} \end{equation*}
This set is the first quadrant in the \(xy\)-plane, including the positive \(y\)-axis, but excluding the origin and the positive \(x\)-axis. See FigureΒ 3.1.7.
First-quadrant domain with the positive x-axis excluded.
The coordinate plane is shaded purple in the region with \(x\geq 0\) and \(y>0\text{.}\) The \(y\)-axis is included as part of the boundary, while the \(x\)-axis is drawn as a dashed red boundary to show it is excluded. A handwritten note points out that the dashed boundary is where \(y=0\text{.}\)
Figure 3.1.7. Domain of \(f(x,y) = \frac{\sqrt{x}}{\sqrt{y}}\text{.}\) Figure by Melissa Lindsey.

Subsubsection Graphs and level curves

Definition 3.1.8. The Graph of a Function.
The graph of a function \(f\) is the set of all pairs \((x,f(x))\text{,}\) with \(x\) in the domain of \(f\text{.}\)
When \(f\) is a scalar-function of two variables, the graph of \(f\) is a set of triples \((x,y,f(x,y))\text{,}\) and thus a subset of \(\R^3\text{,}\) and can therefore be visualized as a surface. See FigureΒ 3.1.9 for a picture of the graph of the function \(f(x,y) = x e^{-x^2-y^2}\text{.}\)
A 3D surface graph of x times an exponential decay.
The figure shows a 3D coordinate system with a red mesh surface for \(z=x e^{-x^2-y^2}\text{.}\) The surface rises to a rounded ridge on the positive \(x\) side and falls to a matching trough on the negative \(x\) side. Away from the origin, the surface flattens toward the \(xy\)-plane.
Figure 3.1.9. A graph of the function \(f(x,y) = x e^{-x^2-y^2}\text{.}\)
Definition 3.1.10. Level Curves and Contour Plots.
A level curve of a scalar function \(f\) of two variables is the curve consisting of pairs \((x,y)\) satisfying the equation \(f(x,y) = c\text{,}\) for some \(c \in \R\text{.}\) A contour plot is a sketch in \(\R^2\) depicting level curves of a function \(f\) for many different values of \(c\text{.}\)
The different values of \(c\) which are chosen to be depicted in a contour plot are often (but not always) obtained by varying \(c\) by a common difference, obtaining β€˜consecutive’ level sets.
Activity 3.1.6.
Sketch a contour plot for the function
\begin{equation*} f(x,y) = e^{x^2 + y^2} \end{equation*}
by sketching the level curves \(f(x,y) = c\) with \(c = 1\text{,}\) \(c = e\text{,}\) \(c = e^4\text{,}\) and \(c = e^9\text{.}\)
Solution.
Table and concentric circular level curves for an exponential radial function.
The left side lists level values such as \(1\text{,}\) \(e\text{,}\) \(e^4\text{,}\) and \(e^9\) with the corresponding equations for \(x^2+y^2\text{.}\) The right side shows concentric circles centered at the origin in the \(xy\)-plane. Larger level values correspond to circles farther from the origin.
Figure 3.1.11. Level curves of \(f(x,y) = e^{x^2+y^2}\text{.}\) Figure by Melissa Lindsey.