Conditioning two functions at a specific point

23 Views Asked by At

I'm trying to create a condition for functions $f$ and $g$ at point $a$, without using any conditional function/ending in a conditional function


What I mean by saying "conditioning functions $f$ and $g$ at point $a$" is:

h(x) =
    if (x < a):
        return f(x)
    if (x >= a):
        return g(x)

In other words, "do $f$ until reaching $a$; whenever $a$ has been reached, do $g$"


An example of conditioning a simple function, i.e. $|x|$:

We all know that $|x|$ is a conditional function - but we can write it unconditionally as well: $\sqrt{x^2}$ - Neither $x^2$ nor $\sqrt{x}$ are conditional; but we used them together to write the conditional function, $|x|$


I tried to play with some functions like $max$, but I didn't find the answer in the end anyway.

1

There are 1 best solutions below

6
On BEST ANSWER

You can just create your favorite conditional function and combine those. For example, consider the function $\mathbf{1}_{\geq a}$ where $\mathbf{1}_{\geq a}(x) = \begin{cases}1&\text{if }x\geq a\\0&\text{if }x<a\end{cases}$

Now just write $h(x) = \mathbf{1}_{\geq a}(x)\cdot g(x) + (1-\mathbf{1}_{\geq a}(x))\cdot f(x)$

But why do you not want to use a conditional function? Even "$\max$" is a conditional function.