# How to assume that the sum of two functions is identically zero (independently from the chosen variables)?

I have met this problem and I do not know how to get rid of it. The problem is the following. I have defined a function h as sum of two functions f and g as follows:

h[x_, y_] := f[x, y] + g[x, y];

then, I have assumed that h is identically zero, that is,

$Assumptions = h[x_, y_] == 0; Then, if I choose the variables, for instance, Simplify[h[x_, y_] /. x -> z]; The output I obtain is 0 However, if I write Simplify[(h[x_, y_] /. x -> z) + 3] then the output is 3 + f[z_, y_] + g[z_, y_] but I want 3 instead. In other words, I would like that any time the function h appears it is considered as equal to zero independently from the choice of the variables. I really cannot understand why it does not work. I hope that someone can help me fix this. Thank you in advance! • How about adding the definition h[x_,y_]=0? – mikado Mar 3 '18 at 18:12 • Related: (42607), (131515), (141973) – Michael E2 Mar 4 '18 at 18:00 • Do you want to simplify h[x_, y_] /. x -> z or h[x, y] /. x -> z? – Michael E2 Mar 4 '18 at 18:16 ## 2 Answers If this does not answer your question, then treat it as a request for clarification. I can't see what you are trying to accomplish with your code. If you are attempting to assume that h is identically zero for all variables, that is equivalent to defining h[x_, y_] := 0  which would replace the previous definition h[x_, y_] := f[x, y] + g[x, y]  rendering ir nor only irrelevant but null and void. To show this, let's do it in a local scope so that it doesn't affect your top-level definitions. Block[{h}, h[x_, y_] := f[x, y] + g[x, y]; h[x_, y_] = 0; h[u, v] + 3]  3 Note that there is no need to introduce Simplify. Any call of h now evaluates to 0. If your goal is to temporarily assume h is identically zero for the purpose of a specific evaluation, then Block is what you want. For example: Block[{h}, h[x_, y_] = 0; Sqrt[h[u, v]] + 3]  3 ### Update This discussion is added to address the clarification given by the OP in a comment to this answer. If you require f[x, y] + g[x, y] "in the code, it put it equal to zero independently from the variables inside", you are mathematically requiring that$g \equiv -f\$, so just write and evaluate

g[x_, y_] := -f[x, y]


Then

  1 + 3 f[x, y] + 2 g[x, y]

1 + f[x, y]

  1 + 2 f[x, y] + 3 g[x, y]

1 - f[x, y]

• Thanks for your answer. I think my question is a little bit confusing. I try to explain it better. I would like that every time that I encounter an expression like f[x_,y_]+g[x_,y_] in the code, it put it equal to zero independently from the variables inside. – Margot_12 Mar 7 '18 at 22:44

It is unclear to me whether the intended expression to be simplified was the OP's literal

3 + f[z_, y_] + g[z_, y_]


or

3 + f[z, y] + g[z, y]


The first is a pattern, and it is highly usual to simplify a pattern, since patterns are used to match code text, not things that are algebraically equivalent. My inclination is to assume the second is the form to be simplified.

In that case, one can try to cull from it the expressions of the form h[x, y] and construct an assumption h[x, y] == 0 for each of them. It seems to work in this case, but rewriting algebraic expression is sometimes complicated. It would probably be more robust to cull the expressions of the form f[x, y] and construct the assumption f[x, y] == -g[x, y]. Be that as it may, here is the first approach:

expr2 = (h[x, y] /. x -> z) + 3;
expr1 = (h[x, y] /. x -> z);
With[{expr = {expr1, expr2}},
Assuming[
Cases[expr, h[x_, y_] + rest___ :> h[x, y] == 0, {0, Infinity}],
Simplify[expr]
]]

(*  {0, 3}  *)


For the expression as it is written in the OP, one should beware that patterns have a life of their own when they find themselves inside an internal pattern-matching function. Having Blank in the assumptions appears to interfere with Simplify's ability to use them. To get the original expression to simplify, I had to remove Blank temporarily and replace it after simplification.

expr2 = (h[x_, y_] /. x -> z) + 3;
expr1 = (h[x_, y_] /. x -> z);
inactivateBlank[e_] := e /. Blank -> "Blank";
activateBlank[e_] := e /. "Blank" -> Blank;
With[{expr = inactivateBlank[{expr1, expr2}]},
Assuming[
Cases[expr, h[x_, y_] + rest___ :> h[x, y] == 0, {0, Infinity}],
Simplify[expr] // activateBlank
]]

(*  {0, 3}  *)