Using the following code, I got the first two piecewise equations right but the third one returns -99.
Clear[x];
{PiecewiseExpand[Which[x < -1, -1, x < 1, x, True, 1]],
PiecewiseExpand[If[x < -1, -1, If[x < 1, x, 1]]],
PiecewiseExpand[If[x < -1, -1, If[x < 1, x, 1], -99]]}
Similarly, the third one always returns -99 when I use the following code.
{Which[x < -1, -1, x < 1, x, True, 1],
If[x < -1, -1, If[x < 1, x, 1]],
If[x < -1, -1, If[x < 1, x, 1], -99]} /. {{x -> 3/5}, {x -> n}}
However, things turn correct if I use
x = 3/5; {Which[x < -1, -1, x < 1, x, True, 1],
If[x < -1, -1, If[x < 1, x, 1]], If[x < -1, -1, If[x < 1, x, 1], -99]}
x = n; {Which[x < -1, -1, x < 1, x, True, 1],
If[x < -1, -1, If[x < 1, x, 1]],
If[x < -1, -1, If[x < 1, x, 1], -99]}
What's wrong with the third equation If[x < -1, -1, If[x < 1, x, 1], -99]?
If[x < -1, -1, If[x < 1, x, 1], -99]/.{x->10}doesn't work? – Richard Sep 09 '21 at 19:53If[x < -1, -1, If[x < 1, x, 1], x^2] /. {x -> -2}. The result is 4. No matter what value is assigned to x, I can never get -1 or x--it's always x^2. However, if completely remove x^2 and usef[x < -1, -1, If[x < 1, x, 1]] /. {x -> -2}, the result is -1, which is correct. It seems something is wrong with the neither TRUE nor FALSE value of x^2. What is the problem? – Richard Sep 09 '21 at 21:22Examples / Scope / Evaluation. – Rohit Namjoshi Sep 10 '21 at 02:16