#test_math.py sample use of functions after import math print "test_math.py running" import math print dir(math) # ugly list of functions and values print "math.pi=%g" % (math.pi) print "math.e=%g" % (math.e) print "math.sin(math.pi)=%10.3f" % (math.sin(math.pi)) print "math.cos(math.pi)=%10.3f" % (math.cos(math.pi)) print "math.tan(math.pi)=%g" % (math.tan(math.pi)) print "math.atan(1.0)=%10.3f" % (math.atan(1.0)) print "math.asin(1.0)=%10.3f" % (math.asin(1.0)) print "math.acos(0.5)=%10.3f" % (math.acos(0.5)) print "math.sinh(1.0)=%10.3f" % (math.sinh(1.0)) print "math.cosh(1.0)=%10.3f" % (math.cosh(1.0)) print "math.tanh(1.0)=%10.3f" % (math.tanh(1.0)) print "math.sqrt(2.0)=%10.3f" % (math.sqrt(2.0)) print "math.exp(2.0)=%10.3f" % (math.exp(2.0)) print "math.log(2.0)=%10.3f" % (math.log(2.0)) print "min(1.0,2.0)=%10.3f" % (min(1.0,2.0)) print "max(1.0,2.0)=%10.3f" % (max(1.0,2.0)) print "abs(-2.5)=%10.3f" % (abs(-2.5)) print "min(1,2)=%d" % (min(1,2)) print "max(1,2)=%d" % (max(1,2)) print "abs(-2)=%d" % (abs(-2)) a=complex(1.0,2.0) print "a=complex(1.0,2.0)= %f %f" % (a.real,a.imag) b=(3.0-2.0j) print "b=(3.0-2.0j)= %f %f" % (b.real,b.imag) c=a*b print "c=a*b= (%f+ %fj)" % (c.real,c.imag) print "no sqrt of complex" print "math.sqrt(abs(c))=%10.3f" % (math.sqrt(abs(c))) print "big number =%g" % (1.23456e300) print "small number =%g" % (1.23456e-300) print "end test_math.py"