# Solving equations with trigon functions NSolve, FindRoot

I have a simple equation:

(Sin[ϕ] Cos[xx])/Sin[xx] == 0.75


If I try:

NSolve[(Sin[ϕ] Cos[xx])/Sin[xx] == 0.75, xx, Reals]


I get

NSolve::ratnz: NSolve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>
{{xx -> ConditionalExpression[1. (-2.57352 + 6.28319 C),
C ∈ Integers]}, {xx ->
ConditionalExpression[1. (0.568075 + 6.28319 C),
C ∈ Integers]}}


For this one in particular, I have to use FindRoot. Why?

The problem I get is with this one:

aaLow = 53.*Degree;
ϕ = 28.6*Degree;
faa[δ_, ha_] := Module[{sigCot, sigSin, aa, res},
If[Sin[ha] == 0,
(* avoid singularities *)
res = 2 π - ha;,
aa = (Tan[δ] Cos[ϕ] - Sin[ϕ] Cos[ha])/Sin[ha];
(* determine the necessary signs to get quadrant *)
sigCot = Sign[aa];
sigSin = -Sign[Sin[ha]];
aa = Abs@ArcCot[aa];
Switch[
{sigSin, sigCot},
{1, 1}, res = aa,
{1, -1}, res = π - aa,
{-1, 1}, res = π + aa,
{-1, -1}, res = 2 π - aa
];
];
res
];


When I try:

FindRoot[faa[0.5, z]== aaLow, {z, 0.5}]


I get

FindRoot::nlnum: "The function value {-0.925025+res$8084} is not a list of numbers with dimensions {1} at {z} = {0.5}">>  Not even FindRoot[faa[0, z], {z, 0.5}]== aaLow which should reduce to the first example (except the right hand side). What am I doing wrong when trying to get the solution? Some more notes, δ∈[-π/2,π/2],ha∈[-π/2,π/2]. ## Update It seems there is something wrong with the definition of the faa function. FindRoot[faa[0, x] == aaLow, {x, 0.5}] FindRoot::nlnum: The function value {-0.925025+res$72908} is not a list of numbers with dimensions {1} at {x} = {0.5}. >>


but

FindRoot[ArcCot[(Tan Cos[ϕ] - Sin[ϕ] Cos[x])/Sin[x]] ==
aaLow, {x, 0.5}]
{x -> -0.565933}

• I would have said that NSolve succeeded, so no need for FindRoot. What's the problem with its solution? (I also wonder what it has to do with the rest of the question. Prima facie it looks like it is a separate question.) – Michael E2 Sep 5 '16 at 23:53
• May be it is not your aim, but this Solve[(Sin[\[Phi]] Cos[xx])/Sin[xx] == 3/4, xx, Reals] gives an exact solution. – Alexei Boulbitch Sep 6 '16 at 7:39
• @MichaelE2 There are several problems, the obvious is the warning, the second one is what is C and finally, how do I access the results. The error suggests that I am doing something wrong and potentially Mathematica illegal. The second example is a more general one which reduces to the first one for \[delta]=0. Specifically, there must be something wrong with my definition of the faa function, see the updated question. – leosenko Sep 6 '16 at 18:49
• C represents any integer. Set it equal to something inside Block[{C},..] or replace it with C -> 2 or another integer instead of 2. Example: Join @@ Block[{C}, Table[{{xx -> ConditionalExpression[1. (-2.57352 + 6.28319 C), C \[Element] Integers]}, {xx -> ConditionalExpression[1. (0.568075 + 6.28319 C), C \[Element] Integers]}}, {C, -3, 3}]]` – Michael E2 Sep 6 '16 at 19:32