(1+sqrt(5))/2

Percentage Accurate: 100.0% → 100.0%
Time: 484.0ms
Alternatives: 1
Speedup: 9.4×

Specification

?
\[\frac{1 + \sqrt{5}}{2} \]
(FPCore ()
  :precision binary64
  (/ (+ 1.0 (sqrt 5.0)) 2.0))
double code() {
	return (1.0 + sqrt(5.0)) / 2.0;
}
real(8) function code()
    code = (1.0d0 + sqrt(5.0d0)) / 2.0d0
end function
public static double code() {
	return (1.0 + Math.sqrt(5.0)) / 2.0;
}
def code():
	return (1.0 + math.sqrt(5.0)) / 2.0
function code()
	return Float64(Float64(1.0 + sqrt(5.0)) / 2.0)
end
function tmp = code()
	tmp = (1.0 + sqrt(5.0)) / 2.0;
end
code[] := N[(N[(1.0 + N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\frac{1 + \sqrt{5}}{2}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 1 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

\[\frac{1 + \sqrt{5}}{2} \]
(FPCore ()
  :precision binary64
  (/ (+ 1.0 (sqrt 5.0)) 2.0))
double code() {
	return (1.0 + sqrt(5.0)) / 2.0;
}
real(8) function code()
    code = (1.0d0 + sqrt(5.0d0)) / 2.0d0
end function
public static double code() {
	return (1.0 + Math.sqrt(5.0)) / 2.0;
}
def code():
	return (1.0 + math.sqrt(5.0)) / 2.0
function code()
	return Float64(Float64(1.0 + sqrt(5.0)) / 2.0)
end
function tmp = code()
	tmp = (1.0 + sqrt(5.0)) / 2.0;
end
code[] := N[(N[(1.0 + N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\frac{1 + \sqrt{5}}{2}

Alternative 1: 100.0% accurate, 9.4× speedup?

\[1.618033988749895 \]
(FPCore ()
  :precision binary64
  1.618033988749895)
double code() {
	return 1.618033988749895;
}
real(8) function code()
    code = 1.618033988749895d0
end function
public static double code() {
	return 1.618033988749895;
}
def code():
	return 1.618033988749895
function code()
	return 1.618033988749895
end
function tmp = code()
	tmp = 1.618033988749895;
end
code[] := 1.618033988749895
1.618033988749895
Derivation
  1. Initial program 100.0%

    \[\frac{1 + \sqrt{5}}{2} \]
  2. Evaluated real constant100.0%

    \[\leadsto \color{blue}{1.618033988749895} \]
  3. Add Preprocessing

Reproduce

?
herbie shell --seed 1 
(FPCore ()
  :name "(1+sqrt(5))/2"
  :precision binary64
  (/ (+ 1.0 (sqrt 5.0)) 2.0))