1
0
mirror of https://github.com/golang/go synced 2024-11-22 03:54:39 -07:00

doc: Fix typo in approximation of square root

See https://en.wikipedia.org/wiki/Newton%27s_method#Square_root_of_a_number

R=golang-dev, minux.ma, adg
CC=golang-dev
https://golang.org/cl/9145044
This commit is contained in:
Katrina Owen 2013-05-29 13:49:51 +10:00 committed by Andrew Gerrand
parent 28c64e3006
commit 605da0e2a2

View File

@ -295,9 +295,9 @@ package newmath
// Sqrt returns an approximation to the square root of x. // Sqrt returns an approximation to the square root of x.
func Sqrt(x float64) float64 { func Sqrt(x float64) float64 {
z := 0.0 z := 1.0
for i := 0; i < 1000; i++ { for i := 0; i < 1000; i++ {
z -= (z*z - x) / (2 * x) z -= (z*z - x) / (2 * z)
} }
return z return z
} }