2

I want to write the following condition for $x\ge 0$ $$y=\begin{cases}y=x&\text{if }y>0\\y=a\neq0&\text{if }x=0\end{cases}$$

The reason is because I have a function on the form $F(x)=f(x)/x$ and I want it to be zero when $x=0$ but without using cases so, there is a way to write that condition within one line?

AlephZero
  • 750
  • You tagged the question as programming but in that case the answer likely depends on the language used. – dxiv Apr 07 '17 at 18:56

2 Answers2

1

For your specific case, this might work: $$ F(x) = \begin{cases} f(x)/x &\textrm{if $x \neq 0$} \\ 0 &\textrm{if $x = 0$} \end{cases} $$ can be written $$ F(x) = \frac{f(x)}{x + (x \:\texttt{==}\: 0)} \cdot (x\:\texttt{!=}\:0) $$ where $(x\:\texttt{==}\:0)$ denotes the boolean expression that returns $1$ if $x=0$ and $0$ else; and $(x\:\texttt{!=}\:0)$ is the reverse. Depending on the language, you might need to write $\operatorname{\texttt{float}}(x\:\texttt{==}\:0)$ or something like that to convert booleans to a number-like data type.

More generally, if you want a function $g$ that does this: $$ g(x) = \begin{cases} x &\textrm{if $x \neq 0$} \\ a &\textrm{if $x = 0$} \end{cases} $$ you could do $$ g(x) = x(x\:\texttt{!=}\:0) + a(x\:\texttt{==}\:0) $$ Although I don't think doing $g(F(x))$ for your $F$ would work, because at $x = 0$ you'd get a division by zero, which could lead to unstable arithmetic.

WB-man
  • 2,508
0

There is probably no "standard" way to condense it. A safe way is to write something like "Let $F: x \mapsto 0$ if $x = 0$ and $x \mapsto$ 'a given correspondence rule involving $x$' if $x > 0$". The key here is employing the symbol "$\mapsto$", which helps.

Yes
  • 20,719