4
$\begingroup$

I can't get Solve to solve the following two equations under the appropriate assumptions.

When I enter

fs = I Cos[(s + t)/2] Sin[beta/2] - 1/2 Cos[beta/2] Sin[(s - t)/2]
ft = I Cos[(s + t)/2] Sin[beta/2] + 1/2 Cos[beta/2] Sin[(s - t)/2]
Solve[
  {fs == 0, ft == 0}, {s, t}, 
  Assumptions -> 
    Element[beta, Reals] && (beta > 0) && (beta < Pi/2) && 
      (s >= 0) && (s <= 2*Pi) && (t >= 0) && (t <= 2*Pi)
]

I get the following result:

{{s -> ConditionalExpression[π/2, Cos[beta/2] > 0 || Cos[beta/2] < 0], 
  t -> ConditionalExpression[π/2, Cos[beta/2] > 0 || Cos[beta/2] < 0]}, 
  {s -> ConditionalExpression[(3 π)/2, Cos[beta/2] > 0 || Cos[beta/2] < 0], 
  t -> ConditionalExpression[(3 π)/2, Cos[beta/2] > 0 || Cos[beta/2] < 0]}}

But I have told it that beta is real, that beta > 0 and beta < Pi/2. So why is it still putting a ConditionalExpression on the value of Cos[beta] being positive or negative?

$\endgroup$
2
  • $\begingroup$ Note that there is no need to add an assumption that a variable is real if you also add an inequality assumption on it: its participation in an inequality automatically implies that it is real. $\endgroup$
    – MarcoB
    Commented Sep 6, 2022 at 12:30
  • $\begingroup$ Solve eliminates assumptions from the conditions that are unnecessary but retains those that are necessary. It's not clear to me that in every use-case, one would want the necessary condition eliminated. When they can be, I use Simplify as @MarcoB shows below. (Another way to look at is that there is a difference between hypothesis Implies[A, B] and constraints A && B. Hypotheses may be ignored if B can be solved, though that is not what Mma usually does.) $\endgroup$
    – Michael E2
    Commented Sep 6, 2022 at 13:25

1 Answer 1

5
$\begingroup$

With your definitions of fs and ft, try this:

assumptions = {0 < beta < Pi/2, 0 <= s <= 2Pi, 0 <= t <= 2Pi};
Assuming[assumptions, Simplify@ Solve[{fs == 0, ft == 0}, {s, t}]]

(* Out: {{s -> π/2, t -> π/2}, {s -> (3 π)/2, t -> (3 π)/2}} *)

This will simplify the conditions away using the same assumptions you used for Solve. Note that this takes advantage of the fact that Solve now takes assumptions, a recent change in the language, but of course you are aware of that, since you were using it in your original code.

$\endgroup$
4
  • $\begingroup$ All right, thanks. But this is still disappointing though. Firstly, in your solution, Mathematica first has to solve the most general equation, and then only afterwards apply the constraints. It would be much more efficient, and indispensable for harder problems, to first apply the constraints and then solve the equation under those constraints. Secondly, it means Mathematica has a bug, since my code should have worked too. $\endgroup$ Commented Sep 6, 2022 at 15:53
  • $\begingroup$ @BruceBartlett - Using Assuming, the assumptions are used by any enclosed function that uses the option Assumptions. Consequently, this solution does exactly what your solution did for Solve. In addition, Assuming makes the assumptions available to the enclosed Simplify without having to repeat them. Solve does not automatically Simplify. $\endgroup$
    – Bob Hanlon
    Commented Sep 6, 2022 at 16:02
  • $\begingroup$ All right, that's good news, thank you. So Mathematica evaluates from outside-in? $\endgroup$ Commented Sep 6, 2022 at 16:15
  • $\begingroup$ @BruceBartlett Not quite. I would guess that Assuming temporarily changes the value of the $Assumptions global variable to whatever assumptions you give it. Code executing within Assuming will then pick up on those "temporary" global assumptions. Those are removed once execution is done. In other words, Assuming behaves more or less as the following: Block[{$Assumptions = assumptions}, Simplify@Solve[{fs == 0, ft == 0}, {s, t}]]. $\endgroup$
    – MarcoB
    Commented Sep 6, 2022 at 18:07

Your Answer

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

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