# Non-Piecewise Representation for Binary Switching Function

Suppose I have a function $f(x)$ defined as

$f(x) = \begin{cases} 1 & g(x) < A\\ 0 & g(x) \geq A \end{cases}$

Is it possible to define $f$ as a non piece wise function for $x,\; g(x),\; A \in \mathbb{R},\;> 0?$

For clarity, here's an example:

Suppose $A = 5,\;g(x) = x$

Can we formulate a non-piecewise version of the function:

$f(x) = \begin{cases} 1 & x < 5\\ 0 & x \geq 5 \end{cases}$?

• Could the person who downvoted explain what's wrong with my question? – Nathan Mar 30 '16 at 20:54
• I didn't downvote, but it is not clear what you are asking. – copper.hat Mar 30 '16 at 20:58
• @copper.hat, I've added an example, does this make it more clear? – Nathan Mar 30 '16 at 21:01
• Not really, I don't understand what you mean by 'formulate a non-piecewise version of the function'. The function is piecewise, so how can it not be??? Are you asking about notation? – copper.hat Mar 30 '16 at 21:02
• I was hoping there existed a trick to make the function switch from 0 to 1 at a value without involving a piecewise. – Nathan Mar 30 '16 at 21:04

$$f(x)=\frac{1+\text{sgn}(A-g(x))-[g(x)=A]}{2}$$ where $[g(x)=A]$ is a logic function having a value of 1 when the equation is true and a value of 0 when it is false.
• This answers my question, thanks! One question though: If $[g(x)=A]$ is 1 when true, 0 when false, why wouldn't $f(x) = [g(x) < A]$ work? – Nathan Mar 30 '16 at 21:13
• You are absolutely correct. The logic function approach did not even occur to me until I had to figure out how to get rid of the unwanted $\frac{1}{2}$ term which popped up when $g(x)=A$. So your answer is best. – John Wayland Bales Mar 30 '16 at 21:16