This question already has an answer here:

I have a question related to this post I made : Why is the function assuming not taken in consideration?

Consider the following code :

f[x_] := Sum[x^i, {i, 1, 10}]

Assuming[a > 0 && b > 0, Simplify[If[a + b != 0, f[x], 0]]]


f[x_] := x^2



When the function f is a sum, we don't have the simplification of the If, even if the function is not the condition of the If (but the output value if the condition is true).

However, when the function is $x^2$, the simplify works fine.

I don't understand the behavior in the first case, why isn't the simplification done ?

MichaelE2 explained me in the other question I asked that I have to put the simplify inside the sum and not outside to use the assumptions, else it doesn't work. But this is to simplify a Sum function. Here my simplification actually occurs to the condition of the If (so it is a different problem).

Could you explain me why my simplification doesn't occur ? I know I could do the simplification directly on the condition in the If but I want to understand what is the problem here.

And other question : when I apply simplify on a big expression, is the simplification done at all level of the expression ? It is not explained in the documentation of simplify.


marked as duplicate by Lukas Lang, m_goldberg, LCarvalho, bbgodfrey, J. M. is away Jan 6 at 2:52




Apply[If, {a + b != 0, f[x], 0}]
(*If[a + b != 0,x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10, 0]*)

Alternativly use Piecewise instead of If:

Piecewise[{{a + b != 0, f[x]}}, 0]
