# Secant, Tangent, Piecewise

## May 04, 2021 | 9 minutes, 36 seconds

# Introduction

It's been a while since my last post, and in that time I've been thinking of some cool things with which I could make use of the idea of piecewise. While my techniques have been more heavily focused on how we interact with functions and their graphs, most recently I've been thinking about functions on a more fundamental level in this way. (Though I don't deny that this post is still heavily graph focused)

Realistically speaking, anything can be a piecewise function. It's about how you write it; what intervals you use, how many intervals, what you use to describe certain values in the respective intervals of the function, what notation you use to denote those intervals. All of these factors make up how you construct the representation of your function, rather than the function itself. Essentially in the same way you can represent fractions in different forms, you can represent functions in different forms via piecewise notation. How many ways can you do that? Well, it depends. You could say infinitely many ways. Technicalities arise in the use of the domain of the function itself and while you might think that is a limiting factor, it is more ironically something that can be taken advantage of. A piecewise function that has a discrete domain is *far* easier to work with than one that has a continuous domain (and here we note the existence of the signum 'function'); in general, anyway. Realistically, the fewer the cases you have in your piecewise function or relation, the more likely you are at finding a 'closed form' for it.

I digress. There are some incredibly fun things about this way of thinking, and I want to take you, dear reader, through one of those fun things. And it involves calculus. The marriage of discrete domains, intervals, piecewise and basic calculus is arguably beautiful, but not without its technicalities.

## Notation

In this post I will skip over some details - arguably semantic but nonetheless important. For example, it is important to realise that when I denote equality of functions here, what I mean to say is that over a certain domain that a function will take certain values that define it and represent it over that domain. In this sense I avoid self-referential functions that would simply not make sense; it is for this reason I denote equivalence and not equality (e.g. \(f(a)\) is actually a constant; \(f(x) = f(a)\) describes a predefined constant function or value).

# Impersonating secants and tangents

Suppose we have \(a,b\in\mathbb{D}\) and that \(f:\left\{a,b\right\}\to\mathbb{R}\). Then we have that:

\[ f(x)\equiv \begin{cases} f(a) & x=a \\ f(b) & x=b \end{cases}\]

If you substitute in \(x=a\) or \(x=b\), you'll see that this holds. Now we just apply our magical process to this (I'll write out all of the steps this time for clarity):

\[ \begin{align} f(x) &\equiv \begin{cases} f(a) & x=a \\ f(b) & x=b \end{cases} \\ &\equiv f(a) + \begin{cases} 0 & x=a \\ f(b)-f(a) & x=b \end{cases} \\ &\equiv f(a) + \left(f(b)-f(a)\right)\begin{cases} 0 & x=a \\ 1 & x=b \end{cases} \\ &\equiv f(a) + \frac{f(b)-f(a)}{b-a}\begin{cases} 0 & x=a \\ b-a & x=b \end{cases} \\ &\equiv f(a) + \frac{f(b)-f(a)}{b-a}\left(\begin{cases} a & x=a \\ b & x=b \end{cases}-a\right) \\ &\equiv f(a) + \frac{f(b)-f(a)}{b-a}\left(x-a\right) \\ \end{align}\]

Obviously this creates the restriction on our domain that \(b\neq a\). Well, temporarily at least. To see that this equation works, substitute \(x=a\) and \(x=b\) in and you'll see this also works. Also notice that this *looks like* a secant line equation.

## Secants

Let's suppose that \(g:\mathbb{D}\to\mathbb{R}\) and that \(\forall a,b \in\mathbb{D}\) we have \(\left\{\left(a,f(a)\right),\left(b,f(b)\right)\right\}\subseteq\left\{\left(x,g(x)\right):x\in\mathbb{D}\right\}\). It follows that \(f(x)\) describes *the equation* of every secant line along the graph of \(g(x)\). Similarly this motivates us to graph these lines, which can be done by defining a new function with the same equation, on the more complete domain.

For example, take \(f(x) = x^2\). We then have, for any two arbitrary values \(a, b \in\mathbb{R}\), the equation \((a+b)x-ab\) describes all secant lines on \(x^2\) (you can form this yourself by substituting the equation in). It will also describe all points on \(x^2\) when the domain of each equation is limited to \(\left\{a,b\right\}\) - and in this sense, the equation is more or less parametric.

## Tangents

Let's first completely ignore the idea of a tangent line along on \(f(x)\). We want to focus on the following we obtained from the last time:

\[ f(x) \equiv f(a) + \frac{f(b)-f(a)}{b-a}\left(x-a\right)\]

Let's also notice that if we had restricted our original function \(f(x)\) to \(\left\{a\right\}\) we would simply have \(f(x) = f(a)\). Well, now we have our secant equation; we could try to motivate a different value for \(b\). Let's suppose \(b = a + \delta a\) and \(\delta a \to 0\). We then have:

\[ f(x) \equiv f(a) + \lim_{\delta a \to 0}\frac{f(a+\delta a)-f(a)}{\delta a}(x-a)\]

This is, of course, in the usual sense, the same as:

\[ f(x) \equiv f(a) + f'(a)(x-a)\]

By the same argument as our secant line equaton, we can argue this is a tangent line equation. However, the domain isn't \(\left\{a\right\}\) - it's still \(\left\{a, a+\delta a\right\}\). But this time - the only meaningful value we will actually obtain out of this equation is if \(x=a\). So effectively, this equation parametrically describes every point on the 'overall' function in terms of \(a\). Still, it's pretty cool, right? Well, maybe not as cool as our next bit.

# Revisiting our derivation

Our entire derivation process lead to the following function representation of \(f(x)\) with respect to \(a\in\mathbb{D}\).

\[ f(x) \equiv f(a) + f'(a)(x-a)\]

Let's revisit this. One approach we can take is by modifying the *representation* of the interval of each case. Suppose we have a function \(h:\mathbb{D}\to\mathbb{R}\) such that \(x=a\implies h(x)=h(a)\) and \(x=b\implies h(x)=h(b)\). We can then replace our conditions in our piecewise function and follow through with all of the steps we obtained before. We go from this:

\[ f(x) \equiv f(a) + \frac{f(b)-f(a)}{h(b)-h(a)}(h(x)-h(a))\]

To this, via our same process:

\[ f(x) \equiv f(a) + \frac{f'(x)}{h'(x)}(h(x)-h(a))\]

Letting \(x=a\) gives the same result - provided \(h'(x)\) 'behaves' well. Notice other interesting properties too - for example, if \(h(x)\) - or our describing function, is equal to \(f(x)\), we just get \(f(x)\) back.

Furthermore, if we define a new function \(p:\mathbb{D}\to\mathbb{R}, p(x)=p(a)+\frac{p'(a)}{h'(a)}(h(x)-h(a))\) and specify both \(p(x)\) and \(h(x)\) over all \(a\in\mathbb{D}\) - we get interesting patterns of tangent curves - transformations of \(h(x)\) that include points on the original function. A cool demonstration of this is on Desmos, here.

# Final Remarks

What we can conclude from this is while on our original domain, our expressions we can create will all represent the same set of values our original function does. Outside of that domain however, we can completely reshape the way our functions work - consider any polynomial with a certain number of points - the ways the polynomial can move around those points are infinite. The same occurs here, with piecewise.

Good examples of this property or observation occur within the polynomials. Consider the polynomial \(x^2-2x+1\) over the domain \(\left\{-1,1\right\}\). We have that:

\[ \begin{align} x^2-2x+1 &\equiv \begin{cases} 4 & x=-1\\ 0 & x=1 \end{cases} \\ &\equiv 2(1-x) \end{align}\]

This is because *over that domain*, both of these functions represent the same set of values. Different domain, different representation. You can extend this to any domain, discrete or continuous. You can change the equality using the same method we did above. In fact, generalising this above equivalence is what led to this post. In fact, you can use this equivalence to find where this relation does hold elsewhere in some cases, allowing you to specifically extend the domain. In this case we simply get \(x^2-1\equiv 0\) which is our original domain - so \(2(1-x)\) only holds for \(-1\) and \(1\).

So I hear you asking now - why is this important? Well, it's yet another technique for working with piecewise functions and equations. In situations where you can scale down a function to a few points, or a set of values, you can come up with closed expressions of these (see probability distributions). If you can find a closed form for only a few values and find the solution is as intended, you could use induction (in situations working with discrete values) to prove that that closed form is actually the one you want. Working with many cases is hard - fewer cases is easier, but it's also more difficult to come up with a solution you want in particular. Like I said however, it's another technique that while obscure, can prove useful. It also shows the power of representing equations, which is what I set out to show.