# Introduction & Motivation

## Background

In high school we were introduced to the notion we could solve equations, particularly in polynomials, using a rule called the null factor law, or zero-product property.

It states that if $$ab=0$$ then $$a=0$$ or $$b=0$$.

In our context, we want to go the other way. Instead of solving we could simply 'slap' two equations together to ultimately plot them both implicitly. So if we have $$y=f(x)$$ and $$y=g(x)$$, then we could simply define an implicit relation that states $$(y-f(x))(y-g(x))=0$$ and be done with it. You could graph it by hand easily in that form, or plug it into any graphing calculator supporting implicit relations and you'd be done. We're not going to do this, however. It gives us absolutely no insight into the overall relation as a whole (that is, it doesn't tell us anything about how $$f(x)$$ and $$g(x)$$ relate to one another), and as we progress, we'll find that graphing whole equations proves ineffectual for constructing some "fun" relations.

So for the time being, disregard the above. It serves as a simple layer of motivation, but doesn't take us very far. And, as we'll see, it does have a connection to what we're going to derive, but only at the very end. This part will only focus on two functions that have a simple restriction.

## An average of two functions.

Let's consider pairs of coordinates like $$P=(1,1)$$ and $$Q=(1,3)$$, and also $$R=(4,4)$$ and $$S=(4,6)$$. In each pair of coordinates, a single point lies in between them, equidistant from each other on the $$y$$ axis; $$(1,2)$$ and $$(4,5)$$ respectively. Notice, however, we can describe each pair of points using their average. $$Q$$ exists above the average of $$P$$ and $$Q$$, while $$P$$ exists below it, and likewise with $$R$$ and $$S$$. That is, their existence is dependent on, in a sense, where they sit relative to their average along the $$y$$ axis.

Obviously $$(4,6)$$ cannot exist if it is below $$(4,5)$$, etc. An alternate way to think about this is if, in the cartesian plane, $$(4,6)$$ lies below $$(4,5)$$, then we're not really describing $$(4,6)$$ (whereas the converse we could be). It's important to distinguish that we are describing a certain point, but in terms of its position relative to another, like in the previous example. Otherwise, we wouldn't be describing that point; we'd be describing either another point, which is impossible (there's only one point $$(4,6)$$).

Now, instead of considering the points, we consider the linear functions on which those points lie. In our case, consider $$PR(x)=x$$ and $$QS(x)=x+2$$.

We previously acknowledged the existence of those points using their average (on the $$y$$ axis), which is given by:

$A_{y}=\frac{y_{0}+y_{1}}{2}$

If such an average exists for our new functions, it would therefore be described by, generally:

$A(x)=\frac{f(x)+g(x)}{2}$

In our example, we can then describe our lines: $$QS(x)=x+2$$ lies above our $$A(x)=x+1$$ while $$PR(x)=x$$ lies below it. And this is important, because we now describe all the points on those lines, and averages, including the points we had before at $$x=1$$ and $$x=4$$.

Hence we can now describe our two functions' existence by their positions above and below the average function, for $$f(x)$$ and $$g(x)$$ respectively. With this line of thinking, both functions must strictly remain above or below the average function. At points where our functions meet, is where they intersect the average line. We therefore have, $$g(x) < A(x) < f(x)$$, which forms the aforementioned restriction for our functions.

# Derivation

We've motivated some restrictions for our functions, so now we can construct a single, whole relation that escribes both of the lines plus the average line, but only where our functions meet.

Notice that the equation $$y=f(x)$$'s existence is entirely dependent on the fact $$f(x)>A(x)$$. With that in mind, we can substitute $$y$$ into the inequality to get $$y>A(x)$$. Similarly with our $$y=g(x)$$ equation, we have the restriction $$y < A(x)$$.

When we hit the average line, e.g. $$y=A(x)$$ - the restriction is that $$f(x)=g(x)$$. However, that simply implies the line itself - $$y=A(x)$$ exists if and only if $$y=A(x)$$ (go on, check this. A quick few manipulations and substitution will tell you exactly this).

So now we have now built our foundational Piecewise relation. Hence we now have:

$y = \begin{cases} g(x) & y<A(x) \\ A(x) & y=A(x) \\ f(x) & y>A(x) \end{cases}$

We can now begin manipulating this into a form we can better easily work with. We first begin by subtracting $$A(x)$$ (using our earlier definition!) from each side, and therefore each case, being motivated by the fact each Piecewise case contains $$f(x)$$, $$g(x)$$ or a combintion thereof. We then get:

$y - A(x) = \begin{cases} \frac{g(x)-f(x)}{2} & y<A(x) \\ 0 & y=A(x) \\ \frac{f(x)-g(x)}{2} & y>A(x) \end{cases}$

Factoring out $$\frac{f(x)-g(x)}{2}$$ and simplifying making use of signum with this definition:

$\DeclareMathOperator{\sgn}{sgn} y - A(x) = \frac{f(x)-g(x)}{2}\sgn(y-A(x))$

By the property $$p(x) = q(x)sgn(p(x) \Longrightarrow |p(x)| = q(x)$$ for "most" of $$p(x)$$ (which will be proven in another post) we finally have our result:

$\DeclareMathOperator{\sgn}{sgn} \left|y - A(x)\right| = \frac{f(x)-g(x)}{2}$

# Final Comments

In our equation, we can call the right-hand side $$\hat{A}(x)$$ (you can think of it as the conjugate of $$A(x)$$) so really our final equation is $$\left|y-A(x)\right|=\hat{A}(x)$$.

Furthermore, our derivation and motivation isn't necessarily restricted to the $$y$$ axis. In fact, you could treat any other function as an "axis" (well, not really an axis), and compare relative to that. (The derivation from that follows exactly the same as our current one).

So, for example, you could have $$\left|x - A(y)\right| = \hat{A}(y)$$. And in future posts, we'll make use of this fact heavily.