6
$\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
  • 3
    $\begingroup$ Assuming[w > 1/2 && P < 1, FullSimplify@Reduce[P + f (-1 + P) (-1 + 2 w) > 0]]? $\endgroup$
    – kglr
    Aug 10 '18 at 12:11
  • $\begingroup$ Oh dear. That was beautiful! $\endgroup$
    – user120911
    Aug 10 '18 at 12:17
11
$\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$
5
$\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$

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.