How to do it...

The following functions and constants operate like their normal math cousins, except where noted:

  • exp(x): Calculate math constant e to the power of x.
  • log(x[, base]): There is one branch cutfrom 0, along the negative real axis to -∞, and continuous from above.
  • log10(x): Same branch cut as log
  • sqrt(x): Same branch cut as log
  • acos(x): Two branch cuts—one from 1 to the right along the real axis to  and continuous from below. The other extends left from -1 to -∞ and is continuous from above.
  • asin(x): Same branch cuts as acos
  • atan(x): Two branch cuts: one from 1j along the imaginary axis to ∞j, continuous from the right. The other extends from -1j to -∞j and continuous from the left.
  • cos(x): Calculate the cosine of x.
  • sin(x): Calculate the sine of x.
  • tan(x): Calculate the tangent of x.
  • acosh(x): One branch cut from 1 to the left along the real axis to  -∞, continuous from above.
  • asinh(x): Two cuts—one from 1j along the imaginary axis to ∞j and continuous from the right. The other is from -1j along the imaginary axis to -∞j and continuous from the left.
  • atanh(x): Two cuts—one from 1 to real , continuous from above. The other is from -1 to real -∞, continuous from above.
  • cosh(x): Calculate the hyperbolic cosine of x.
  • sinh(x): Calculate the hyperbolic sine of x.
  • tanh(x): Calculate the hyperbolic tangent of x.
  • pi: Return the math constant π as a number.
  • e: Return the math constant e as a number.
  • tau: Return the math constant τ as a number.
  • inf: Represent the floating-point value .
  • nan: Represent the floating-point value "not a number".

New constants in the cmath module include the following:

  • infj: Constant complex number with 0 real part and ∞j imaginary part
  • nanj: Constant complex number with 0 real part and NaN imaginary part

Polar coordinates are supported within the cmath module. In Python, z represents the real part z.real and the imaginary part z.imag. Using polar coordinates, z is defined by the modulus r and the phase angle φ (phi):

  • The phase(x) function returns the phase of x (provided as a complex number); the returned value is a float. The result is within the range of -π and  π  and the branch cut is along the negative real axis, continuous from above:
  • The polar(x) function returns the phase of x in polar coordinates as a (r, φ) pair:
  • The rect(r, phi) function returns the complex number x as a (real, imag) pair:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset