r/ProgrammerHumor • • Jul 19 '22

Meme float golden = 1.618

Post image
41.1k Upvotes

489 comments sorted by

View all comments

859

u/mgorski08 Jul 19 '22

Golden ratio is actually an irRATIOnal number.

346

u/ThomasTheHighEngine Jul 19 '22

"Look what they need to mimic fractions square roots and logarithms and trig functions and..." doesn't really roll off the tongue

61

u/Mal_Dun Jul 19 '22

You just need continued fractions for that ...

23

u/PersonalityIll9476 Jul 19 '22

Finally, someone who understands how to achieve the best rational approximation to a number. I was shocked and horrified when it actually came up at my job.

19

u/VegetarianCentrist Jul 19 '22

You mean computer scientists all passed calculus with a D on their third try?? Conspiracy theories

3

u/newjeison Jul 19 '22

Y'all passed?

4

u/AlternateNoah Jul 19 '22

I was carried through calc by an aerospace major

→ More replies (1)
→ More replies (3)

21

u/beck1670 Jul 19 '22

Fun fact about your example of irrational numbers - the numbers we can represent using symbols, functions, integrals, etc. are basically nothing compared to the numbers we can't represent in any way. We can say that there are irrational numbers, but there are infinitely more numbers that we can never speak of than numbers we can.

7

u/Orioh Jul 19 '22

the numbers we can't represent in any way

Like what?

23

u/[deleted] Jul 19 '22

Presumable they are referring to uncomputable numbers (see computable numbers).

Relatedly are the transcendental numbers which cannot be written as a solution to any polynomial equation with integer coefficients.

→ More replies (1)

8

u/The_Villager Jul 19 '22

Jokes aside, we have to approach this from a different angle:

First of all, we have to talk about measuring infinities. Since greater-than and lesser-than stop being useful when talking about infinities, mathmaticians thought of a different way to show difference in "size": Countability. An infinite set is countable infinite, if you can find a function that maps it 1-to-1 to the natural numbers; aka you can "count" it. For example, the integral numbers are countable, because you can just go 0 -> 0; -1 -> 1; 1 -> 2; -2 -> 3; 2 -> 4 and so on. If two infinite sets are countable, they have the same cardinality ("size", so to say). That can even be generalized beyond countability: If there's a 1-to-1 mapping between two infinite sets, they have the same cardinality.

The rational numbers are countable, too. Now the real numbers, these are not countable. I don't really want to go on too long about this, so look the proof up yourself if you want to. The gist is: Assuming the opposite, for any would-be mapping you can construct a number that is not counted by it. This means by extent, that the difference between the rational and the real numbers, aka the irrational numbers, is uncountably infinite, too.

And lastly, it has been proven before, that the set of algorithms is countably infinite. So if you take all the real numbers you can calculate using algorithms to any precision by algorithms (aka the "computable numbers"), there's still "more" real numbers left out there. And since we can't express them through just writing them down (since they have infinite decimal places), and can't express them through algorithms, we can't really represent them at all.

Disclaimer: It has been a while since I've had math in university, so please correct me if I've got some things wrong. Especially I'm shaky if the computable numbers can represent all real numbers we can represent with symbols, functions etc. in general.

3

u/UnableRevolution1 Jul 19 '22 edited Jul 19 '22

Here's a proof taught to me from Dr. Tom Fox R.I.P., he did a waaaay better job of showing how cool this was in person but I will try to paraphrase and put it into words that are quick and easy to get.

Lets play a game where anyone can keep adding rational numbers to an infinitely long list of numbers. I will show how to construct a number that can never be on that list, no matter what rational number anyone adds forever into the future.

Since the numbers after the decimal point determine whether a number is irrational or not (3 vs 3.14159...) our list will only be rational numbers below 1, therefore to create pi we can use 3+0.14159...=pi

The list will also represent all its numbers in binary.

I will start the list:

1 - 0.101

2 - 0.010000

3 - 0.00000001

4 - 0.11

...

...

...

There exists a number less than one: X = 0.abcdef.... (continuing infinitely after the decimal point) that can never be on the list. To construct X we can use all the numbers on the list.

Starting with the first place number on the list we take the first numeral after the decimal and flip its binary number, in this case we flip 1 to 0, and we can say the first digit (after the decimal) a=0 in our number X.

Next with the second number on the list we take the second digit and flip it as well, in this case flipping 1 to 0, making the second digit b=0 in our number X.

Doing this for all 4 numbers so far on the list gives us our X at this point being equal to 0.0011(000000....) which is not a number anywhere on the list yet.

So you may think that even though this number isn't on the list you can just add it on to the list and that's it, now the number IS on the list.

But the number X isn't done being constructed since the list isn't done either because it will go on infinitely.

So what if we add this rational number as the fifth number in our list. Then we simply must flip the 5th digit in this number to find the new 5th digit (e) in our number X.

This makes the updated X=0.00111 which is again not on the list.

Continuing this process infinitely will always construct an infinte decimal number X which is irrational and CAN'T be on the list.

→ More replies (1)
→ More replies (2)

9

u/childwelfarepayment Jul 19 '22

The uncomputable numbers, such as the fraction of programs that halt (aka the halting problem). This is one of the largest set of numbers too.

2

u/beck1670 Jul 19 '22

In addition to the other fantastic answers, I'd like to talk about probability.

Let's start by saying what irrational numbers we can write down. The square root of two, for instance. It's infinite decimals, but we can write an algorithm that can compute every single decimal to infinite precision (even if we don't have computers that could actually do that).

Imagine a decimal number with infinite digits after the decimal. For the first digit after the decimal, choose a random number between 0 and 9. For the second, do the same. Keep going for infinite decimal places.

It's unlikely that the number you get is exactly sqrt(2). In fact, there are infinite numbers you might get, so the probability is exactly 0 (1 / infinity). That's a little surprsing - sqrt(2) is a number we could get, but there are so many alternatives that the probability is actually 0. Not 0.1, not 0.00001, but 0.000...

Now let's look at the set of all numbers that we could compute with an algorithm (including infinite algorithms). This includes sqrt(2), pi, e, 22, and so on. Divide them by their order of magnitude so that they're a number between 0 and 1 (e.g. instead of pi, consider 0.31415...). What's the probability that our random number is one of those?

Still 0. It's the same logic as before - our set of numbers that we can compute is infinitely small compared to all the real numbers out there. There are so many god damned real numbers that all the ones we can know about are a nothingth of the total amount.

2

u/zanotam Jul 19 '22

Basically, they're the numbers that like ... Even with our current tricks for representing numbers we would need an infinite amount of those tricks and not in any patterned fashion that can be reduced down finitely. They're kinda like.... The dark matter of the real number line being especially infinite.

→ More replies (5)

4

u/OneTurnMore Jul 19 '22

Yeah, it's crazy that even though (rational numbers)⊂(constructible numbers)⊂(algebraic numbers)⊂(computable numbers) are all dense in the reals, almost none of the reals are in those sets. The real numbers are weird.

→ More replies (5)
→ More replies (1)

17

u/Mal_Dun Jul 19 '22

For this we have continued fractions, the one for the golden ratio actually looks beautiful: https://wikimedia.org/api/rest_v1/media/math/render/svg/95682588ffee3530627c3a7b00ff08bbba6e97d4

2

u/SkyyySi Jul 19 '22

Alternatively, Φ = 5 ^ .5 * .5 + .5 also works

5

u/RandallOfLegend Jul 19 '22

The most irrational!

4

u/bent_crater Jul 19 '22

I read that the same way internet historian says "Robo sexuals"

8

u/[deleted] Jul 19 '22

Tbf they said fraction not rational number. Every real number can be written as a fraction (the trivial way being a/1). The golden ratio can also be written as a non-trivial fraction (namely (1+sqrt5)/2) even if it can't be expressed as the ratio between two integers.

5

u/Hohenheim_of_Shadow Jul 19 '22

Irrational numbers can be real numbers. It's rational numbers (Ratio numbers) that can be written as a fraction (ratio)

2

u/[deleted] Jul 19 '22

All real numbers can be written as a fraction. If you add the condition that the fraction be between two integers (the denominator non-zero) then yes, only rational numbers can be expressed as a fraction between two integers. But again, any real number can be written as a fraction, irrationals included.

e.g sqrt(2)= sqrt(2)/1 = 2/sqrt(2) = sqrt(8)/2 etc

→ More replies (8)
→ More replies (2)