Converting Complex-Valued Angles from Radians to Degrees in Python?
<p>After using cmath to compute the asin of 1.47, which returns a complex angle measured in radians;</p>

<blockquote>
  <p>cmath.asin(1.47)</p>
  
  <p>(1.5707963267948966+0.9350931316301407j)</p>
</blockquote>

<p>Is there a way in which can I convert this value to degrees? math.degrees does not work since it cannot compute with complex values.</p>

<p>Thanks!</p>

<p>Degrees make little sense in complex numbers. But if you must use them, just use the same math formula as for real numbers:</p>

<pre><code>cmath.asin(1.47) * 180 / math.pi
</code></pre>

<p>You get the result</p>

<pre><code>(90+53.576889894078214j)
</code></pre>

<p>Note the 90 degrees in the real part.</p>

<p>The usefulness of this depends on the context. For example, when taking a complex logarithm, only the imaginary part of the result is an angle and thus can be expressed in degrees. The real part is the logarithm of the modulus of the parameter and has nothing to do with an angle. In that case, use the above conversion only on the imaginary part. In your arcsine example, usually only the real part is considered an angle, which is why you got the simple <code>90</code> for the real part but a mess for the imaginary part.</p>

<p>Let us know just what you are doing with this and we can help you determine the best way to use degrees.</p>

python python-2.7