# Linear Function Visualization In general we can think of our function $f: \mathbb{R}^n \rightarrow \mathbb{R}$, where $f(x) = c_1x_1 + \dots + c_nx_n = c^Tx$ , as producing a **hyperplane** of dimension $\mathbb{R}^n$ that is [embedded](Embedding.md) in $\mathbb{R}^{n+1}$. But we can also think about what *defined* our hyperplane. That hyperplane is defined by the vector of coefficients $c_i$: $\boldsymbol{c} = \begin{bmatrix} c_1 \\ \vdots \\c_n \end{bmatrix}$ This vector $\boldsymbol{c}$, which lives in $\mathbb{R}^n$, is **perpendicular** to the [Level Sets](Level%20Sets.md) of $f$ (which also lives in $\mathbb{R}^n$). We can think of the level sets as lines [defined via projection](Projection%20Defines%20a%20Line.md). As we move along the vector $\boldsymbol{c}$ we will pass through successively larger / smaller level sets. The key idea is that by just having $\boldsymbol{c}$ we can entirely reconstruct our hyperplane representation. Starting in our input space, we find the set of all vectors that would project to the same magnitude along $\boldsymbol{c}$. Let this magnitude be $t$. This set of vectors forms a level set in the input space. We then simply take this level set and for each point within it, we assign it a value of $t$ for it's $n+1$ dimension (previously the value in this dimension had be $0$). We do this for all possible values of $t$. This reconstructs our hyperplane. It is this ability to construct one from the other that makes these equivalent representations. ### An Example Consider the simple [Linear Function](Linear%20Transformations.md): $f(x) = c_1x_1 + c_2x_2$ How can we visualize this function? What is it's *geometry*? > The first way we can think about this function is as a **plane** embedded in $\mathbb{R}^3$. This is because $f$ is simply a map $\mathbb{R}^2 \rightarrow \mathbb{R}$, satisfying the constraints of linearity. If we look across all tuples $(x_1, x_2) \in \mathbb{R}^2$ and evaluate them via $f$, we will yield the hyperplane shown in the figure below. As we change our values of $c_1$ and $c_2$ we create any arbitrary hyperplane that we wish. So, we can think about our function $f$ as mapping to the space of two dimensional planes, where the exact plane that we map to is defined by $c_1$ and $c_2$. ![center | 500](Screenshot%202024-10-24%20at%202.52.40%20PM.png) > The second way that we think about $f$ is as the **vector** $\begin{bmatrix} c_1 \\ c_2 \end{bmatrix}$. Let us say that $f(x) = c_1x_1 + c_2x_2 = 0$. That represents a specific *counter line* where $f(x)$ always evaluates to $0$. More generally, we can write $f(x) = c_1x_1 + c_2x_2 = b$, where as we vary $b$ we get a different contour line. So, a contour line really represents all values of our input space that, when evaluated via $f$, yield the same value in the output space. Now imagine we are on the contour line where $f(x) = 2$. We want to move to the contour line where $f(x) = 2.1$. In what *direction* in our input space should we move? We should move in the direction of $\begin{bmatrix} c_1 \\ c_2 \end{bmatrix}$. This can be seen clearly if we just think about the [Gradient](Gradient.md). It says "given where we are right now, what direction provides the fastest rate of increase?". We can evaluate the gradient as: $ \nabla f(x) = \begin{bmatrix} \frac{\partial f}{\partial x_1}(x) \\ \frac{\partial f}{\partial x_2}(x) \\ \end{bmatrix} = \begin{bmatrix} c_1 \\ c_2 \end{bmatrix} $ We can see this exact vector in red in the figure below. ![center | 500](Pasted%20image%2020241025140107.png) What we start to see is that this vector $\begin{bmatrix} c_1 \\ c_2 \end{bmatrix}$ provides us all the information we need when thinking about our linear function. From it we can reconstruct the hyperplane point of view. Now, as we step up into higher dimensions, our plane becomes a hyperplane of dimension $n$, and the "contours" are of dimension $n-1$. If we step down one dimension, our plane is a line and our "contours" are just points. ### Dual Space --- Date: 20241024 Links to: Tags: References: * []()