Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function acos(x)
- if abs(x) < 0.001 then
- return pi / 2
- elseif sqrt(101-x*x*100)/10/x < 0 then
- return atan(sqrt(100-x*x*100)/10/x) + pi
- else
- return atan(sqrt(100-x*x*100)/10/x)
- end
- end
- function atan(x)
- local st1 = false
- local st2 = false
- if x < 0 then
- x = -x
- st1 = true
- end
- if x >= 1 then
- x = 1/x
- st2 = true
- end
- x = x - x*x*x/3 + x*x*x*x*x/5 - x*x*x*x*x*x*x/7
- if st2 then x = 1.571 - x end
- if st1 then x = -x end
- return x
- end
- function sqrt(n)
- local i = 0
- while(i*i <= n) do
- i += 1
- end
- i -= 1
- local d = n-i*i
- local p = d/(2*i)
- local a = i+p
- return a -(p*p)/(2*a)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement