1
$\begingroup$

In a recent question I posed, it was noted that by design, Sqrt[ blah] only returns the positive branch, even though we might want to obtain all possible symbolic solutions. So, taking care to avoid the Sqrt function here in my input :), suppose I am interested to find the intervals that, when squared, generate the Interval[{0,4}]:

Solve[Interval[{0, 4}] == y^2, y]

This returns:

{{y -> Interval[{-2, 0}]}, {y -> Interval[{0, 2}]}}

How should we then obtain the missing solution:

expr = Interval[{-2, 2}];  expr^2
Interval[{0, 4}]

… that nests all others?

[P.S. I suppose a Union applied to the output might do the trick, but I'm not sure a trick is the real point to the question.]

$\endgroup$
3
  • 1
    $\begingroup$ I don't understand you. There doesn't seem to be a "missing solution", just another way of rewriting the other two ForAll[y, IntervalMemberQ[Interval[{-2, 0}], y] || IntervalMemberQ[Interval[{0, 2}], y], IntervalMemberQ[Interval[{-2, 2}], y]] $\endgroup$ Apr 21, 2013 at 19:15
  • $\begingroup$ Are you suggesting that if Solve[blah] returns the solution set {A,B}, ... it should be interpreted as A Or B Or Union[A,B] ? $\endgroup$
    – wolfies
    Apr 21, 2013 at 19:47
  • 1
    $\begingroup$ Here's a very similar question: mathematica.stackexchange.com/questions/11345/… $\endgroup$ Apr 22, 2013 at 15:36

1 Answer 1

5
$\begingroup$

Use inequalities, as Reduce knows how to work with those.

Reduce[0 <= y^2 <= 4, y, Reals]

(* Out[9]= -2 <= y <= 2`*)

Interval[] resides mostly in the arithmetic/numerical world, and symbolic solving with those will at best, in general, give an overestimated result (that is, one that properly contains the actual result). Here is an example. We first show that if -1<=x<=1 then -1/4<=x^2+x<=2.

Minimize[{x^2 + x, -1 <= x <= 1}, x]

(* Out[12]= {-(1/4), {x -> -(1/2)}} *)

Maximize[{x^2 + x, -1 <= x <= 1}, x]

(* Out[13]= {2, {x -> 1}} *)

Now try to recover this with Solve.

Solve[x^2 + x == Interval[{-1/4, 2}], x]

(* Out[14]= {{x -> Interval[{-2, -(1/2)}]},  {x -> Interval[{-(1/2), 1}]}} *)

The interval from -2 to 1 properly contains the one from -1/4 to 1.

Here is another variation. We set x to the interval from -1 to 1. We showed above that x^2+x lies between -1/4 and 2. The interval for 'y` below properly contains this.

Solve[{y == x^2 + x, x == Interval[{-1, 1}]}, {x, y}]

(*  Out[15]= {{x -> Interval[{-1, 1}],   y -> Interval[{-2, 2}]}}  *)
$\endgroup$
2
  • $\begingroup$ Fixed minor typo: x^2-x > x^2+x .... Interestingly, stackexchange wouldn't allow the edit because it was less than 6 characters, which seems a bit artificial for a math site. All that was needed was 1 character (+ some ....... to get around the limit). Thanks for the interesting post, Daniel! $\endgroup$
    – wolfies
    Apr 22, 2013 at 15:22
  • $\begingroup$ Heh. It just now let me add a (needed but missing) comma. I guess I was lucky. $\endgroup$ Apr 22, 2013 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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