giochanturia

Square root and logarithm for positive branch cut

Mar 2nd, 2022
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. # %% Square root and logarithm for positive branch cut
  2.  
  3. def logth(z, theta):
  4.     argument = np.angle(z)
  5.     modulus = np.absolute(z)
  6.     argument = np.mod(argument + theta, 2 * np.pi) - theta
  7.     return np.log(modulus) + 1j * argument
  8.  
  9. log1 = lambda z: logth(z, 2*np.pi)
  10.  
  11. def sqrtth(z, theta):
  12.     argument = np.angle(z)
  13.     modulus = np.abs(z)
  14.     argument = np.where(argument == 0, 0, np.mod(argument + theta, 2 * np.pi) - theta)
  15.     return np.sqrt(modulus) * np.exp(1j * argument / 2)
  16.  
  17. sqrt1 = lambda z: sqrtth(z, 2*np.pi)
Advertisement
Add Comment
Please, Sign In to add comment