0

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?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
user42459
  • 345
  • 1
  • 2
  • 7
  • Try simplifying this expression assuming k1 and k2 are Reals. – swish May 30 '16 at 20:59
  • 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. – MarcoB May 30 '16 at 21:00
  • 1
    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. – Sumit May 30 '16 at 21:02
  • @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? – user42459 May 30 '16 at 21:10
  • 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). – Sumit May 30 '16 at 21:14
  • @Sumit Thank you so much. How to I specify I only want principal values? – user42459 May 30 '16 at 21:24
  • @user42459 You can't quite make that assumption for any and all variables, but you may be interested in this: How to tell Mathematica that the argument of a function is real? – MarcoB May 30 '16 at 21:24

1 Answers1

2

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

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198