Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When using Reduce, I accidentally put a set of variables as the domain. To my surprise, it not only seems that Reduce expects this sort of input, but I found the output to be very useful.

Let me explain with an example. In a system of equations with multiple variables, I am often interested in the conditions placed on certain variables. Suppose I have x + y == 1 && x y == 2 and want to know what conditions this places on x. Normally, I would do this:

In[1]:= Reduce[x + y == 1 && x y == 2, x]
Out[1]= (y == 1/2 (1 - I Sqrt[7]) || y == 1/2 (1 + I Sqrt[7])) && x == 1 - y

This output is not in the best form for what I want. Namely, Reduce has given me specific values for y and then expressed x and a function of y. I would have preferred if this had been the other way around, then I would have exactly what I want after ignoring y. (Oddly enough, Reduce gives specific values for x and expresses y as a function of x if you ask it to solve for y.)

Recently, I was working with a system of equation like this and accidentally put the other variables (in this case, just the variable y) as the domain.

In[2]:= Reduce[x + y == 1 && x y == 2, x, {y}]
Out[2]= x == 1/2 (1 - I Sqrt[7]) || x == 1/2 (1 + I Sqrt[7])

Fantastic! This is exactly what I was looking for: the constraints placed on x. As far as I can tell, this behavior is not described in the documentation for Reduce.

Question:

Is this expected behavior from Reduce? If so, where is this behavior described?

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

If you enter a bare Symbol as the third argument you get an illuminating Message:

Reduce[x + y == 1 && x y == 2, x, y];

Reduce::bdomv: Warning: y is not a valid domain specification. Mathematica is assuming it is a variable to eliminate. >>

This is analogous to the syntax of Solve:

Solve[eqns, vars, elims]
attempts to solve the equations for vars, eliminating the variables elims.

I have been using this syntax for a long time so I was surprised to find that it is missing from the current documentation. A bit of searching shows that it was a documented syntax in version 4 (and earlier):

Reduce[eqns, vars, elims] simplifies the equations, trying to eliminate the variables elims.

Why this was left out of later documentation is a mystery to me.

share|improve this answer
3  
It was changed to be a domain spec. When it is clearly NOT a domain spec then it reverts to the version <=4 interpretation as variables to eliminate. Possibly that should be an option rather than an optional argument, so as to avoid this ambiguity (and lack of ducumentation). Not my call though. –  Daniel Lichtblau Jan 28 at 17:41
    
@Daniel Thanks for the explanation. If this is a deprecated syntax how is the operation intended to be written now? –  Mr.Wizard Jan 28 at 23:40
    
I, umm, don't know. Sorry about that. –  Daniel Lichtblau Jan 29 at 16:21
add comment

There are all sorts of nuggets like this, search the site for "undocumented". Who knows why something like this example works this way...it appears to invoke refinement of the result. Try, e.g., the second of these various forms,and the last which also causes a different refinement:

Reduce[x + y == 1 && x y == 2, {y}]
Reduce[x + y == 1 && x y == 2, {y}] // Refine[#, Last[#]] &
Reduce[x + y == 1 && x y == 2, {x}, {y}]
Reduce[x + y == 1 && x y == 2, {x}, Complexes]
Reduce[x + y == 1 && x y == 2, {x}, {Complexes}]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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