2

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!

Margot_12
  • 23
  • 2

1 Answers1

1

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]
m_goldberg
  • 107,779
  • 16
  • 103
  • 257
  • 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 07 '18 at 22:44