
(FPCore (i) :precision binary64 (let* ((t_0 (* (* 2.0 i) (* 2.0 i)))) (/ (/ (* (* i i) (* i i)) t_0) (- t_0 1.0))))
double code(double i) {
double t_0 = (2.0 * i) * (2.0 * i);
return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0);
}
real(8) function code(i)
real(8), intent (in) :: i
real(8) :: t_0
t_0 = (2.0d0 * i) * (2.0d0 * i)
code = (((i * i) * (i * i)) / t_0) / (t_0 - 1.0d0)
end function
public static double code(double i) {
double t_0 = (2.0 * i) * (2.0 * i);
return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0);
}
def code(i): t_0 = (2.0 * i) * (2.0 * i) return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0)
function code(i) t_0 = Float64(Float64(2.0 * i) * Float64(2.0 * i)) return Float64(Float64(Float64(Float64(i * i) * Float64(i * i)) / t_0) / Float64(t_0 - 1.0)) end
function tmp = code(i) t_0 = (2.0 * i) * (2.0 * i); tmp = (((i * i) * (i * i)) / t_0) / (t_0 - 1.0); end
code[i_] := Block[{t$95$0 = N[(N[(2.0 * i), $MachinePrecision] * N[(2.0 * i), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(i * i), $MachinePrecision] * N[(i * i), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\\
\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{t_0}}{t_0 - 1}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (i) :precision binary64 (let* ((t_0 (* (* 2.0 i) (* 2.0 i)))) (/ (/ (* (* i i) (* i i)) t_0) (- t_0 1.0))))
double code(double i) {
double t_0 = (2.0 * i) * (2.0 * i);
return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0);
}
real(8) function code(i)
real(8), intent (in) :: i
real(8) :: t_0
t_0 = (2.0d0 * i) * (2.0d0 * i)
code = (((i * i) * (i * i)) / t_0) / (t_0 - 1.0d0)
end function
public static double code(double i) {
double t_0 = (2.0 * i) * (2.0 * i);
return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0);
}
def code(i): t_0 = (2.0 * i) * (2.0 * i) return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0)
function code(i) t_0 = Float64(Float64(2.0 * i) * Float64(2.0 * i)) return Float64(Float64(Float64(Float64(i * i) * Float64(i * i)) / t_0) / Float64(t_0 - 1.0)) end
function tmp = code(i) t_0 = (2.0 * i) * (2.0 * i); tmp = (((i * i) * (i * i)) / t_0) / (t_0 - 1.0); end
code[i_] := Block[{t$95$0 = N[(N[(2.0 * i), $MachinePrecision] * N[(2.0 * i), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(i * i), $MachinePrecision] * N[(i * i), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\\
\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{t_0}}{t_0 - 1}
\end{array}
\end{array}
(FPCore (i) :precision binary64 (/ i (- (* i 16.0) (/ 4.0 i))))
double code(double i) {
return i / ((i * 16.0) - (4.0 / i));
}
real(8) function code(i)
real(8), intent (in) :: i
code = i / ((i * 16.0d0) - (4.0d0 / i))
end function
public static double code(double i) {
return i / ((i * 16.0) - (4.0 / i));
}
def code(i): return i / ((i * 16.0) - (4.0 / i))
function code(i) return Float64(i / Float64(Float64(i * 16.0) - Float64(4.0 / i))) end
function tmp = code(i) tmp = i / ((i * 16.0) - (4.0 / i)); end
code[i_] := N[(i / N[(N[(i * 16.0), $MachinePrecision] - N[(4.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{i}{i \cdot 16 - \frac{4}{i}}
\end{array}
Initial program 32.5%
sqr-neg32.5%
associate-*l*32.4%
swap-sqr32.4%
sqr-neg32.4%
times-frac40.3%
associate-/l*54.3%
*-inverses77.7%
/-rgt-identity77.7%
associate-/r/77.5%
swap-sqr77.5%
sqr-neg77.5%
swap-sqr77.5%
associate-/l/78.2%
Simplified78.2%
Taylor expanded in i around 0 99.1%
Taylor expanded in i around 0 99.1%
Final simplification99.1%
(FPCore (i) :precision binary64 (if (<= i 0.5) (* i (* i -0.25)) 0.0625))
double code(double i) {
double tmp;
if (i <= 0.5) {
tmp = i * (i * -0.25);
} else {
tmp = 0.0625;
}
return tmp;
}
real(8) function code(i)
real(8), intent (in) :: i
real(8) :: tmp
if (i <= 0.5d0) then
tmp = i * (i * (-0.25d0))
else
tmp = 0.0625d0
end if
code = tmp
end function
public static double code(double i) {
double tmp;
if (i <= 0.5) {
tmp = i * (i * -0.25);
} else {
tmp = 0.0625;
}
return tmp;
}
def code(i): tmp = 0 if i <= 0.5: tmp = i * (i * -0.25) else: tmp = 0.0625 return tmp
function code(i) tmp = 0.0 if (i <= 0.5) tmp = Float64(i * Float64(i * -0.25)); else tmp = 0.0625; end return tmp end
function tmp_2 = code(i) tmp = 0.0; if (i <= 0.5) tmp = i * (i * -0.25); else tmp = 0.0625; end tmp_2 = tmp; end
code[i_] := If[LessEqual[i, 0.5], N[(i * N[(i * -0.25), $MachinePrecision]), $MachinePrecision], 0.0625]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;i \cdot \left(i \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
\end{array}
if i < 0.5Initial program 35.3%
sqr-neg35.3%
associate-*l*35.3%
swap-sqr35.3%
sqr-neg35.3%
times-frac43.0%
associate-/l*55.2%
*-inverses100.0%
/-rgt-identity100.0%
associate-/r/99.8%
swap-sqr99.8%
sqr-neg99.8%
swap-sqr99.8%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in i around 0 97.8%
associate-/r/98.0%
div-inv98.0%
metadata-eval98.0%
Applied egg-rr98.0%
if 0.5 < i Initial program 29.4%
sqr-neg29.4%
associate-*l*29.3%
swap-sqr29.3%
sqr-neg29.3%
times-frac37.3%
associate-/l*53.3%
*-inverses53.3%
/-rgt-identity53.3%
associate-/r/53.0%
swap-sqr53.0%
sqr-neg53.0%
swap-sqr53.0%
associate-/l/54.5%
Simplified54.5%
Taylor expanded in i around inf 97.9%
Final simplification97.9%
(FPCore (i) :precision binary64 0.0625)
double code(double i) {
return 0.0625;
}
real(8) function code(i)
real(8), intent (in) :: i
code = 0.0625d0
end function
public static double code(double i) {
return 0.0625;
}
def code(i): return 0.0625
function code(i) return 0.0625 end
function tmp = code(i) tmp = 0.0625; end
code[i_] := 0.0625
\begin{array}{l}
\\
0.0625
\end{array}
Initial program 32.5%
sqr-neg32.5%
associate-*l*32.4%
swap-sqr32.4%
sqr-neg32.4%
times-frac40.3%
associate-/l*54.3%
*-inverses77.7%
/-rgt-identity77.7%
associate-/r/77.5%
swap-sqr77.5%
sqr-neg77.5%
swap-sqr77.5%
associate-/l/78.2%
Simplified78.2%
Taylor expanded in i around inf 48.0%
Final simplification48.0%
herbie shell --seed 2023336
(FPCore (i)
:name "Octave 3.8, jcobi/4, as called"
:precision binary64
:pre (> i 0.0)
(/ (/ (* (* i i) (* i i)) (* (* 2.0 i) (* 2.0 i))) (- (* (* 2.0 i) (* 2.0 i)) 1.0)))