scientific-programming-exer.../ex_01_01.py

19 lines
464 B
Python

#!/usr/bin/python3
import cmath
import math
if( __name__ == "__main__"):
log = cmath.log(-16)
sqrt = cmath.sqrt(-16)
print("logarithm:", log)
print("\tabsolute value:", abs(log))
print("square root:", sqrt)
print("\tabsolute value:", abs(sqrt))
# rotate (7, 3) counter-clockwise (math. positive) arount (0, 0)
c = 7 + 3j
c_prime = c * cmath.exp(1j * math.radians(30))
print("Rotated (7,3) by 30 degs:", "({}, {})".format(c_prime.real, c_prime.imag))