
(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 5 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 (/ 0.25 (- 4.0 (pow i -2.0))))
double code(double i) {
return 0.25 / (4.0 - pow(i, -2.0));
}
real(8) function code(i)
real(8), intent (in) :: i
code = 0.25d0 / (4.0d0 - (i ** (-2.0d0)))
end function
public static double code(double i) {
return 0.25 / (4.0 - Math.pow(i, -2.0));
}
def code(i): return 0.25 / (4.0 - math.pow(i, -2.0))
function code(i) return Float64(0.25 / Float64(4.0 - (i ^ -2.0))) end
function tmp = code(i) tmp = 0.25 / (4.0 - (i ^ -2.0)); end
code[i_] := N[(0.25 / N[(4.0 - N[Power[i, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.25}{4 - {i}^{-2}}
\end{array}
Initial program 38.3%
Simplified76.8%
Taylor expanded in i around inf 57.7%
*-un-lft-identity57.7%
pow-flip57.6%
metadata-eval57.6%
Applied egg-rr57.6%
*-lft-identity57.6%
Simplified57.6%
add-log-exp30.3%
*-un-lft-identity30.3%
log-prod30.3%
metadata-eval30.3%
add-log-exp57.6%
pow257.6%
associate-/r*57.6%
pow157.6%
pow257.6%
pow-div98.7%
metadata-eval98.7%
unpow-198.7%
Applied egg-rr98.7%
+-lft-identity98.7%
associate-*r*98.7%
associate-/l*98.7%
associate-*l*98.7%
rgt-mult-inverse98.8%
metadata-eval98.8%
Simplified98.8%
(FPCore (i) :precision binary64 (if (<= i 0.5) (* 0.25 (* i (- i))) 0.0625))
double code(double i) {
double tmp;
if (i <= 0.5) {
tmp = 0.25 * (i * -i);
} 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 = 0.25d0 * (i * -i)
else
tmp = 0.0625d0
end if
code = tmp
end function
public static double code(double i) {
double tmp;
if (i <= 0.5) {
tmp = 0.25 * (i * -i);
} else {
tmp = 0.0625;
}
return tmp;
}
def code(i): tmp = 0 if i <= 0.5: tmp = 0.25 * (i * -i) else: tmp = 0.0625 return tmp
function code(i) tmp = 0.0 if (i <= 0.5) tmp = Float64(0.25 * Float64(i * Float64(-i))); else tmp = 0.0625; end return tmp end
function tmp_2 = code(i) tmp = 0.0; if (i <= 0.5) tmp = 0.25 * (i * -i); else tmp = 0.0625; end tmp_2 = tmp; end
code[i_] := If[LessEqual[i, 0.5], N[(0.25 * N[(i * (-i)), $MachinePrecision]), $MachinePrecision], 0.0625]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;0.25 \cdot \left(i \cdot \left(-i\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
\end{array}
if i < 0.5Initial program 40.8%
Simplified100.0%
Taylor expanded in i around 0 97.9%
neg-mul-197.9%
Simplified97.9%
if 0.5 < i Initial program 35.9%
Simplified54.3%
Taylor expanded in i around inf 98.1%
(FPCore (i) :precision binary64 (/ 0.25 (- 4.0 (* (/ 1.0 i) (/ 1.0 i)))))
double code(double i) {
return 0.25 / (4.0 - ((1.0 / i) * (1.0 / i)));
}
real(8) function code(i)
real(8), intent (in) :: i
code = 0.25d0 / (4.0d0 - ((1.0d0 / i) * (1.0d0 / i)))
end function
public static double code(double i) {
return 0.25 / (4.0 - ((1.0 / i) * (1.0 / i)));
}
def code(i): return 0.25 / (4.0 - ((1.0 / i) * (1.0 / i)))
function code(i) return Float64(0.25 / Float64(4.0 - Float64(Float64(1.0 / i) * Float64(1.0 / i)))) end
function tmp = code(i) tmp = 0.25 / (4.0 - ((1.0 / i) * (1.0 / i))); end
code[i_] := N[(0.25 / N[(4.0 - N[(N[(1.0 / i), $MachinePrecision] * N[(1.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.25}{4 - \frac{1}{i} \cdot \frac{1}{i}}
\end{array}
Initial program 38.3%
Simplified76.8%
Taylor expanded in i around inf 57.7%
*-un-lft-identity57.7%
pow-flip57.6%
metadata-eval57.6%
Applied egg-rr57.6%
*-lft-identity57.6%
Simplified57.6%
add-log-exp30.3%
*-un-lft-identity30.3%
log-prod30.3%
metadata-eval30.3%
add-log-exp57.6%
pow257.6%
associate-/r*57.6%
pow157.6%
pow257.6%
pow-div98.7%
metadata-eval98.7%
unpow-198.7%
Applied egg-rr98.7%
+-lft-identity98.7%
associate-*r*98.7%
associate-/l*98.7%
associate-*l*98.7%
rgt-mult-inverse98.8%
metadata-eval98.8%
Simplified98.8%
sqr-pow98.7%
metadata-eval98.7%
unpow-198.7%
metadata-eval98.7%
unpow-198.7%
Applied egg-rr98.7%
(FPCore (i) :precision binary64 (if (<= i 0.8) (* 0.25 (* i i)) 0.0625))
double code(double i) {
double tmp;
if (i <= 0.8) {
tmp = 0.25 * (i * i);
} else {
tmp = 0.0625;
}
return tmp;
}
real(8) function code(i)
real(8), intent (in) :: i
real(8) :: tmp
if (i <= 0.8d0) then
tmp = 0.25d0 * (i * i)
else
tmp = 0.0625d0
end if
code = tmp
end function
public static double code(double i) {
double tmp;
if (i <= 0.8) {
tmp = 0.25 * (i * i);
} else {
tmp = 0.0625;
}
return tmp;
}
def code(i): tmp = 0 if i <= 0.8: tmp = 0.25 * (i * i) else: tmp = 0.0625 return tmp
function code(i) tmp = 0.0 if (i <= 0.8) tmp = Float64(0.25 * Float64(i * i)); else tmp = 0.0625; end return tmp end
function tmp_2 = code(i) tmp = 0.0; if (i <= 0.8) tmp = 0.25 * (i * i); else tmp = 0.0625; end tmp_2 = tmp; end
code[i_] := If[LessEqual[i, 0.8], N[(0.25 * N[(i * i), $MachinePrecision]), $MachinePrecision], 0.0625]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.8:\\
\;\;\;\;0.25 \cdot \left(i \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
\end{array}
if i < 0.80000000000000004Initial program 40.8%
Simplified100.0%
Taylor expanded in i around 0 97.9%
neg-mul-197.9%
Simplified97.9%
neg-sub097.9%
sub-neg97.9%
add-sqr-sqrt0.0%
sqrt-unprod41.3%
sqr-neg41.3%
sqrt-prod41.3%
add-sqr-sqrt41.3%
Applied egg-rr41.3%
+-lft-identity41.3%
Simplified41.3%
if 0.80000000000000004 < i Initial program 35.9%
Simplified54.3%
Taylor expanded in i around inf 98.1%
(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 38.3%
Simplified76.8%
Taylor expanded in i around inf 51.1%
herbie shell --seed 2024152
(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)))