2
$\begingroup$

I am trying to solve a system of five equations and five variables w.r.t. one of them. I do not understand I obtain the empty set if I try to solve

Solve[x+y==s && x==p*Cos[a] && y==q*Cos[b] && h^2+x^2==p^2 && h^2+y^2==q^2 && 0<a<\[Pi]/4 && 0<b<\[Pi]/4, {x}, Reals]

However, if I reduce the above equality system to a simple quadratic equation in $x$, I obtain a non-empty solution set:

Solve[(1/(Cos[a]^2))*x^2+(1+1/(Cos[b]^2))*s*x-s^2==0 && 0<a<\[Pi]/4 && 0<b<\[Pi]/4, {x}, Reals]

Please find attached this screenshot:enter image description here

Could you please help me to understand where is the error?

$\endgroup$
0

1 Answer 1

4
$\begingroup$

You have five equations and specify only one unknown, the rest of the variables being treated as parameters. Solve does better if the number of unknowns equals the number of equations (not a strict requirement perhaps, though in many cases, such as this one, it seems necessary):

Solve[x + y == s && x == p*Cos[a] && y == q*Cos[b] && 
  h^2 + x^2 == p^2 && h^2 + y^2 == q^2 && 0 < a < \[Pi]/4 && 
  0 < b < \[Pi]/4, {x}, {y, p, q, h}, Reals]

Mathematica graphics

$\endgroup$
5
  • $\begingroup$ Thank you! I was expecting an answer from Mathematica in terms of $s, a, b$, but I now read the numerical answer $45.8559$. Why? $\endgroup$ Commented Oct 23, 2022 at 13:23
  • 1
    $\begingroup$ @PenelopeBenenati You're welcome. :) If you get a numerical answer, I think it must be because you set the variables equal to some numbers. It's never happened to me otherwise. $\endgroup$
    – Michael E2
    Commented Oct 23, 2022 at 13:27
  • 1
    $\begingroup$ @PenelopeBenenati Note his image includes //AbsoluteTiming, which is used to report the time cost of the evaluation. 45.8559 means that Solve cost 45.8559 seconds $\endgroup$
    – rnotlnglgq
    Commented Oct 23, 2022 at 13:36
  • 1
    $\begingroup$ @rnotlnglgq Thanks, I misread/misunderstood Penelope's comment. I included the timing to warn folks it takes a long time. $\endgroup$
    – Michael E2
    Commented Oct 23, 2022 at 13:39
  • $\begingroup$ Simplify gives a cleaner result; i.e., Assuming[0 < a < \[Pi]/4 && 0 < b < \[Pi]/4, Solve[x + y == s && x == p*Cos[a] && y == q*Cos[b] && h^2 + x^2 == p^2 && h^2 + y^2 == q^2, {x}, {y, p, q, h}, Reals] // Simplify] $\endgroup$
    – Bob Hanlon
    Commented Oct 23, 2022 at 14:28

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.