How to shrink explicit function definitions to 1 line?

45 Views Asked by At

Assume maximum domain for all following examples. We know that $f(x)=|x-1|$ can be expanded(split) into branches like this: $f(x)=\left\{\begin{gather}-x+1, x\le 1\\x-1, x \gt 1\end{gather}\right\}$ or $f(x)=min(x^{2}-2, 2)$ can be written as $f(x)=\left\{\begin{gather}2, x\lt -2\\x^{2}-2, -2 \le x \le 2 \\ 2, x \gt 2\end{gather}\right\}$ I usually found these branched forms in math problems to study continuity and what not. What i'm interested in is if i can do the reverse (write all branches in 1 line in closed form if possible) in a general case where branches appear. Maybe something like: $f(x)=\left\{\begin{gather}-2x+7, x\lt -10\\x^{3}-2x^{2}+8, -10 \le x \le 3 \\ \ln (x+8), x \gt 3\end{gather}\right\}$ can be written as $f(x)=A*(-2x+7)+B*(x^{3}-2x^{2}+8)+C*(\ln (x+8))$ that is equivalent to the branched form? What other functions like abs or min and other tricks can i use to achieve that 1 line explicit form? Or in my example is it even possible to find such A, B, C ? My example is just that, an example. I want to apply this on other functions. Thanks!

1

There are 1 best solutions below

2
On

We can use the indicator function to write for instance \begin{align*} f(x)&=|x-1|\\ &=(1-x)\mathbf{1}_{x\le 1}+(x-1)\mathbf{1}_{x> 1}\\ \\ &\qquad\qquad\text{or}\\ \\ g(x)&= \begin{cases} -2x+7&\qquad x<-10\\ x^{3}-2x^{2}+8&\qquad -10 \le x \le 3 \\ \ln (x+8)&\qquad x > 3 \end{cases}\\ \\ &=(-2x+7)\mathbf{1}_{x<-10}+(x^{3}-2x^{2}+8)\mathbf{1}_{-10 \le x \le 3}+\ln (x+8)\mathbf{1}_{x> 3} \end{align*} We can also use Iversion brackets to do the same job: \begin{align*} f(x)&=|x-1|\\ &=(1-x)[[x\le 1]]+(x-1)[[x> 1]]\\ \\ &\qquad\qquad\text{or}\\ \\ g(x)&= \begin{cases} -2x+7&\qquad x<-10\\ x^{3}-2x^{2}+8&\qquad -10 \le x \le 3 \\ \ln (x+8)&\qquad x > 3 \end{cases}\\ \\ &=(-2x+7)[[x<-10]]+(x^{3}-2x^{2}+8)[[-10 \le x \le 3]]+\ln (x+8)[[x> 3]] \end{align*}

Note that both, the indicator function as well as the Iverson brackets are sometimes conveniently used when doing calculations. Here we only need to focus on how to ease readability.