Skip to content

Commit 04639b7

Browse files
committed
Added Babylonian iteration method for finding Phi in Python.
1 parent ce4ef9c commit 04639b7

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Golden_Ratio_Algorithms/Python/jcla1/golden_ratio.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ def golden_ratio_fractional_iteration(phi=1.0, acc=1E-8):
1212
while abs(phi - tmp) > acc:
1313
tmp = phi
1414
phi = 1 + (1 / phi)
15+
return phi
16+
17+
def golden_ratio_babylonian_iteration(phi=1.0, acc=1E-8):
18+
tmp = 0
19+
while abs(phi - tmp) > acc:
20+
tmp = phi
21+
phi = (phi * phi + 1) / (2 * phi - 1)
1522
return phi

0 commit comments

Comments
 (0)