
(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 6 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 (if (<= i 5000.0) (/ (* i i) (fma (* i i) 16.0 -4.0)) 0.0625))
double code(double i) {
double tmp;
if (i <= 5000.0) {
tmp = (i * i) / fma((i * i), 16.0, -4.0);
} else {
tmp = 0.0625;
}
return tmp;
}
function code(i) tmp = 0.0 if (i <= 5000.0) tmp = Float64(Float64(i * i) / fma(Float64(i * i), 16.0, -4.0)); else tmp = 0.0625; end return tmp end
code[i_] := If[LessEqual[i, 5000.0], N[(N[(i * i), $MachinePrecision] / N[(N[(i * i), $MachinePrecision] * 16.0 + -4.0), $MachinePrecision]), $MachinePrecision], 0.0625]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 5000:\\
\;\;\;\;\frac{i \cdot i}{\mathsf{fma}\left(i \cdot i, 16, -4\right)}\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
\end{array}
if i < 5e3Initial program 28.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
times-fracN/A
clear-numN/A
frac-timesN/A
*-rgt-identityN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
Applied rewrites100.0%
lift-*.f64N/A
lift-fma.f64N/A
metadata-evalN/A
lift-*.f64N/A
swap-sqrN/A
distribute-rgt-inN/A
swap-sqrN/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-eval100.0
Applied rewrites100.0%
if 5e3 < i Initial program 25.3%
Taylor expanded in i around inf
Applied rewrites100.0%
(FPCore (i) :precision binary64 (if (<= i 0.5) (* (* (- -0.25 (* i i)) i) i) (+ (/ 0.015625 (* i i)) 0.0625)))
double code(double i) {
double tmp;
if (i <= 0.5) {
tmp = ((-0.25 - (i * i)) * i) * i;
} else {
tmp = (0.015625 / (i * i)) + 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)) * i) * i
else
tmp = (0.015625d0 / (i * i)) + 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)) * i) * i;
} else {
tmp = (0.015625 / (i * i)) + 0.0625;
}
return tmp;
}
def code(i): tmp = 0 if i <= 0.5: tmp = ((-0.25 - (i * i)) * i) * i else: tmp = (0.015625 / (i * i)) + 0.0625 return tmp
function code(i) tmp = 0.0 if (i <= 0.5) tmp = Float64(Float64(Float64(-0.25 - Float64(i * i)) * i) * i); else tmp = Float64(Float64(0.015625 / Float64(i * i)) + 0.0625); end return tmp end
function tmp_2 = code(i) tmp = 0.0; if (i <= 0.5) tmp = ((-0.25 - (i * i)) * i) * i; else tmp = (0.015625 / (i * i)) + 0.0625; end tmp_2 = tmp; end
code[i_] := If[LessEqual[i, 0.5], N[(N[(N[(-0.25 - N[(i * i), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision] * i), $MachinePrecision], N[(N[(0.015625 / N[(i * i), $MachinePrecision]), $MachinePrecision] + 0.0625), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;\left(\left(-0.25 - i \cdot i\right) \cdot i\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;\frac{0.015625}{i \cdot i} + 0.0625\\
\end{array}
\end{array}
if i < 0.5Initial program 26.6%
Taylor expanded in i around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
if 0.5 < i Initial program 27.1%
Taylor expanded in i around inf
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
lower-*.f6499.4
Applied rewrites99.4%
(FPCore (i) :precision binary64 (if (<= i 0.5) (* (* (- -0.25 (* i i)) i) i) 0.0625))
double code(double i) {
double tmp;
if (i <= 0.5) {
tmp = ((-0.25 - (i * i)) * 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)) * 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)) * i) * i;
} else {
tmp = 0.0625;
}
return tmp;
}
def code(i): tmp = 0 if i <= 0.5: tmp = ((-0.25 - (i * i)) * i) * i else: tmp = 0.0625 return tmp
function code(i) tmp = 0.0 if (i <= 0.5) tmp = Float64(Float64(Float64(-0.25 - Float64(i * i)) * i) * 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)) * i) * i; else tmp = 0.0625; end tmp_2 = tmp; end
code[i_] := If[LessEqual[i, 0.5], N[(N[(N[(-0.25 - N[(i * i), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision] * i), $MachinePrecision], 0.0625]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;\left(\left(-0.25 - i \cdot i\right) \cdot i\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
\end{array}
if i < 0.5Initial program 26.6%
Taylor expanded in i around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
if 0.5 < i Initial program 27.1%
Taylor expanded in i around inf
Applied rewrites98.7%
(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(Float64(-0.25 * i) * 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[(N[(-0.25 * i), $MachinePrecision] * i), $MachinePrecision], 0.0625]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;\left(-0.25 \cdot i\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
\end{array}
if i < 0.5Initial program 26.6%
Taylor expanded in i around 0
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in i around 0
Applied rewrites99.0%
if 0.5 < i Initial program 27.1%
Taylor expanded in i around inf
Applied rewrites98.7%
(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 * 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 i\right)\\
\mathbf{else}:\\
\;\;\;\;0.0625\\
\end{array}
\end{array}
if i < 0.5Initial program 26.6%
Taylor expanded in i around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6499.0
Applied rewrites99.0%
if 0.5 < i Initial program 27.1%
Taylor expanded in i around inf
Applied rewrites98.7%
(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 26.9%
Taylor expanded in i around inf
Applied rewrites48.1%
herbie shell --seed 2024331
(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)))