- #1
Gerenuk
- 1,034
- 5
I was wondering if the Golden ratio base (phinary system) has any use somewhere and if arithmetics with it is easy?
I programmed a surprisingly simple algorithm to calculate the logarithm yielding digits in base phi using nothing more than 2 multiplications/divisions per result digit. Can it be useful?
Here the python programm if you want to see:
I programmed a surprisingly simple algorithm to calculate the logarithm yielding digits in base phi using nothing more than 2 multiplications/divisions per result digit. Can it be useful?
Here the python programm if you want to see:
Code:
phi=(sqrt(5)+1)/2
base=2
digits=5
totalDigits=30
a0,b0=1/base**(phi**digits),base**(phi**(digits-1))
def logPhinary(x):
a,b=a0,b0
result=""
x*=a
switch=0
for i in range(totalDigits):
if switch==0:
a*=b
if x > 1:
result+="1"
b*=a
x*=a
else:
switch=1
x/=a
else:
b*=a
if x > 1:
result+="1"
a*=b
x/=b
else:
switch=0
x*=b
result+="0"
return result[0:digits+1]+"."+result[digits+1:] #insert decimal point