4

Mathematica fails to do anything with

Reduce[Abs[x-3]<4, Reals]
(* Reduce[Abs[x-3]<4, Reals] *)

This answer contends that explicitly naming the variables to be reduced will solve the problem, and indeed

Reduce[Abs[x-3]<4, x, Reals]
(* -1 < x < 7 *)

But why is this the case? If either the absolute value is removed, or the < is changed to =, it is not necessary to provide the variable name.

rogerl
  • 4,209
  • 3
  • 27
  • 42

2 Answers2

5

After some back and forth with WRI, here is the answer: the domain restriction in Reduce[] applies to the specified variables and functions involving those variables. Since no variables are specified in my first example, the domain restriction effectively does nothing. That also explains why using {} does not solve the problem.

EDIT: After reading @Michael's comment below, I had more interactions with Wolfram support, and I am still somewhat confused. From WRI:


From Reduce documentation:

"Algebraic variables in expr free of the Subscript[x, i] and of each other are treated as independent parameters."

Since no Subscript[x, i] are specified, Reduce solves for the algebraic-level variables that are free of other algebraic-level variables.

In[1]:= Reduce`FreeVariables[x^2<4, "Algebraic"]
Out[1]= {x}

In[2]:= Reduce`FreeVariables[Abs[x-3]<4 && x\[Element]Reals, "Algebraic"]
Out[2]= {x}

In[3]:= Reduce`FreeVariables[Abs[x-3]<4, "Algebraic"]
Out[3]= {Abs[-3 + x]}

In[4]:= Reduce`FreeVariables[Re[x] > 0, "Algebraic"]
Out[4]= {Re[x]}

I guess the point is that x appears "algebraically" only in the first example; in the other examples it is the Abs or Re expression that is the "algebraic-level" variable.

This is still pretty unclear to me at a conceptual level (although I now know how to get the results I want), but I'm not sure what further questions to ask to clarify the situation. BTW, Reduce``FreeVariables is not documented.

rogerl
  • 4,209
  • 3
  • 27
  • 42
  • That was my first thought, which I put in a comment, but I deleted the comment after finding it was contradicted in the docs, the relevant parts of which I quote in my answer. Note that the Subscript[x, i] refer to the specified variables. The identification and treatment of the parameters seems explicit, deliberate and clear, which makes me think the techie that helped you didn't look thoroughly into the matter. It's happened to me before. Or the docs are wrong, but, as I said, the docs seem intentionally to make the point. – Michael E2 Jan 02 '20 at 14:47
  • @MichaelE2 Just tagging you so you see the edit to the answer. I'd appreciate any further insights. – rogerl Jan 06 '20 at 16:06
  • I think (guess) what they are saying is that Reduce[expr, vars, dom] is equivalent to something like Reduce[expr, Union[Reduce`FreeVariables[{expr, {vars}}, "Algebraic"], Flatten@{vars}], dom], where vars and dom may be omitted. Union is not quite right because the order of vars matters and the additional free variables ("parameters") are treated as though order does not matter, at least not in the same way (another guess). It seems the docs are incomplete, which is not that unusual unfortunately. They tend to leave out things most users don't need to know. – Michael E2 Jan 06 '20 at 16:55
  • 1
    If you haven't seen it, you might be interested in this Q&A – Michael E2 Jan 06 '20 at 17:01
  • 2
    @MichaelE2 What a rat's nest. I thought I was just asking a simple question... – rogerl Jan 06 '20 at 19:58
  • @MichaelE2 BTW, your proposed equivalence above doesn't seem to quite work. Compare Reduce[x y<4,{x},Reals], Reduce[x y<4,{y},Reals], Reduce[x y<4,{x,y},Reals] with your formulation with vars={x}. – rogerl Jan 06 '20 at 20:04
  • I know it's not quite right. That's what I meant by the 2nd half of the comment. Union sorts the variables, which messes up the order; the equivalent to Reduce[x y < 4, {x}, Reals] is Reduce[x y < 4, {y, x}, Reals]. The parameters should precede the variables. But even this is not completely correct. For instance Reduce[x^2 + w y^2 < z] is not identical to Reduce[x^2 + w y^2 < z, vars] for vars being {w, x, y, z} in any order. – Michael E2 Jan 06 '20 at 20:25
  • Hi @rogerl, I am the author of the question Michael linked to. I am still utterly puzzled by Reduce`FreeVariables. Something that I find disconcerting is that in a fresh kernel defining Reduce`FreeVariables[args__] := Null /; Print[{"FreeVar: ", args}], and then running something like Reduce[Abs[x-3]<4, x, Reals] reveals that Reduce doesn't even call `ReduceFreeVariables... so I don't know how WRI's response actually helps here. – QuantumDot Jan 07 '20 at 06:10
  • @QuantumDot So I'm pretty much out of my depth here as regards MMA knowledge. But if you want to follow up with WRI, my case number is CASE:4368640. I'd love to hear what the result is. – rogerl Jan 07 '20 at 13:19
3

I suspect Reduce treats the second argument as a variable. For instance:

Reduce[2 Reals == 1, Reals]
(* Reals == 1/2 *)

So I'm not sure there's anything wrong with

Reduce[Abs[x-3] < 4, Reals]
(* Reduce[Abs[x-3] < 4, Reals] *)

However, from the docs ("Details"):

Reduce[expr,vars,dom] restricts all variables and parameters to belong to the domain dom.
...
Algebraic variables in expr free of the Subscript[x, i] and of each other are treated as independent parameters.

I think this means that in Reduce[Abs[x-3]<4, {}, Reals], the x is not treated as a variable (to be solved for) but as a parameter, assumed to be real. Yet it still does not solve the inequality:

Reduce[Abs[x-3]<4, {}, Reals]
(* Abs[x-3]<4 *)

If you put the constraint in directly, you get the sought-after result:

Reduce[Abs[x - 3] < 4 && x \[Element] Reals, {}, Reals]
(* 1 < x < 7 *)

I would expect to get the same thing for Reduce[Abs[x-3]<4, {}, Reals], since x \[Element] Reals is supposed to be assumed.

It may be a bug and should be reported to WRI. See if they have an explanation.

Michael E2
  • 235,386
  • 17
  • 334
  • 747