Consider the following function:
test[x_, u_, v_] =
Piecewise[{{CosIntegral[ (-3 + u + v) x], u + v > 3},
{CosIntegral[ (-3 + u + v) x], u + v < 3},
{5, u + v == 3}}];
If I run:
Assuming[u + v == 3, Simplify[test[x, u, v]]]
Then I get the error "Simplify Expression CosIntegral[(-3+u+v)x] simplified to -Infinity". However, it should not be evaluating either of the first cases. This can be checked by running:
Simplify[u + v > 3 || u + v < 3, u + v == 3]
which evaluates to false (as it should). Hence, Mathematica shouldn't be evaluating the first two cases in the piecewise function, as it "knows" this isn't true (when you ask it to simplify the condition). However, despite Mathematica knowing this, it seems to not be using it, as running:
Assuming[u + v == 3, Refine[test[x, u, v]]]
returns CosIntegral[(-3+u+x)x] for u+v>3 || u+v<3 and 5 for True. So u+v>3 || u+v<3 is not getting evaluated to false here.
In this case, ignoring the error message is not too difficult. However, in my actual function, there are multiple CosIntegrals in the spurious cases, and this causes Mathematica to hang as it tries to evaluate them. However, there is no need to do that, since they only go to Infinities when u+v==3 which is a separate case.
How can I tell Mathematica to simplify the first conditions to false and so not evaluate the function value?
Thanks for the help.
Update: The second proposal (in the first answer) below fails on:
test[x_, u_, v_] =
Piecewise[{{CosIntegral[ (-3 + u + v) x]+1, u + v > 3},
{CosIntegral[ (-3 + u + v) x]-1, u + v < 3},
{5, u + v == 3}}];
and so, while helpful, isn't a general solution. (The first one, to ignore the error message, while helpful doesn't actually prevent Mathematica from evaluating the irrelevant cases.)