Home | Pictures of 3D objects

# Math Functions The following math functions are provided: abs(x) sqrt(x) sin(x) cos(x) tan(x) asin(x) # arc sine acos(x) # arc cosine atan(x) # arc tangent atan2(y,x) # angle whose tangent is y/x exp(x) # e to the x log(x) # natural log, base e # log(x)/log(10) gives log base 10 pow(x,y) # x to the power y pi # 3.14159.... ceil(x) # round up to nearest integer floor(x) # round down to nearest integer round(x) # round to nearest integer max(x,y,z) # the largest of x,y,z min(x,y,z) # the smallest of x,y,z random() # pseudorandom number 0 to 1 factorial(x) # x! = x*(x-1)*(x-2)....(1) combin(x,y) # x!/(y!*(x-y)!) max(a,b,c,..) # maximum of these min(a,b,c,..) # minimum of these Many of the quantities above are simplified forms of the JavaScript functions Math.abs(x), Math.sqrt(x), etc. Here are details of the factorial and combin functions. There are functions for converting between degrees and radians, where there are 2*pi radians in 360 degrees: radians(360) # equal to 2*pi degrees(2*pi) # equal to 360 See JavaScript documentation on the Date object which provides methods for determining the current day etc. Here is a way to determine elapsed time in seconds, with microsecond accuracy, using the clock() function that is also available in the standard Python "time" module. The displayed text is approximately 1.5: t1 = clock() sleep(1.5,wait) t2 = clock() print(t2-t1) JavaScript: var t1 = clock() sleep(1.5,wait) var t2 = clock() print(t2-t1) There is also a function msclock() which gives the time in milliseconds instead of seconds. You can use LaTeX to display mathematical expressions on the page.

Top of page