Can someone please explain the following phenomenon to me?

I am using Refine to evaluate a symbolic Max expression with a condition that explicitly states which of the inputs is the maximum, like this:

Refine[Max[0, 1/b - a1 - a2 - a3],  1/b - a1 - a2 - a3 > 0 && b > 0]

which correctly yields 1/b - a1 - a2 - a3. Now if I add another variable to the sum:

Refine[Max[0, 1/b - a1 - a2 - a3 - a4],  1/b - a1 - a2 - a3 - a4 > 0 && b > 0]

suddenly the Refine command fails and simply states Max[0, 1/b - a1 - a2 - a3 - a4]. This confuses me as Mathematica is generally quite strong with symbolic simplifications and here I outright state the supposed result.

Another peculiarity is that the process works again if instead of 1/b I simply use b:

Refine[Max[0, b - a1 - a2 - a3 - a4], b - a1 - a2 - a3 - a4 > 0 && b > 0]
(* -a1 - a2 - a3 - a4 + b *)

I tried Simplify, FullSimplify, Reduce (with 0 < 1/b - a1 - a2 - a3 - a4 instead of the Maxexpression) alone and in conjunction with Refine. Is this a software limitation? And if so, can I work around this? I wouldn't see a mathematical reason for this behavior.

I am using Mathematica 12.0.

By the way, I am well aware that this refinement has no use what so ever. I just stumbled across this during an attempted generalization, which failed after adding more variables to the mix.

  • $\begingroup$ well, you can always introduce a new variable $z=1/b-a_1-a_2-...$ so that the condition simply reads $z>0$. E.g., With[{a1 = (1 - a2 b - a3 b - a4 b - b z)/b}, Refine[Max[0, 1/b - a1 - a2 - a3 - a4], 1/b - a1 - a2 - a3 - a4 > 0 && b > 0]] /. z -> 1/b - a1 - a2 - a3 - a4 // Simplify. $\endgroup$ – AccidentalFourierTransform Jan 21 at 14:59
  • $\begingroup$ @AccidentalFourierTransform True, as a workaround that'll do in this case. However, I have the feeling that this phenomenon will also strike if the expression inside Max or the assumption becomes a bit more complicated or at least if they are not the exact same. Any idea, why this is happening in the first place? $\endgroup$ – niak Jan 21 at 15:45

Unfortunately, the choice of variable names affects whether or not Simplify or FullSimplify will successfully simplify an expression (see the last example in the "Possible Issues" section of the documentation on Simplify).

If you use {x, y, z, t} rather than {a1, a2, a3, a4}, Simplify can correctly evaluate your 5-variable comparison:

In[1]:= Simplify[Max[0, 1/b - x - y - z - t],  1/b - x - y - z - t > 0 && b > 0]
Out[1]= (1 - b (t + x + y + z))/b

For more on this, it may be helpful to take a look at these two threads: (1, 2) (especially Szabolcs comment on the question in the second one)

  • $\begingroup$ Wow, I did not know that the variable names have such an impact. Thanks also for the references! Do you know why the renaming only works with Simplify, but not Refine? According to the manual Refineshould show what an expression looks like if any numerical input was chosen that satisfies the assumption. Regardless of the variable names, any combination of numbers fulfilling the assumption would naturally result in 1/b - x-... being larger than 0. Or does Mathematica also only use symbolic tricks in the background, prone to the same limitations? $\endgroup$ – niak Jan 21 at 17:16
  • $\begingroup$ In this instance Refine is interpreting the variables as nonlinear (because of the 1/b). If you enter SystemOptions["SimplificationOptions"], it shows that the default for "AssumptionsMaxNonlinearVariables" is 4. If you increase this, say, to 5 by calling: SetSystemOptions[ "SimplificationOptions" -> "AssumptionsMaxNonlinearVariables" -> 5], then Refine will be also able to evaluate the re-named expression. $\endgroup$ – Tim Wagner Jan 21 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.