0
$\begingroup$

Beside this specific problem I'm wondering if there's a more explicit way that I can understand when Solve and Reduce will find solutions. I find myself repeatedly getting stuck where I'll get positive and negative solutions for $x$ from Solve, add $x>0$ to the equations it's solving, and then get no solutions. Often specifying PositiveReals in Solve will return no solutions, even if there were no negative or nonreal solutions to begin with. I'm learning a lot by experimentation, but I don't feel like I'm coming to understand how these tools work.

I know part of the issue is that I've been unaware of how many assumptions I make when I work out problems by hand, but are there other factors that I can learn about?

First a CWE; I've removed units here for clarity and confirmed the behavior is the same.

g = 9.81; m = 2; ρ = 2; v0 = 6;

Solve[{
    Fw == m g,
    Fw Sin[Θ] == m an,
    an == v^2/ρ,
    -ρ g Sin[Θ] == 1/2 (v^2 - v0^2)
    }, {Θ, v, Fw, an}]]

yields $$\{\{\theta \to 0.658108,v\to -3.4641,\text{Fw}\to 19.62,\text{an}\to 6.\},\\\{\theta \to 0.658108,v\to 3.4641,\text{Fw}\to 19.62,\text{an}\to 6.\}\}$$ where the $v<0$ case should be eliminated.

Note that in each of these examples I've tried Solve, Reduce, Simplify, FullSimplify, v>0, and v ∈ PositiveReals

I've tried with the first line as

Assuming[v > 0, Simplify@Solve[{

which warned me about inverse functions, so I used Reduce and saw those extra solutions on the domain of $\sin^{-1}$. So I added a constraint

Assuming[{v > 0, 0 <= Θ < 2 π}, Simplify@Reduce[{

and I tried using without Assuming

FullSimplify[Reduce[{
   ...
   }, {Θ, v, Fw, an}], {v ∈ PositiveReals, 0 <= Θ < 2 π}]

Finally I connected the dots when adding $v>0$ as part of the system gave

$$\left\{\left\{\theta \to \text{ConditionalExpression}[6.28319 c_1+0.658108,c_1\in \mathbb{Z}],\\v\to \text{ConditionalExpression}\left[3.4641 \left(1\text{m}/\text{s}\right),c_1\in \mathbb{Z}\right]\right.\right.$$

so I solved the problem by including both $v>0$ and $0\leq\theta<\pi$ in the system, and discovered there were more solutions than I thought

$$\left\{\left\{\theta \to 0.658108,v\to 3.4641\text{m}/\text{s},\text{Fw}\to 19.62\text{N},\text{an}\to 6.\text{m}/\text{s}^2\right\},\\\left\{\theta \to 2.48349,v\to 3.4641\text{m}/\text{s},\text{Fw}\to 19.62\text{N},\text{an}\to 6.\text{m}/\text{s}^2\right\}\right\}$$

but then why didn't I get the $\theta \to 2.48349$ solution the first time, before adding any constraints? And why did none of the other methods eliminate the negative solution?

Finally, solving it this way (also with NSolve) warned that it wasn't able to solve with inexact coefficients. How can I give it exact values instead of silencing it?

Edit: The solution to the inexact coefficients warning is to change the first line with g=Rationalize[9.81];

It's clear I don't understand these tools well enough to get more than the very basics out of them. What is it that I don't know I don't know here?

$\endgroup$
5
  • 1
    $\begingroup$ "why didn't I get the θ→2.48349 solution the first time, before adding any constraints?" Well, Solve EXPLICITLY warned you that "Inverse functions are being used by Solve, so some solutions may not be found". So you would attempt Reduce as the warning says. Reduce would tell you that "Reduce was unable to solve the system with inexact coefficients". So then you would rationalize your g (e.g. g = 981/100) and Reduce would work without a hitch. Going back to Solve with the rationalized system would show four solutions now, just by following the instructions in the warnings. $\endgroup$
    – MarcoB
    May 4 '20 at 23:15
  • $\begingroup$ If you then add the constraint that v >=0 to that last Solve system, it reduced the number of solutions to two, including periodic conditions. You could then set C[1] to e.g. zero to get an instance of the solution (e.g. Solve[...] /. C[1] -> 0). $\endgroup$
    – MarcoB
    May 4 '20 at 23:19
  • $\begingroup$ FWIW: the error messages are not always instructive, but this is one of those cases where you really should have paid attention to them. $\endgroup$
    – J. M.'s torpor
    May 5 '20 at 1:12
  • $\begingroup$ @MarcoB I see your point, but actually in my original problem, which is exactly as written here but with units, Solve does not warn that inverse functions are being used. It returns the two solutions I listed first with no other message. $\endgroup$ May 5 '20 at 1:44
  • $\begingroup$ I did find that adding the inequalities to the Solve equations fixed it, and I found that by following the error messages. My confusion is that another issue I had was resolved by adding a constraint in Simplify, but here that has no effect. $\endgroup$ May 5 '20 at 1:52
3
$\begingroup$

Along with the equations, include the inequalities as constraints

g = 9.81; m = 2; ρ = 2; v0 = 6;

sol = Solve[{Fw == m g, Fw Sin[Θ] == m an, an == v^2/ρ,
    -ρ g Sin[Θ] == 1/2 (v^2 - v0^2),
    v > 0, 0 <= Θ < 2 Pi}, {Θ, v, Fw, an}] // 
  Quiet

(* {{Θ -> 0.658108, v -> 3.4641, Fw -> 19.62, 
  an -> 6.}, {Θ -> 2.48349, v -> 3.4641, Fw -> 19.62, an -> 6.}} *)

sol /. x_Real :> RootApproximant[x]

(* {{Θ -> π - ArcSin[200/327], v -> 2 Sqrt[3], Fw -> 981/50, 
  an -> 6}, {Θ -> ArcSin[200/327], v -> 2 Sqrt[3], Fw -> 981/50,
   an -> 6}} *)

Or

sol = Solve[{Fw == m g, Fw Sin[Θ] == m an, an == v^2/ρ,
    -ρ g Sin[Θ] == 1/2 (v^2 - v0^2),
    v > 0, 0 <= Θ < 2 Pi} // Rationalize, {Θ, v, 
   Fw, an}]

(* {{Θ -> π - ArcSin[200/327], v -> 2 Sqrt[3], Fw -> 981/50, 
  an -> 6}, {Θ -> ArcSin[200/327], v -> 2 Sqrt[3], Fw -> 981/50,
   an -> 6}} *)
$\endgroup$
1
  • $\begingroup$ I didn't know I can just rationalize the whole equation like that, thanks! That has fixed a bunch of instances where I was using Quiet. $\endgroup$ May 5 '20 at 2:05

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.