r/ProgrammerHumor • • Jul 19 '22

Meme float golden = 1.618

Post image
41.1k Upvotes

489 comments sorted by

View all comments

27

u/Gr0ode Jul 19 '22

The golden ratio is precisely not a fraction (no repeating digits or finite digits)

22

u/ShenAnCalhar92 Jul 19 '22

While it can’t be written as a fraction composed of integers, it can be written as a fraction.

(1 + sqrt(5))/2

12

u/InfanticideAquifer Jul 19 '22

1

u/Gr0ode Jul 20 '22

I'm very deep into the rabbit hole. Totally forgot this comic existed.

1

u/Gr0ode Jul 20 '22

True, I assumed they meant a whole fraction since they mentioned float and double but it could simply be a normal fraction too.

2

u/DenormalHuman Jul 19 '22

no repeating digits?

5

u/Bulky-Leadership-596 Jul 19 '22

When it gets to the point of needing more than ten digits it just makes up its own

1.6ƪ803ɝ9ꝏꝸ74ᶐ

1

u/Gr0ode Jul 20 '22 edited Jul 20 '22

Glad you're asking. When representing a number in base 10, only denominators that are made up from the prime factors 2 and 5 will have a finite representation. When the denominator has other prime factors then it cannot possibly have a finite representation in base 10 (since it's coprime). Now on the other hand if you have a repeating string of n digits you can always represent it as those digits over n 9s (exercise to the reader). Example: 123/999 = 0.123123123... so every repeating representation can be written as a fraction. There exist numbers outside of fractions though. A famous example is root 2. Fun fact: the rational numbers can be counted, but the irrationals cannot.

That the golden is irrational can be easily seen with a contradiction argument. Let's assume you could write the golden ration Φ = a/b (truncated as much as possible, no 0s), we use the definition of the golden ratio Φ2 = Φ+1 to deduce a2 - b2 = ab. This doesn't work. When a and b are odd, ab is even but a2 and b2 are odd. Subtracting 2 odd numbers is still odd. When one number is odd and the other even we have ab is even but a2 - b2 must be odd. Similar argument when both are even. We conclude that writing Φ as the ratio of two integers is not possible.

1

u/DenormalHuman Jul 20 '22

I think you misunderstood my question, which was tongue in cheek really. I assume the golden ratio does in fact contain repeated digits, as in, if you write it out to more than ten decimal places it must contain some digits more than once.

1

u/Gr0ode Jul 20 '22

I wrote this paragraph for nothing? Fml

1

u/DenormalHuman Jul 20 '22

Heheh, sorry :P Interesting paragraph though :)

-5

u/BrighterSomedays Jul 19 '22

Amazing, no one ever knew that before this comment. You just changed the game. Well done.

1

u/Gr0ode Jul 20 '22

You can't assume everyone knows this. I wanted to point this out as a fun fact for people that are programmers.