def c8_to_polar ( c ): #*****************************************************************************80 # ## C8_TO_POLAR converts a C8 to polar form. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 12 February 2015 # # Author: # # John Burkardt # # Parameters: # # Input, complex C, the value. # # Output, real R, T, the polar form. # from c8_arg import c8_arg from c8_mag import c8_mag r = c8_mag ( c ) t = c8_arg ( c ) return r, t
def c8_inv(c): #*****************************************************************************80 # ## C8_INV evaluates the inverse of a C8. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 11 February 2015 # # Author: # # John Burkardt # # Parameters: # # Input, complex C, the argument. # # Output, complex VALUE, the function value. # from c8_conj import c8_conj from c8_mag import c8_mag value = c8_conj(c) / (c8_mag(c))**2 return value
def c8_inv ( c ): #*****************************************************************************80 # ## C8_INV evaluates the inverse of a C8. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 11 February 2015 # # Author: # # John Burkardt # # Parameters: # # Input, complex C, the argument. # # Output, complex VALUE, the function value. # from c8_conj import c8_conj from c8_mag import c8_mag value = c8_conj ( c ) / ( c8_mag ( c ) ) ** 2 return value
def c8_to_polar(c): #*****************************************************************************80 # ## C8_TO_POLAR converts a C8 to polar form. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 12 February 2015 # # Author: # # John Burkardt # # Parameters: # # Input, complex C, the value. # # Output, real R, T, the polar form. # from c8_arg import c8_arg from c8_mag import c8_mag r = c8_mag(c) t = c8_arg(c) return r, t
def c8_log ( c ): #*****************************************************************************80 # ## C8_LOG evaluates the logarithm of a C8. # # Discussion: # # Here we use the relationship: # # C8_LOG ( Z ) = LOG ( MAG ( Z ) ) + i * ARG ( Z ) # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 11 February 2015 # # Author: # # John Burkardt # # Parameters: # # Input, complex C, the argument. # # Output, complex VALUE, the function value. # import numpy as np from c8_arg import c8_arg from c8_mag import c8_mag arg = c8_arg ( c ); mag = c8_mag ( c ); value = np.log ( mag ) + arg * 1j; return value
def c8_sqrt ( c ): #*****************************************************************************80 # ## C8_SQRT returns the principal square root of a C8. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 10 February 2015 # # Author: # # John Burkardt # # Parameters: # # Input, complex C, the number whose square root is desired. # # Output, complex VALUE, the square root of X. # from c8_arg import c8_arg from c8_mag import c8_mag from math import cos from math import sin from math import sqrt argument = c8_arg ( c ) magnitude = c8_mag ( c ); value = sqrt ( magnitude ) \ * complex ( cos ( argument / 2.0 ), sin ( argument / 2.0 ) ) return value
def c8_sqrt(c): #*****************************************************************************80 # ## C8_SQRT returns the principal square root of a C8. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 10 February 2015 # # Author: # # John Burkardt # # Parameters: # # Input, complex C, the number whose square root is desired. # # Output, complex VALUE, the square root of X. # from c8_arg import c8_arg from c8_mag import c8_mag from math import cos from math import sin from math import sqrt argument = c8_arg(c) magnitude = c8_mag(c) value = sqrt ( magnitude ) \ * complex ( cos ( argument / 2.0 ), sin ( argument / 2.0 ) ) return value
def c8_cube_root ( c ): #*****************************************************************************80 # ## C8_CUBE_ROOT returns the principal square root of a C8. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 12 February 2015 # # Author: # # John Burkardt # # Parameters: # # Input, complex C, the number whose square root is desired. # # Output, complex VALUE, the square root of X. # import numpy as np from c8_arg import c8_arg from c8_mag import c8_mag arg = c8_arg ( c ) mag = c8_mag ( c ); mag = mag ** ( 1.0 / 3.0 ) arg = arg / 3.0 value = mag * complex ( np.cos ( arg ), np.sin ( arg ) ) return value
def c8_cube_root(c): #*****************************************************************************80 # ## C8_CUBE_ROOT returns the principal square root of a C8. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 12 February 2015 # # Author: # # John Burkardt # # Parameters: # # Input, complex C, the number whose square root is desired. # # Output, complex VALUE, the square root of X. # import numpy as np from c8_arg import c8_arg from c8_mag import c8_mag arg = c8_arg(c) mag = c8_mag(c) mag = mag**(1.0 / 3.0) arg = arg / 3.0 value = mag * complex(np.cos(arg), np.sin(arg)) return value