# Solve returns format I don't understand with dollar sign ($) [closed] I have the following function K[theta_, phi_] := Module[{c1, c2, c3, Phi, PhiPr, x, y}, {c1, c2, c3} = 1 - 3 Sin[theta]^2 Cos[phi - 2 Pi (# - 1)/3]^2 & /@ {1, 2, 3}; Phi = Sqrt[((c2 + c3)^2 - c1^2)/(4 c2 c3)]; PhiPr = ((c3 - c2)/c1) Phi; If[0 <= Phi^2 <= 1, {x, y} /. Solve[Sin[Sqrt x/2] == Phi && Sin[3 y/2] == PhiPr && (c2 + c3) Cos[Sqrt x/2] == -c1 Cos[3 y/2] && -Pi <= x <= Pi && -Pi <= y <= Pi, {x, y}] , Null] ]  Sometimes it behaves itself and returns me either a Null (as desired) or an actual number. However sometimes it is a naughty function and returns something strange. For example if I compute K[0.1,0] it returns me {x$17889, y$17889}. What is this output? I don't understand. Many thanks • When Solve cannot find a solution it returns {}. {x,y}/.{} is just {x,y}. But inside any module all the variable names are aliased with a$ and a claimed unique serial number. So that is what you are seeing, the aliased local variables from your Module. You could verify all this with a carefully positioned Print statement. – Bill Jan 2 '15 at 19:22
• Related: mathematica.stackexchange.com/questions/40578/…. Perhaps there's a better candidate for a duplicate, but this is basically how Module works and is explained in the "Details" section of its documentation page. – Michael E2 Jan 2 '15 at 19:40
• Ah.. I understand. Thank you – Tom Jan 2 '15 at 19:46

You can identify the problem by performing the steps in your function one at a time for theta = .1 and phi = 0..

{c1, c2, c3} = 1 - 3 Sin[0.1]^2 Cos[0 - 2 Pi (# - 1)/3]^2 & /@ {1, 2, 3}
{* {0.9701, 0.992525, 0.992525} *}

Phi = Sqrt[((c2 + c3)^2 - c1^2)/(4 c2 c3)]
{* 0.87245 *}

PhiPr = ((c3 - c2)/c1) Phi
{* 0. *}


Because 0 <= Phi^2 <= 1 is True, the Solve is executed:

{x, y} /. Solve[Sin[Sqrt x/2] == Phi && Sin[3 y/2] ==
PhiPr && (c2 + c3) Cos[Sqrt x/2] == -c1 Cos[3 y/2] && -Pi <= x <= Pi && -Pi <= y <= Pi,
{x, y}]


returning the error message Solve::ratnz and {x, y} instead of an answer. Returning now to your original function, a Module, x and y are temporary variables, which have names beginning with \$, which is what you are getting.

Replace the If statement in the Module by
If[0 <= Phi^2 <= 1, Check[{x, y} /. Solve[Sin[Sqrt x/2] == Phi &&

to obtain a Null response is such cases.