
(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 5 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
(let* ((t_0 (* (* x x) (* x x))))
(if (<= x -4.7e+185)
t_0
(if (<= x 4.1e+114) (fma (* x x) (* x x) (- (pow y 4.0))) t_0))))
double code(double x, double y) {
double t_0 = (x * x) * (x * x);
double tmp;
if (x <= -4.7e+185) {
tmp = t_0;
} else if (x <= 4.1e+114) {
tmp = fma((x * x), (x * x), -pow(y, 4.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * x) * Float64(x * x)) tmp = 0.0 if (x <= -4.7e+185) tmp = t_0; elseif (x <= 4.1e+114) tmp = fma(Float64(x * x), Float64(x * x), Float64(-(y ^ 4.0))); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.7e+185], t$95$0, If[LessEqual[x, 4.1e+114], N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + (-N[Power[y, 4.0], $MachinePrecision])), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{if}\;x \leq -4.7 \cdot 10^{+185}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+114}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, x \cdot x, -{y}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.69999999999999972e185 or 4.1000000000000001e114 < x Initial program 66.7%
Taylor expanded in y around 0
lower-pow.f6489.4
Applied rewrites89.4%
Applied rewrites89.4%
if -4.69999999999999972e185 < x < 4.1000000000000001e114Initial program 95.8%
lift--.f64N/A
sub-negN/A
lift-pow.f64N/A
sqr-powN/A
lower-fma.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6499.4
Applied rewrites99.4%
(FPCore (x y) :precision binary64 (if (<= (- (pow x 4.0) (pow y 4.0)) -4e-313) (* (* (* (- 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)) <= -4e-313) {
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)) <= (-4d-313)) 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)) <= -4e-313) {
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)) <= -4e-313: 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)) <= -4e-313) tmp = Float64(Float64(Float64(Float64(-y) * y) * y) * y); else tmp = Float64(Float64(x * x) * Float64(x * x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x ^ 4.0) - (y ^ 4.0)) <= -4e-313) 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], -4e-313], N[(N[(N[((-y) * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} - {y}^{4} \leq -4 \cdot 10^{-313}:\\
\;\;\;\;\left(\left(\left(-y\right) \cdot y\right) \cdot y\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -4.0000000000037e-313Initial program 100.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f64N/A
lower-pow.f6499.2
Applied rewrites99.2%
Applied rewrites98.9%
if -4.0000000000037e-313 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) Initial program 81.5%
Taylor expanded in y around 0
lower-pow.f6491.1
Applied rewrites91.1%
Applied rewrites91.0%
(FPCore (x y) :precision binary64 (if (<= (- (pow x 4.0) (pow y 4.0)) -4e-313) (* (* 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)) <= -4e-313) {
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)) <= (-4d-313)) 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)) <= -4e-313) {
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)) <= -4e-313: 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)) <= -4e-313) tmp = Float64(Float64(y * y) * Float64(Float64(-y) * y)); else tmp = Float64(Float64(x * x) * Float64(x * x)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((x ^ 4.0) - (y ^ 4.0)) <= -4e-313) 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], -4e-313], N[(N[(y * y), $MachinePrecision] * N[((-y) * y), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} - {y}^{4} \leq -4 \cdot 10^{-313}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(\left(-y\right) \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -4.0000000000037e-313Initial program 100.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f64N/A
lower-pow.f6499.2
Applied rewrites99.2%
Applied rewrites98.9%
if -4.0000000000037e-313 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) Initial program 81.5%
Taylor expanded in y around 0
lower-pow.f6491.1
Applied rewrites91.1%
Applied rewrites91.0%
Final simplification93.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (* x x) (* x x))))
(if (<= x -4.7e+185)
t_0
(if (<= x 4.1e+114) (fma (* x x) (* x x) (* (* (* (- y) y) y) y)) t_0))))
double code(double x, double y) {
double t_0 = (x * x) * (x * x);
double tmp;
if (x <= -4.7e+185) {
tmp = t_0;
} else if (x <= 4.1e+114) {
tmp = fma((x * x), (x * x), (((-y * y) * y) * y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * x) * Float64(x * x)) tmp = 0.0 if (x <= -4.7e+185) tmp = t_0; elseif (x <= 4.1e+114) tmp = fma(Float64(x * x), Float64(x * x), Float64(Float64(Float64(Float64(-y) * y) * y) * y)); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.7e+185], t$95$0, If[LessEqual[x, 4.1e+114], N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[(N[(N[((-y) * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{if}\;x \leq -4.7 \cdot 10^{+185}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+114}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, x \cdot x, \left(\left(\left(-y\right) \cdot y\right) \cdot y\right) \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.69999999999999972e185 or 4.1000000000000001e114 < x Initial program 66.7%
Taylor expanded in y around 0
lower-pow.f6489.4
Applied rewrites89.4%
Applied rewrites89.4%
if -4.69999999999999972e185 < x < 4.1000000000000001e114Initial program 95.8%
lift--.f64N/A
sub-negN/A
lift-pow.f64N/A
sqr-powN/A
lower-fma.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6499.4
Applied rewrites99.4%
lift-neg.f64N/A
lift-pow.f64N/A
sqr-powN/A
distribute-lft-neg-inN/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6499.2
Applied rewrites99.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 88.3%
Taylor expanded in y around 0
lower-pow.f6458.6
Applied rewrites58.6%
Applied rewrites58.5%
herbie shell --seed 2024249
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))