• If the beginning the calculation is the following:
5 / (3 + pow( 1 - sqrt(x*x+y*y), 2) ) with x = -1/2; y = sqrt(3)/2
(that is: 5 / ( 3 + ( 1 − √(x²+y²) ) 2 )
the output is:
1.6666666666666667
You can change the calculation however you want.
The original file:
<head><title>calculation</title><script> with(Math) { x = -1/2; y = sqrt(3)/2 u = 5 / (3 + pow( 1 - sqrt(x*x+y*y), 2) ) document.write(u) } // abs(a) // the absolute value of a // acos(a) // arc cosine of a // asin(a) // arc sine of a // atan(a) // arc tangent of a // atan2(a,b) // arc tangent of a/b // ceil(a) // integer closest to a and not less than a // cos(a) // cosine of a // exp(a) // exponential of a // floor(a) // integer closest to and not greater than a // log(a) // log of a base e // max(a,b) // the maximum of a and b // min(a,b) // the minimum of a and b // pow(a,b) // a to the power b // random() // pseudorandom number in the range 0 to 1 // round(a) // integer closest to a // sin(a) // sine of a // sqrt(a) // square root of a // tan(a) // tangent of a // PI // π // exp(1) // e </script> </head>
• If I want calculate:
I change:
x = -1/2; y = sqrt(3)/2
u = 5 / (3 + pow( 1 - sqrt(x*x+y*y), 2) )
document.writeln(u)
with:
x = 5/6; y = -1/3; z = 0.5
u = pow(x+y,2)/z
document.write(u)
I have:
0.5
• With:
x = 3; a = x*x; b = a+3; c = x+5; d = b/c; u = sqrt(d) document.write("d = " + d); document.write(" | u = " + u)
I have:
d = 1.5 | u = 1.224744871391589
If I want to round u to the 3rd digit after ".":
x = 3; a = x*x; b = a+3; c = x+5; d = b/c; u = sqrt(d) document.write("d = " + d); document.write(" | u = " + round(u*1000)/1000 )
I have:
d = 1.5 | u = 1.225
• Another example: here