Can I combine two functions (express them as a single function) where they meet a certain criteria at different times.

156 Views Asked by At

Say I have a function $F(x) = 7x$. That meets my criteria when $0 \leq x \leq 10$.

And another function $G(x) = x^2$. That meets my criteria when $x > 10$.

Is there a way to combine these two into one function?

1

There are 1 best solutions below

2
On

One way to do this is to define a piecewise function like N. F. Taussig said in the comments above. However I have my own alternative way of defining such funcion, using the properties of floor and ceiling functions.

First notice one special function that I found:

$$y=\Bigg\lceil\frac{\lfloor x\rfloor}{x}\Bigg\rceil$$

What's special about it is that it outputs 0 for all numbers between zero and one, and one for the rest of numbers.

We can invert the behavior of this function by negating it and adding one. This will output one for the range of 0 to 1, and zero for other numbers.

$$y=-\Bigg\lceil\frac{\lfloor x\rfloor}{x}\Bigg\rceil+1$$

Now we can stretch this by ten dividing x by 10 everywhere:

$$y=-\Bigg\lceil\frac{10\lfloor {x\over10}\rfloor}{x}\Bigg\rceil+1$$

Now we simply multiply this by 7x, our function between 0 and 10.

$$y=-7x\Bigg\lceil\frac{10\lfloor {x\over10}\rfloor}{x}\Bigg\rceil+7x$$

This is one part of our function, now we do the similar thing with the second part, except this time we want our special floor-ceiling function to be 1 everywhere except in the range 0 to 10, so we do:

$$y=\Bigg\lceil\frac{10\lfloor {x\over10}\rfloor}{x}\Bigg\rceil$$

We simply multiply this part by our second function, $x^2$:

$$y=x^2\Bigg\lceil\frac{10\lfloor {x\over10}\rfloor}{x}\Bigg\rceil$$

Now, when we got two parts of the final function. We simply add them together to get:

$$f(x)=x^2\Bigg\lceil\frac{10\lfloor {x\over10}\rfloor}{x}\Bigg\rceil-7x\Bigg\lceil\frac{10\lfloor {x\over10}\rfloor}{x}\Bigg\rceil+7x$$

There it is, an alternative definition of piecewise function. Now there are some tweaks we could add to make this better, for example make this defined at 0, because now it isnt, and make negatives undefined. However this will nee some more playing with floor, ceiling, square root, and modulo functions.

The best way is to simply define a piecewise function, but alternative I presented is also an interesting one.

Edit: here's a graph of the function: http://www.wolframalpha.com/input/?i=y%3Dx%5E2%5Clceil%5Cfrac%7B10%5Clfloor+%7Bx%5Cover10%7D%5Crfloor%7D%7Bx%7D%5Crceil-7x%5Clceil%5Cfrac%7B10%5Clfloor+%7Bx%5Cover10%7D%5Crfloor%7D%7Bx%7D%5Crceil%2B7x+from+0+to+20