
(FPCore (x y) :precision binary64 (+ (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (* 2.0 (* y y))))
double code(double x, double y) {
return ((9.0 * pow(x, 4.0)) - pow(y, 4.0)) + (2.0 * (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((9.0d0 * (x ** 4.0d0)) - (y ** 4.0d0)) + (2.0d0 * (y * y))
end function
public static double code(double x, double y) {
return ((9.0 * Math.pow(x, 4.0)) - Math.pow(y, 4.0)) + (2.0 * (y * y));
}
def code(x, y): return ((9.0 * math.pow(x, 4.0)) - math.pow(y, 4.0)) + (2.0 * (y * y))
function code(x, y) return Float64(Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0)) + Float64(2.0 * Float64(y * y))) end
function tmp = code(x, y) tmp = ((9.0 * (x ^ 4.0)) - (y ^ 4.0)) + (2.0 * (y * y)); end
code[x_, y_] := N[(N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\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)) (pow y 4.0)) (* 2.0 (* y y))))
double code(double x, double y) {
return ((9.0 * pow(x, 4.0)) - pow(y, 4.0)) + (2.0 * (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((9.0d0 * (x ** 4.0d0)) - (y ** 4.0d0)) + (2.0d0 * (y * y))
end function
public static double code(double x, double y) {
return ((9.0 * Math.pow(x, 4.0)) - Math.pow(y, 4.0)) + (2.0 * (y * y));
}
def code(x, y): return ((9.0 * math.pow(x, 4.0)) - math.pow(y, 4.0)) + (2.0 * (y * y))
function code(x, y) return Float64(Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0)) + Float64(2.0 * Float64(y * y))) end
function tmp = code(x, y) tmp = ((9.0 * (x ^ 4.0)) - (y ^ 4.0)) + (2.0 * (y * y)); end
code[x_, y_] := N[(N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right)
\end{array}
(FPCore (x y) :precision binary64 (fma (- 2.0 (* y y)) (* y y) (* (* (* x x) (* x x)) 9.0)))
double code(double x, double y) {
return fma((2.0 - (y * y)), (y * y), (((x * x) * (x * x)) * 9.0));
}
function code(x, y) return fma(Float64(2.0 - Float64(y * y)), Float64(y * y), Float64(Float64(Float64(x * x) * Float64(x * x)) * 9.0)) end
code[x_, y_] := N[(N[(2.0 - N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision] + N[(N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * 9.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(2 - y \cdot y, y \cdot y, \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot 9\right)
\end{array}
Initial program 18.8%
Taylor expanded in x around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6418.8%
Simplified18.8%
+-commutativeN/A
sub-negN/A
+-commutativeN/A
associate-+r+N/A
unsub-negN/A
associate-*r*N/A
distribute-rgt-out--N/A
*-commutativeN/A
fma-defineN/A
fma-lowering-fma.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
rem-exp-logN/A
pow-lowering-pow.f64N/A
rem-exp-log100.0%
Applied egg-rr100.0%
*-commutativeN/A
*-lowering-*.f64N/A
pow-to-expN/A
*-commutativeN/A
exp-prodN/A
metadata-evalN/A
prod-expN/A
unpow-prod-downN/A
*-lowering-*.f64N/A
pow-expN/A
*-commutativeN/A
exp-lft-sqrN/A
*-lowering-*.f64N/A
rem-exp-logN/A
rem-exp-logN/A
pow-expN/A
*-commutativeN/A
exp-lft-sqrN/A
*-lowering-*.f64N/A
rem-exp-logN/A
rem-exp-log100.0%
Applied egg-rr100.0%
(FPCore (x y) :precision binary64 (- (- (* (* x x) (* (* x x) 9.0)) (* y (* y (* y y)))) (* y (* y -2.0))))
double code(double x, double y) {
return (((x * x) * ((x * x) * 9.0)) - (y * (y * (y * y)))) - (y * (y * -2.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (((x * x) * ((x * x) * 9.0d0)) - (y * (y * (y * y)))) - (y * (y * (-2.0d0)))
end function
public static double code(double x, double y) {
return (((x * x) * ((x * x) * 9.0)) - (y * (y * (y * y)))) - (y * (y * -2.0));
}
def code(x, y): return (((x * x) * ((x * x) * 9.0)) - (y * (y * (y * y)))) - (y * (y * -2.0))
function code(x, y) return Float64(Float64(Float64(Float64(x * x) * Float64(Float64(x * x) * 9.0)) - Float64(y * Float64(y * Float64(y * y)))) - Float64(y * Float64(y * -2.0))) end
function tmp = code(x, y) tmp = (((x * x) * ((x * x) * 9.0)) - (y * (y * (y * y)))) - (y * (y * -2.0)); end
code[x_, y_] := N[(N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 9.0), $MachinePrecision]), $MachinePrecision] - N[(y * N[(y * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * N[(y * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 9\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)\right) - y \cdot \left(y \cdot -2\right)
\end{array}
Initial program 18.8%
Taylor expanded in x around 0
--lowering--.f64N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6418.8%
Simplified18.8%
+-commutativeN/A
sub-negN/A
+-commutativeN/A
associate-+r+N/A
unsub-negN/A
associate-*r*N/A
distribute-rgt-out--N/A
*-commutativeN/A
fma-defineN/A
fma-lowering-fma.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
rem-exp-logN/A
pow-lowering-pow.f64N/A
rem-exp-log100.0%
Applied egg-rr100.0%
*-commutativeN/A
sub-negN/A
distribute-lft-inN/A
associate-*r*N/A
associate-+l+N/A
+-commutativeN/A
cancel-sign-subN/A
--lowering--.f64N/A
Applied egg-rr18.8%
(FPCore (x y) :precision binary64 (- (* (* y y) (+ 2.0 (* y y))) (* y (* y (* y y)))))
double code(double x, double y) {
return ((y * y) * (2.0 + (y * y))) - (y * (y * (y * y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((y * y) * (2.0d0 + (y * y))) - (y * (y * (y * y)))
end function
public static double code(double x, double y) {
return ((y * y) * (2.0 + (y * y))) - (y * (y * (y * y)));
}
def code(x, y): return ((y * y) * (2.0 + (y * y))) - (y * (y * (y * y)))
function code(x, y) return Float64(Float64(Float64(y * y) * Float64(2.0 + Float64(y * y))) - Float64(y * Float64(y * Float64(y * y)))) end
function tmp = code(x, y) tmp = ((y * y) * (2.0 + (y * y))) - (y * (y * (y * y))); end
code[x_, y_] := N[(N[(N[(y * y), $MachinePrecision] * N[(2.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * N[(y * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y \cdot y\right) \cdot \left(2 + y \cdot y\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)
\end{array}
Initial program 18.8%
Taylor expanded in x around 0
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
pow-plusN/A
cancel-sign-sub-invN/A
unpow2N/A
associate-*r*N/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-rgt-outN/A
distribute-rgt-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f641.5%
Simplified1.5%
Taylor expanded in y around 0
Simplified11.1%
+-rgt-identityN/A
+-inversesN/A
sub-negN/A
distribute-rgt-neg-outN/A
+-commutativeN/A
associate-+r+N/A
associate-*r*N/A
distribute-lft-inN/A
sub-negN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
associate-*r*N/A
Applied egg-rr11.1%
Final simplification11.1%
(FPCore (x y) :precision binary64 (* y (* 2.0 y)))
double code(double x, double y) {
return y * (2.0 * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * (2.0d0 * y)
end function
public static double code(double x, double y) {
return y * (2.0 * y);
}
def code(x, y): return y * (2.0 * y)
function code(x, y) return Float64(y * Float64(2.0 * y)) end
function tmp = code(x, y) tmp = y * (2.0 * y); end
code[x_, y_] := N[(y * N[(2.0 * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(2 \cdot y\right)
\end{array}
Initial program 18.8%
Taylor expanded in x around 0
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
pow-plusN/A
cancel-sign-sub-invN/A
unpow2N/A
associate-*r*N/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-rgt-outN/A
distribute-rgt-inN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
unpow2N/A
*-lowering-*.f641.5%
Simplified1.5%
Taylor expanded in y around 0
Simplified11.1%
Final simplification11.1%
herbie shell --seed 2024164
(FPCore (x y)
:name "From Rump in a 1983 paper"
:precision binary64
:pre (and (== x 10864.0) (== y 18817.0))
(+ (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (* 2.0 (* y y))))