
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
double code(double x, double y) {
return pow(x, 4.0) - pow(y, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x ** 4.0d0) - (y ** 4.0d0)
end function
public static double code(double x, double y) {
return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
def code(x, y): return math.pow(x, 4.0) - math.pow(y, 4.0)
function code(x, y) return Float64((x ^ 4.0) - (y ^ 4.0)) end
function tmp = code(x, y) tmp = (x ^ 4.0) - (y ^ 4.0); end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{4} - {y}^{4}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
double code(double x, double y) {
return pow(x, 4.0) - pow(y, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x ** 4.0d0) - (y ** 4.0d0)
end function
public static double code(double x, double y) {
return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
def code(x, y): return math.pow(x, 4.0) - math.pow(y, 4.0)
function code(x, y) return Float64((x ^ 4.0) - (y ^ 4.0)) end
function tmp = code(x, y) tmp = (x ^ 4.0) - (y ^ 4.0); end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{4} - {y}^{4}
\end{array}
(FPCore (x y) :precision binary64 (/ (- y x) (/ (/ -1.0 (+ x y)) (fma y y (* x x)))))
double code(double x, double y) {
return (y - x) / ((-1.0 / (x + y)) / fma(y, y, (x * x)));
}
function code(x, y) return Float64(Float64(y - x) / Float64(Float64(-1.0 / Float64(x + y)) / fma(y, y, Float64(x * x)))) end
code[x_, y_] := N[(N[(y - x), $MachinePrecision] / N[(N[(-1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(y * y + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y - x}{\frac{\frac{-1}{x + y}}{\mathsf{fma}\left(y, y, x \cdot x\right)}}
\end{array}
Initial program 86.3%
lift--.f64N/A
lift-pow.f64N/A
sqr-powN/A
lift-pow.f64N/A
sqr-powN/A
difference-of-squaresN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
unpow2N/A
lower-fma.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
metadata-evalN/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
un-div-invN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f64N/A
div-invN/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
sub-negN/A
lower--.f64N/A
lift-/.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-/r*N/A
div-invN/A
lift-/.f64N/A
neg-mul-1N/A
lower-/.f64N/A
neg-mul-1N/A
lift-/.f64N/A
div-invN/A
lower-/.f6499.8
Applied rewrites99.8%
(FPCore (x y) :precision binary64 (if (<= (- (pow x 4.0) (pow y 4.0)) -2e-280) (* (* (* (- y) y) y) y) (* (* (* x x) x) x)))
double code(double x, double y) {
double tmp;
if ((pow(x, 4.0) - pow(y, 4.0)) <= -2e-280) {
tmp = ((-y * y) * y) * y;
} else {
tmp = ((x * x) * x) * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (((x ** 4.0d0) - (y ** 4.0d0)) <= (-2d-280)) then
tmp = ((-y * y) * y) * y
else
tmp = ((x * x) * x) * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.pow(x, 4.0) - Math.pow(y, 4.0)) <= -2e-280) {
tmp = ((-y * y) * y) * y;
} else {
tmp = ((x * x) * x) * x;
}
return tmp;
}
def code(x, y): tmp = 0 if (math.pow(x, 4.0) - math.pow(y, 4.0)) <= -2e-280: tmp = ((-y * y) * y) * y else: tmp = ((x * x) * x) * x return tmp
function code(x, y) tmp = 0.0 if (Float64((x ^ 4.0) - (y ^ 4.0)) <= -2e-280) tmp = Float64(Float64(Float64(Float64(-y) * y) * y) * y); else tmp = Float64(Float64(Float64(x * x) * x) * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x ^ 4.0) - (y ^ 4.0)) <= -2e-280) tmp = ((-y * y) * y) * y; else tmp = ((x * x) * x) * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], -2e-280], N[(N[(N[((-y) * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} - {y}^{4} \leq -2 \cdot 10^{-280}:\\
\;\;\;\;\left(\left(\left(-y\right) \cdot y\right) \cdot y\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot x\right) \cdot x\\
\end{array}
\end{array}
if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -1.9999999999999999e-280Initial program 100.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f64N/A
lower-pow.f6499.5
Applied rewrites99.5%
Applied rewrites99.3%
if -1.9999999999999999e-280 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) Initial program 78.7%
Taylor expanded in y around 0
lower-pow.f6491.5
Applied rewrites91.5%
Applied rewrites91.4%
(FPCore (x y) :precision binary64 (if (<= (- (pow x 4.0) (pow y 4.0)) -2e-280) (* (* (- y) y) (* y y)) (* (* (* x x) x) x)))
double code(double x, double y) {
double tmp;
if ((pow(x, 4.0) - pow(y, 4.0)) <= -2e-280) {
tmp = (-y * y) * (y * y);
} else {
tmp = ((x * x) * x) * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (((x ** 4.0d0) - (y ** 4.0d0)) <= (-2d-280)) then
tmp = (-y * y) * (y * y)
else
tmp = ((x * x) * x) * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.pow(x, 4.0) - Math.pow(y, 4.0)) <= -2e-280) {
tmp = (-y * y) * (y * y);
} else {
tmp = ((x * x) * x) * x;
}
return tmp;
}
def code(x, y): tmp = 0 if (math.pow(x, 4.0) - math.pow(y, 4.0)) <= -2e-280: tmp = (-y * y) * (y * y) else: tmp = ((x * x) * x) * x return tmp
function code(x, y) tmp = 0.0 if (Float64((x ^ 4.0) - (y ^ 4.0)) <= -2e-280) tmp = Float64(Float64(Float64(-y) * y) * Float64(y * y)); else tmp = Float64(Float64(Float64(x * x) * x) * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x ^ 4.0) - (y ^ 4.0)) <= -2e-280) tmp = (-y * y) * (y * y); else tmp = ((x * x) * x) * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], -2e-280], N[(N[((-y) * y), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} - {y}^{4} \leq -2 \cdot 10^{-280}:\\
\;\;\;\;\left(\left(-y\right) \cdot y\right) \cdot \left(y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot x\right) \cdot x\\
\end{array}
\end{array}
if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -1.9999999999999999e-280Initial program 100.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f64N/A
lower-pow.f6499.5
Applied rewrites99.5%
Applied rewrites99.2%
if -1.9999999999999999e-280 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) Initial program 78.7%
Taylor expanded in y around 0
lower-pow.f6491.5
Applied rewrites91.5%
Applied rewrites91.4%
(FPCore (x y) :precision binary64 (/ (- y x) (/ -1.0 (* (fma y y (* x x)) (+ x y)))))
double code(double x, double y) {
return (y - x) / (-1.0 / (fma(y, y, (x * x)) * (x + y)));
}
function code(x, y) return Float64(Float64(y - x) / Float64(-1.0 / Float64(fma(y, y, Float64(x * x)) * Float64(x + y)))) end
code[x_, y_] := N[(N[(y - x), $MachinePrecision] / N[(-1.0 / N[(N[(y * y + N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y - x}{\frac{-1}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x + y\right)}}
\end{array}
Initial program 86.3%
lift--.f64N/A
lift-pow.f64N/A
sqr-powN/A
lift-pow.f64N/A
sqr-powN/A
difference-of-squaresN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
unpow2N/A
lower-fma.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
metadata-evalN/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
un-div-invN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f64N/A
div-invN/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
sub-negN/A
lower--.f64N/A
lift-/.f64N/A
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (/ (* (- x y) (fma y y (* x x))) (/ 1.0 (+ x y))))
double code(double x, double y) {
return ((x - y) * fma(y, y, (x * x))) / (1.0 / (x + y));
}
function code(x, y) return Float64(Float64(Float64(x - y) * fma(y, y, Float64(x * x))) / Float64(1.0 / Float64(x + y))) end
code[x_, y_] := N[(N[(N[(x - y), $MachinePrecision] * N[(y * y + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x - y\right) \cdot \mathsf{fma}\left(y, y, x \cdot x\right)}{\frac{1}{x + y}}
\end{array}
Initial program 86.3%
lift--.f64N/A
lift-pow.f64N/A
sqr-powN/A
lift-pow.f64N/A
sqr-powN/A
difference-of-squaresN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
unpow2N/A
lower-fma.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
metadata-evalN/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
un-div-invN/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
(FPCore (x y) :precision binary64 (* (/ (- x y) (/ 1.0 (+ x y))) (fma y y (* x x))))
double code(double x, double y) {
return ((x - y) / (1.0 / (x + y))) * fma(y, y, (x * x));
}
function code(x, y) return Float64(Float64(Float64(x - y) / Float64(1.0 / Float64(x + y))) * fma(y, y, Float64(x * x))) end
code[x_, y_] := N[(N[(N[(x - y), $MachinePrecision] / N[(1.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y * y + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{\frac{1}{x + y}} \cdot \mathsf{fma}\left(y, y, x \cdot x\right)
\end{array}
Initial program 86.3%
lift--.f64N/A
lift-pow.f64N/A
sqr-powN/A
lift-pow.f64N/A
sqr-powN/A
difference-of-squaresN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
unpow2N/A
lower-fma.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
metadata-evalN/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (* (* (- x y) (+ x y)) (fma x x (* y y))))
double code(double x, double y) {
return ((x - y) * (x + y)) * fma(x, x, (y * y));
}
function code(x, y) return Float64(Float64(Float64(x - y) * Float64(x + y)) * fma(x, x, Float64(y * y))) end
code[x_, y_] := N[(N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x * x + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - y\right) \cdot \left(x + y\right)\right) \cdot \mathsf{fma}\left(x, x, y \cdot y\right)
\end{array}
Initial program 86.3%
lift--.f64N/A
lift-pow.f64N/A
sqr-powN/A
lift-pow.f64N/A
sqr-powN/A
difference-of-squaresN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
unpow2N/A
lower-fma.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
metadata-evalN/A
unpow2N/A
difference-of-squaresN/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6499.8
Applied rewrites99.8%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x y) :precision binary64 (* (* (* x x) x) x))
double code(double x, double y) {
return ((x * x) * x) * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * x) * x) * x
end function
public static double code(double x, double y) {
return ((x * x) * x) * x;
}
def code(x, y): return ((x * x) * x) * x
function code(x, y) return Float64(Float64(Float64(x * x) * x) * x) end
function tmp = code(x, y) tmp = ((x * x) * x) * x; end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot x\right) \cdot x\right) \cdot x
\end{array}
Initial program 86.3%
Taylor expanded in y around 0
lower-pow.f6459.3
Applied rewrites59.3%
Applied rewrites59.2%
(FPCore (x y) :precision binary64 (* (* x x) (* x x)))
double code(double x, double y) {
return (x * x) * (x * x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * x) * (x * x)
end function
public static double code(double x, double y) {
return (x * x) * (x * x);
}
def code(x, y): return (x * x) * (x * x)
function code(x, y) return Float64(Float64(x * x) * Float64(x * x)) end
function tmp = code(x, y) tmp = (x * x) * (x * x); end
code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(x \cdot x\right)
\end{array}
Initial program 86.3%
Taylor expanded in y around 0
lower-pow.f6459.3
Applied rewrites59.3%
Applied rewrites59.1%
herbie shell --seed 2024235
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))