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?
Solve
EXPLICITLY warned you that "Inverse functions are being used by Solve, so some solutions may not be found". So you would attemptReduce
as the warning says.Reduce
would tell you that "Reduce was unable to solve the system with inexact coefficients". So then you would rationalize yourg
(e.g.g = 981/100
) andReduce
would work without a hitch. Going back toSolve
with the rationalized system would show four solutions now, just by following the instructions in the warnings. $\endgroup$v >=0
to that lastSolve
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$