[Question]
  [
Write the shortest code, in number of bytes, to display, return, or evaluate to the golden ratio (that is, the positive root of the quadratic equation: \$x^2-x-1=0\$, approximately
1.618033988749895), to at least 15 significant figures. No input will be given to your program.
Sample in Stutsk programming language:
```
1 100 { 1 + 1 swp / } repeat print
```
  
[Answer]
## Perl, Python - 10 chars
probably other languages too
```
.5+5**.5/2
```
[Answer]
# [Julia 0.7](http://julialang.org/), 2 bytes
```
φ
```
[Try it online!](https://tio.run/##yyrNyUw0/@9QUJSZV5KmoaSqZ2iapqTz/3zbf83/AA "Julia 0.7 – Try It Online")
I'm surprised nobody has posted this yet...
[Answer]
# Mathematica 11
```
GoldenRatio
```
This is the irrational number itself, not an approximation of it.
**Examples** (first 2 examples from Mathematica documentation)
```
FullSimplify[GoldenRatio^4 - GoldenRatio]
FullSimplify[GoldenRatio^20 + 1/GoldenRatio^20]
FullSimplify[GoldenRatio^2 - GoldenRatio - 1]
```
> 
> 3 + Sqrt[5]
> 
> 
> 15127
> 
> 
> 0
> 
> 
> 
[Answer]
# [Desmos](https://www.desmos.com/calculator), 8 bytes
```
aa-a~1
a
```
[Try it on Desmos!](https://www.desmos.com/calculator/fpodwh2z33)
[Answer]
**PHP 17 chars**
This one is just trolling, but hey.
```
1.618033988749895
```
[Answer]
# k (10 chars)
As continued fraction:
```
{%x%x+1}/1
```
Or in closed form for 11:
```
%2%1+sqrt 5
```
[Answer]
# J, 7 chars
```
-:1+%:5
```
some more text for the filter (my first J solution, heh)
[Answer]
# APL, 7
```
2÷⍨1+√5
÷2÷1+√5
.5×1+√5
.5+√5÷4
```
Curses! I can't find a way to do it in less than 7 characters! Dialect is Nars2000.
[Answer]
## JavaScript (ECMAScript), 10 chars
```
5**.5/2+.5
```
This is the same as the Perl & Python submission - thanks to **Redwolf Programs** for telling me about this.
However, back in 2012, when this answer was originally written, the `**` operator did not exist in JavaScript. While almost all browsers and do now support the exponentiation operator, according to [Can I Use](https://caniuse.com/#feat=mdn-javascript_operators_exponentiation), as of July 2020, around 9% of users still does not support it, including the latest version of Internet Explorer. Thus, the old version of the answer:
**JavaScript (backwards-compatible), 17 chars**
```
Math.sqrt(5)/2+.5
```
[Answer]
# Language Agnostic, 15 chars
```
9227465/5702887
```
If all you need is enough precision for an IEEE 32 bit float, you can do it in 9 chars:
```
6765/4181
```
This will only work for languages that don't treat integer division specially.
[Answer]
# dc, 8 chars
```
Fk5v1+2/
```
The value is on top of the stack - can be printed by adding `p` to the end of the program.
`F` pushes 15 on the stack ([trick found here](https://codegolf.stackexchange.com/a/17050/2800)), `k` sets the precision to 15 digits. The rest is normal postfix notation :-) `v` is a square root. Trailing `p` for print was omitted.
[Answer]
**J, 10 9 8 chars**
```
p.1,1,_1
```
(root of polynomial: -x^2+x+1)
```
>:@%^:_+1
```
(continued fraction (9 chars))
```
%:@>:^:_+1 
```
(continued root: (10 chars))
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 6 bytes
```
5X‚t;O
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fNOJRw6wSa////wE "05AB1E – Try It Online")
# Explanation
```
5      Push 5
 X     Push 1
  ‚    Pair: [5, 1]
   t   Square root: [2.23606797749979, 1.0]
    ;  Halve: [1.118033988749895, 0.5]
     O Sum: 1.618033988749895
```
[Answer]
# [Arn](https://github.com/ZippyMagician/Arn), 3 bytes
```
phi
```
Just a builtin, too short to be compressed. Returns `1.61803398874989484820458683436563811`.
A more interesting one. If running in the downloadable version, this will print `n` digits, given the command:
```
arn run file.arn -p n
```
or 25 digits if the `-p` flag is not provided.
If running in the online version, this will print the first 50 digits.
## [6 bytes](https://github.com/ZippyMagician/Arn/wiki/Carn)
```
l[├Qn0
```
[Try it!](https://zippymagician.github.io/Arn?code=Oi0xKzovNQ==&input=)
### Explanation
Unpacked: `:-1+:/5`
```
:-       Halve
    1    Literal one
  +      Plus
    :/   Square root of
      5  Literal five
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 4 bytes
**(floating-point; accurate to 15 significant figures)**
```
½→√5
```
[Try it online!](https://tio.run/##yygtzv7//9DeR22THnXMMv3/HwA "Husk – Try It Online")
This seems (to me) to be surprisingly readable for a golfing language...
```
  √5    # square root of 5
 →      # increment 
½       # halve
```
---
# [Husk](https://github.com/barbuz/Husk), 9 bytes
**(calculation as arbitrary precision rational number)**
```
!Ẋ/İf!5İ⁰
```
[Try it online!](https://tio.run/##yygtzv6fqaVoaGBgcGTDo8YNj5oa/ys@3NWlf2RDmqIpWOj/fwA "Husk – Try It Online") (TIO header converts the rational number [expressed in [Husk](https://github.com/barbuz/Husk) as a fraction] to its first 1000 decimal digits)
```
  /         # get the ratio of 
 Ẋ          # every pair of elements of
   İf       # the fibonacci sequence;
!           # now select the ratio at position
     !5İ⁰   # 10^5 (change to !9İ⁰ for more accuracy with same byte-count)
```
[Answer]
# [Malbolge](https://github.com/TryItOnline/malbolge), 102 bytes
```
(C%;_#!7[}{3Wyw/St,+0/(-&Jlk"FEg|{A?~,`<^:r[Y64m3kT0Rg,xwc;J`&%#5"!~Bji.-,X;POsMppn"2GFEiCg+e?>b<;_#![
```
[Try it online!](https://tio.run/##y03MScrPSU/9/1/DWdU6XlnRPLq22ji8slw/uERH20BfQ1fNKydbyc01vaba0b5OJ8EmzqooOtLMJNc4O8QgKF2nojzZ2itBTVXZVEmxzikrU09XJ8I6wL/Yt6AgT8nI3c010zldO9XeLskGZHr0//8A "Malbolge – Try It Online")
[Answer]
# [brainf](https://github.com/TryItOnline/brainfuck), 93 bytes
```
+++++++[>+++++++<-]>.---.++++++++.-----.+++++++.--------.+++..++++++.-..-.---.+++++.-.+.----.
```
[Try it online!](https://tio.run/##SypKzMxLK03O/v9fGwKi7aAMG91YOz1dXV09KF8bxEFwITyogJ4eTFAPiOCqgGyIOr3//wE "brainfuck – Try It Online")
It works :/
Not very optimised though. I can’t think of any way to optimize this, although I’m sure a way exists.
Explanation:
```
+++++++         Add seven to cell at 0.
[               Begin a loop.
     >+++++++   Add seven to cell at 1.
     <          Go back to cell 0.
     -          Decrement the counter there (soon it will reach 0).
]               End loop when cell 0 reaches 0 after 7 repetitions.
>               Go to cell 1 which is now 49.
.               Print it (1).
---.            Decrement 3 to get 46 (period) then print it.
Afterwards, not much explanation is needed. Just add some 
or subtract some and repeat until everything is printed.
++++++++.-----.+++++++.--------.+++..++++++.-..-.---.+++++.-.+.----.
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 8 bytes
```
(1+1%)/1
```
[Try it online!](https://ngn.codeberg.page/k#eJxlzMEOgjAMgOF7n4KLicaw2qCw8TZN6cA4N3Ql8eSzy93z/+WP45HOdDghAcTm25DryV+6Lng/XIMPNwCExWytI6KUSeeSoqvG8tCPLJxndVKe+Nq02r3kiv3gCYWTbIlN291Pmts37xXgb/8DC40lmw==)
Adapted from the [built-in docs](https://codeberg.org/ngn/k/src/commit/875e1d94e181ea59f63cedc366095bc40fb507a7/repl.k#L180).
* `(...)/1` set up a converge-reduce, seeded with 1 and run until two successive iterations return the same result
	+ `(1+1%)` add one to the inverse of the current value, and feed that into the next iteration
[Answer]
# Ruby - 14 chars
```
(­5**0.5)/2+0.5
```
Based on the Javascript Perl answer above.
[Answer]
# Almost language agnostic, 9 chars
### (tested in R):
```
.5+5^.5/2
```
In R, evaluates full double precision. More digits can be seen by setting `options(digits=99)`. The question says "evaluate", so that goes with the rules.
[Answer]
# x86 machine code, 13 bytes
Hexdump:
```
b1 7f d9 e8 d9 e8 de c1 d9 fa e2 f8 c3
```
Disassembly:
```
100139D0 B1 7F                mov         cl,7Fh  
100139D2 D9 E8                fld1  
    again:
100139D4 D9 E8                fld1  
100139D6 DE C1                faddp       st(1),st  
100139D8 D9 FA                fsqrt  
100139DA E2 F8                loop        again (100139D4h)  
100139DC C3                   ret  
```
Uses the converging sequence `an = sqrt(an-1 + 1)`.
The number of iterations is determined by the contents of `ecx`, which is mostly garbage. The minimal number of iterations is 127, which guarantees good precision (actually, 30 iterations should be enough). In the worst case, the calculation will take a few minutes (232-1 iterations), and in the best case, it's instantaneous (127 iterations).
[Answer]
## Python 3, 11 bytes
```
(1+5**.5)/2
```
= 1.618033988749895
[Answer]
# Whispers v3, 16 bytes
```
> φ
>> Output 1
```
[Try it online!](https://tio.run/##K8/ILC5ILSo2@v/fTuF8G5ednYJ/aUlBaYmC4f//AA)
[Answer]
# [><>](https://esolangs.org/wiki/Fish), ~~29~~, 25 bytes
Saved **4 bytes**!
After posting this answer I noticed the example Stutsk program and realized that I could probably save a few bytes. My new answer is based off the example given in the question. This program works because the golden ration can be expressed as a [continued fraction](https://en.wikipedia.org/wiki/Golden_ratio#Alternative_forms).
`golden_ratio = 1+1/(1+1/(1+1/...))`
```
ff*101.;n~<
$1$,1+$:?!^1-
```
[Try it online!](https://tio.run/##S8sszvj/Py1Ny9DAUM86r86GS8VQRcdQW8XKXjHOUPf/fwA "><> – Try It Online")
## Old Answer
```
f201.;n,2+1~<
$:5$,+2,$:?!^1-
```
The second line approximates the sqrt of 5. After looping 15 times, this value is used to calculate the golden ratio.
[Try it online!](https://tio.run/##S8sszvj/P83IwFDPOk/HSNuwzoZLxcpURUfbSEfFyl4xzlD3/38A "><> – Try It Online")
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 3 bytes
```
.n3
```
[Try it online!](https://tio.run/##K6gsyfj/Xy/P@P9/AA "Pyth – Try It Online")
11 bytes without builtin:
```
+c@5 2 2 .5
```
[Try it online!](https://tio.run/##K6gsyfj/XzvZwVTBCAj1TP//BwA "Pyth – Try It Online")
[Answer]
# dc - 11 chars
```
15k5v2/.5+p
```
The most character-consuming task is setting the decimal precision..
[Answer]
# Mathematica - 31
```
N[x/.Solve[x^2-x-1==0][[2]],16]
1.618033988749895
```
(It's going to be the longest code, I expect...:)
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 2 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
MQ
```
[Test it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=TVE)
Or 6 bytes without the built-in:
```
½+5¬/2
```
[Test it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=vSs1rC8y)
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 1 [byte](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
φ
```
Builtins ftw ¯\\_(ツ)\_/¯
[Try it online.](https://tio.run/##y00syUjPz0n7//982///AA)
**Without builtins it's 6 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py):**
```
51α√½Σ
```
[Try it online.](https://tio.run/##y00syUjPz0n7/9/U8NzGRx2zDu09t/j/fwA)
**Explanation:**
```
φ       # Push golden ratio builtin 1.618033988749895
        # (output the entire stack joined together implicitly as result)
5       # Push 5
 1      # Push 1
  α     # Wrap the last two values into a list: [5,1]
   √    # Take the square-root of each value: [2.23606797749979,1.0]
    ½   # Halve each: [1.118033988749895,0.5]
     Σ  # And sum this list: 1.618033988749895
        # (after which the entire stack joined together is output implicitly as result)
```
[Answer]
# [CJam](https://esolangs.org/wiki/CJam), 7 bytes
```
X5mq+2/
```
[Try it online](https://tio.run/##S85KzP3/P8I0t1DbSP//fwA)
Just one more byte than 05AB1E! Pretty simple stack-based translation of the equation on the [Wikipedia page](https://en.wikipedia.org/wiki/Golden_ratio):
```
X5         Push 1 and 5 on to the stack
  mq       Square root the top number
    +      Add the top two numbers on the stack
     2/    Divide by two
           (implicit) output the stack
```
]