0
$\begingroup$

I did

Solve[k2 Cos[x] - k1 Sin[x] == 0,x]

Since tangent is sin over cos, the solution must be

arctan(k2/k1)

But Mathematica gives

{{x -> 
     ConditionalExpression[
       ArcTan[-(k1/Sqrt[k1^2 + k2^2]), -(k2/Sqrt[k1^2 + k2^2])] + 2*Pi*C[1], 
       Element[C[1], Integers]]}, 
  {x -> 
     ConditionalExpression[
       ArcTan[k1/Sqrt[k1^2 + k2^2], k2/Sqrt[k1^2 + k2^2]] + 2*Pi*C[1], 
       Element[C[1], Integers]]}}

Why is this the case?

$\endgroup$

closed as off-topic by m_goldberg, MarcoB, user9660, dr.blochwave, Edmund May 31 '16 at 9:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, MarcoB, Community, dr.blochwave, Edmund
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Try simplifying this expression assuming k1 and k2 are Reals. $\endgroup$ – swish May 30 '16 at 20:59
  • $\begingroup$ Consider that Mathematica assumes all numbers to be complex unless told otherwise. Consider the result of FullSimplify[Solve[{k2 Cos[x] - k1 Sin[x] == 0}, x], {k1, k2, x} \[Element] Reals] instead. $\endgroup$ – MarcoB May 30 '16 at 21:00
  • 1
    $\begingroup$ It is exactly what you are expecting, written in a different way. ArcTan[x,y] is ArcTan[y/x] with proper choice of sign. Check this for details. $\endgroup$ – Sumit May 30 '16 at 21:02
  • $\begingroup$ @MarcoB Thank you very much! By the way, I won't have any situation where I consider variables that are not real. Can I just make assumption that all variables are reals globally? $\endgroup$ – user42459 May 30 '16 at 21:10
  • $\begingroup$ Assuming[{{k1, k2} \[Element] Reals}, Simplify[Solve[k2 Cos[x] - k1 Sin[x] == 0, x]]] . you will still have a condition because it is not specified that we are looking for Principal values (That is the solution + 2Pi C[1] part). $\endgroup$ – Sumit May 30 '16 at 21:14
2
$\begingroup$

To remove the condition just assume the condition

soln1 = Solve[k2 Cos[x] - k1 Sin[x] == 0, x] //
  Simplify[#, Element[C[1], Integers]] &

enter image description here

To look at the fundamental interval, set the arbitrary integer constant to zero

soln2 = Solve[k2 Cos[x] - k1 Sin[x] == 0, x] /. C[1] -> 0

enter image description here

Plot3D[Evaluate[x /. soln2],
 {k1, -10, 10}, {k2, -10, 10},
 PlotLegends -> "Expressions",
 PlotPoints -> 50]

enter image description here

Simplifying the results

soln3 = soln2 // FullSimplify[#, Element[{k1, k23}, Reals]] &

enter image description here

Despite its appearance, the first function is real-valued, e.g.,

x /. soln3 /. {k1 -> 1, k2 -> 3} // FunctionExpand

enter image description here

Plot3D[Evaluate[x /. soln3],
 {k1, -10, 10}, {k2, -10, 10},
 PlotLegends -> "Expressions",
 PlotPoints -> 50]

enter image description here

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.