Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compute the square root of a number in ATS?

Tags:

ats

I know that one can use the sqrt function in libc/math for doing it:

staload
Math =
"libats/libc/SATS/math.sats"

val sqrt2 = $Math.sqrt(2.0)
val sqrt3 = $Math.sqrt(3.0)

I am looking for a direct implementation of sqrt in ATS if possible.


1 Answers

See this snippet for a basic implementation of the square root using the Newton-Raphson method.

like image 50
Arets Paeglis Avatar answered Jan 19 '26 19:01

Arets Paeglis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!