
(FPCore (x y) :precision binary64 (- (* 9.0 (pow x 4.0)) (* (* y y) (- (* y y) 2.0))))
double code(double x, double y) {
return (9.0 * pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (9.0d0 * (x ** 4.0d0)) - ((y * y) * ((y * y) - 2.0d0))
end function
public static double code(double x, double y) {
return (9.0 * Math.pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0));
}
def code(x, y): return (9.0 * math.pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0))
function code(x, y) return Float64(Float64(9.0 * (x ^ 4.0)) - Float64(Float64(y * y) * Float64(Float64(y * y) - 2.0))) end
function tmp = code(x, y) tmp = (9.0 * (x ^ 4.0)) - ((y * y) * ((y * y) - 2.0)); end
code[x_, y_] := N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
9 \cdot {x}^{4} - \left(y \cdot y\right) \cdot \left(y \cdot y - 2\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (* 9.0 (pow x 4.0)) (* (* y y) (- (* y y) 2.0))))
double code(double x, double y) {
return (9.0 * pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (9.0d0 * (x ** 4.0d0)) - ((y * y) * ((y * y) - 2.0d0))
end function
public static double code(double x, double y) {
return (9.0 * Math.pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0));
}
def code(x, y): return (9.0 * math.pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0))
function code(x, y) return Float64(Float64(9.0 * (x ^ 4.0)) - Float64(Float64(y * y) * Float64(Float64(y * y) - 2.0))) end
function tmp = code(x, y) tmp = (9.0 * (x ^ 4.0)) - ((y * y) * ((y * y) - 2.0)); end
code[x_, y_] := N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
9 \cdot {x}^{4} - \left(y \cdot y\right) \cdot \left(y \cdot y - 2\right)
\end{array}
(FPCore (x y) :precision binary64 (fma (- y) (* y (fma y y -2.0)) (* 9.0 (pow x 4.0))))
double code(double x, double y) {
return fma(-y, (y * fma(y, y, -2.0)), (9.0 * pow(x, 4.0)));
}
function code(x, y) return fma(Float64(-y), Float64(y * fma(y, y, -2.0)), Float64(9.0 * (x ^ 4.0))) end
code[x_, y_] := N[((-y) * N[(y * N[(y * y + -2.0), $MachinePrecision]), $MachinePrecision] + N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-y, y \cdot \mathsf{fma}\left(y, y, -2\right), 9 \cdot {x}^{4}\right)
\end{array}
Initial program 3.1%
sub-neg3.1%
+-commutative3.1%
associate-*l*3.1%
distribute-lft-neg-in3.1%
fma-define100.0%
fmm-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
(FPCore (x y) :precision binary64 (+ (* 9.0 (exp (* 4.0 (log x)))) (* (* y y) (- 2.0 (* y y)))))
double code(double x, double y) {
return (9.0 * exp((4.0 * log(x)))) + ((y * y) * (2.0 - (y * y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (9.0d0 * exp((4.0d0 * log(x)))) + ((y * y) * (2.0d0 - (y * y)))
end function
public static double code(double x, double y) {
return (9.0 * Math.exp((4.0 * Math.log(x)))) + ((y * y) * (2.0 - (y * y)));
}
def code(x, y): return (9.0 * math.exp((4.0 * math.log(x)))) + ((y * y) * (2.0 - (y * y)))
function code(x, y) return Float64(Float64(9.0 * exp(Float64(4.0 * log(x)))) + Float64(Float64(y * y) * Float64(2.0 - Float64(y * y)))) end
function tmp = code(x, y) tmp = (9.0 * exp((4.0 * log(x)))) + ((y * y) * (2.0 - (y * y))); end
code[x_, y_] := N[(N[(9.0 * N[Exp[N[(4.0 * N[Log[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(y * y), $MachinePrecision] * N[(2.0 - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
9 \cdot e^{4 \cdot \log x} + \left(y \cdot y\right) \cdot \left(2 - y \cdot y\right)
\end{array}
Initial program 3.1%
add-exp-log14.1%
log-pow14.1%
Applied egg-rr14.1%
Final simplification14.1%
(FPCore (x y) :precision binary64 (* 9.0 (pow x 4.0)))
double code(double x, double y) {
return 9.0 * pow(x, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 9.0d0 * (x ** 4.0d0)
end function
public static double code(double x, double y) {
return 9.0 * Math.pow(x, 4.0);
}
def code(x, y): return 9.0 * math.pow(x, 4.0)
function code(x, y) return Float64(9.0 * (x ^ 4.0)) end
function tmp = code(x, y) tmp = 9.0 * (x ^ 4.0); end
code[x_, y_] := N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
9 \cdot {x}^{4}
\end{array}
Initial program 3.1%
Taylor expanded in x around inf 9.6%
(FPCore (x y) :precision binary64 (pow y 4.0))
double code(double x, double y) {
return pow(y, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y ** 4.0d0
end function
public static double code(double x, double y) {
return Math.pow(y, 4.0);
}
def code(x, y): return math.pow(y, 4.0)
function code(x, y) return y ^ 4.0 end
function tmp = code(x, y) tmp = y ^ 4.0; end
code[x_, y_] := N[Power[y, 4.0], $MachinePrecision]
\begin{array}{l}
\\
{y}^{4}
\end{array}
Initial program 3.1%
Taylor expanded in y around inf 1.5%
mul-1-neg1.5%
Simplified1.5%
neg-sub01.5%
sub-neg1.5%
add-sqr-sqrt0.0%
sqrt-unprod9.6%
sqr-neg9.6%
sqrt-unprod9.6%
add-sqr-sqrt9.6%
Applied egg-rr9.6%
+-lft-identity9.6%
Simplified9.6%
herbie shell --seed 2024132
(FPCore (x y)
:name "From Rump in a 1983 paper, rewritten"
:precision binary64
:pre (and (== x 10864.0) (== y 18817.0))
(- (* 9.0 (pow x 4.0)) (* (* y y) (- (* y y) 2.0))))