Skip to content

Commit 20cd151

Browse files
committed
Added babylonian iteration method for finding phi in Go.
1 parent 3e55f51 commit 20cd151

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Golden_Ratio_Algorithms/Go/jcla1/golden_ratio.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,14 @@ func FractionalIteration(phi, epsilon float64) float64 {
2323

2424
return phi
2525
}
26+
27+
func BabylonianIteration(phi, epsilon float64) float64 {
28+
tmp := 0.0
29+
30+
for math.Abs(tmp-phi) > epsilon {
31+
tmp = phi
32+
phi = (phi * phi + 1) / (2 * phi - 1)
33+
}
34+
35+
return phi
36+
}

0 commit comments

Comments
 (0)