2

I have two eqution (blue / green), composed them using a simple if (black).

enter image description here

Blue: (2x)^2 / 2

Green: 0.5 + (1 - (2(1-x))^2) / 2

Black: (x < 0.5) ? (2x)^2 / 2 : 0.5 + (1 - (2(1-x))^2) / 2

See it in action on Fooplot: http://fooplot.com/plot/7knnh3zxis


Question is how can I simplify / extract the if statement?

Seemingly this is a single eqution offset by 0.5, 0.5 from the origin. Can someone shed a light on how to simplify this? I have some other similar equtions I am to simplify.

I'm not a math ninja, so explain with care if you can. :) Sorry if this is a noob question here at math.stackexchange.com, this is the first time I ask here.


UPDATE: I expressed as a single function, than it turned out that this all above can be simplified to a surprisingly simple function, like: -(4(x-0.5)abs((x-0.5))-4(x-0.5)-1)/2

See http://fooplot.com/plot/t5msqna67s

Geri
  • 123

2 Answers2

2

You can't write the whole function you have defined as a polynomial (sum of multiples of $x^n$). Your function is differentiable everywhere and piecewise a polynomial, but that doesn't mean that the function as a whole is a polynomial. To see this, note that your function's second derivative is discontinuous.

Although it's kind of cheating, you could write it as:

$$f(x):=\frac{2x^2}{2}+ U\left(x-\frac{1}{2}\right)\cdot \left[\frac{1}{2} + \frac{1 - (2(1-x))^2}{2} - \frac{2x^2}{2}\right]$$

with 'U' being the 'unit step': $U(x)=\left\{\begin{array}{ll}0 & x<0 \\ 1 & x \geq 0\end{array}\right.$

Note that some polynomials of degree 3 will have a similar shape to your function, but they will go off to infinity faster on their tail ends.

1

If you with extracting mean to replace the "if" with some function then you could use the following function:

$\displaystyle t(x)=\frac{x+|x|}{2\cdot x}$ which is equal to $ \;t(x)=\!\! \left\{ \begin{array}{l} 1 \quad\text{if } x>0\\ 0 \quad\text{if } x<0 \end{array} \right. $

In your example $f(x)=\text{blue}(x)\cdot t(x-0.5)+\text{green}(x)\cdot t(0.5-x)$.

Lehs
  • 13,791
  • 4
  • 25
  • 77
  • Yap, simply "weight" the two eqution actually. I think this is actually the answer, but it is seemingly less performant. – Geri Dec 01 '14 at 13:51
  • 1
    @Geri: In a computer program it is less time efficient. And also, $t$ is not defined for $x=0$. – Lehs Dec 01 '14 at 13:56