3
$\begingroup$

Downstream of a long process I got the following function:

$\begin{cases} 0 & x < 0 \, \vee \, x > \frac{307}{400} \\ 14.27-7.44\,x & 0 < x < \frac{307}{400} \\ \text{Indeterminate} & \text{True} \end{cases}$

I would like to know if you can delete the last case, without manual intervention, but with a code. I searched far and wide but could not find anything effective.

Thank you!

$\endgroup$
  • 2
    $\begingroup$ Maybe just do expr /. Intermediate -> 0? (Where expr is your function.) $\endgroup$ – march Jul 27 '16 at 16:53
  • 1
    $\begingroup$ @march /. Indeterminate -> 0 But yes, this works. $\endgroup$ – Feyre Jul 27 '16 at 17:02
  • 2
    $\begingroup$ @Feyre. I can't even blame autocorrect because I typed that on my computer. :) $\endgroup$ – march Jul 27 '16 at 17:04
  • $\begingroup$ So easy that it seems impossible functions and instead ... brilliant! Thank you! =) $\endgroup$ – TeM Jul 27 '16 at 17:21
3
$\begingroup$

This seems to be a good application for PiecewiseExpand:

f[x_] := Piecewise[{{1, x > 0}, {0, x < 0}, {Indeterminate, True}}]
f[x]

$$\begin{cases} 1 & x>0 \\ 0 & x<0 \\ \text{Indeterminate} & \text{True} \end{cases}$$

g[x_] := Piecewise[{{f[x], x != 0}, {0, True}}]
h[x_] = PiecewiseExpand[g[x]]

$$\begin{cases} 1 & x>0 \\ 0 & \text{True} \end{cases}$$

I split this up into steps just for illustration. The end result is the function h which has only the two relevant cases.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.