8
$\begingroup$

I have the following code that includes Assuming to cut through irrelevant detail, or so I had hoped.

Assuming[w > 1/2 && P < 1, Reduce[P + f (-1 + P) (-1 + 2 w) > 0]]

To my detriment Mathematica generates an output whose first condition is $w<\frac{1}{2}$

How can I get Mathematica to use my assumptions to focus on only those values that apply within those assumptions?

$\endgroup$
2
  • 4
    $\begingroup$ Assuming[w > 1/2 && P < 1, FullSimplify@Reduce[P + f (-1 + P) (-1 + 2 w) > 0]]? $\endgroup$
    – kglr
    Aug 10, 2018 at 12:11
  • 1
    $\begingroup$ Oh dear. That was beautiful! $\endgroup$
    – user120911
    Aug 10, 2018 at 12:17

4 Answers 4

12
$\begingroup$

Assuming >> Details:

  • Assuming affects the default assumptions for all functions that have an Assumptions option.

Assumptions is not an option for Reduce:

Options[Reduce]

{Backsubstitution -> False, Cubics -> False, GeneratedParameters -> C, Method -> Automatic, Modulus -> 0, Quartics -> False, WorkingPrecision -> ∞}

You can wrap Reduce with FullSimplify:

Assuming[w > 1/2 && P < 1, FullSimplify@Reduce[P + f (-1 + P) (-1 + 2 w) > 0]]

f (-1 + P + 2 w - 2 P w) < P

$\endgroup$
8
$\begingroup$

There is a warning in the docs for FullSimplify:

Some of the transformations used by FullSimplify are only generically correct.

It's also true for Simplify (e.g. Simplify[Sin[Pi x]/x == 0, x ∈ Integers]). Often one uses Reduce to avoid such errors.

One way to introduce assumptions in Reduce is to include them as constraints:

Assuming[w > 1/2 && P < 1, 
 Reduce[$Assumptions && P + f (-1 + P) (-1 + 2 w) > 0]]
(*  w > 1/2 && P < 1 && f < -(P/(1 - P - 2 w + 2 P w))  *)
$\endgroup$
3
$\begingroup$

As mentioned by @kglr (+1) Reduce will ignore the conditions in Assuming but FullSimplify will use them.

Composition[
  MemberQ[Assumptions],
  Keys,
  Options
  ] /@ {Reduce, FullSimplify}
(* {False, True} *)

Another option would have been to incorporate your assumptions into the expression to Reduce.

Reduce[
 And @@ {
   P + f (-1 + P) (-1 + 2 w) > 0,
   w > 1/2,
   P < 1
   }
 ]
(* w > 1/2 && P < 1 && f < -(P/(1 - P - 2 w + 2 P w)) *)
$\endgroup$
1
$\begingroup$

The perfect method is written as follows.

Reduce[expr && $Assumptions, vars] // Simplify

(e.g. Reduce for $e^a>1$, whose result is $a>0$) Step by step demonstration

This way is much better than the Reduce[...]//Simplify way, which also exerts the global $Assumptions, but costs much more efforts and may bring about failure. That's because in Reduce part it tries to find all the possible solutions in the whole domain of vars, which is totally not necessary if you assign (e.g.)a>=0. Even worse is it's too heavy-loaded for Mathematica to give a result, and then it gives up. But my way of using $Assumptions in *expr* part of Reduce tells it not to search in the other region.

The Trace functions shows this: enter image description here

A very simple example in which Reduce fails but reduce succeeds: enter image description here

$\endgroup$

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.