
(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 4 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 (if (or (<= x -3.9e+154) (not (<= x 6.2e+100))) (* (* x x) (* x x)) (* (+ (* x x) (* y y)) (- (* x x) (* y y)))))
double code(double x, double y) {
double tmp;
if ((x <= -3.9e+154) || !(x <= 6.2e+100)) {
tmp = (x * x) * (x * x);
} else {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-3.9d+154)) .or. (.not. (x <= 6.2d+100))) then
tmp = (x * x) * (x * x)
else
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -3.9e+154) || !(x <= 6.2e+100)) {
tmp = (x * x) * (x * x);
} else {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -3.9e+154) or not (x <= 6.2e+100): tmp = (x * x) * (x * x) else: tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)) return tmp
function code(x, y) tmp = 0.0 if ((x <= -3.9e+154) || !(x <= 6.2e+100)) tmp = Float64(Float64(x * x) * Float64(x * x)); else tmp = Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x * x) - Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -3.9e+154) || ~((x <= 6.2e+100))) tmp = (x * x) * (x * x); else tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -3.9e+154], N[Not[LessEqual[x, 6.2e+100]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.9 \cdot 10^{+154} \lor \neg \left(x \leq 6.2 \cdot 10^{+100}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\end{array}
\end{array}
if x < -3.9000000000000003e154 or 6.20000000000000014e100 < x Initial program 56.5%
Taylor expanded in x around inf 95.7%
sqr-pow95.7%
metadata-eval95.7%
pow295.7%
metadata-eval95.7%
pow295.7%
Applied egg-rr95.7%
if -3.9000000000000003e154 < x < 6.20000000000000014e100Initial program 95.2%
sqr-pow95.0%
sqr-pow94.8%
difference-of-squares99.6%
metadata-eval99.6%
pow299.6%
metadata-eval99.6%
pow299.6%
metadata-eval99.6%
pow299.6%
metadata-eval99.6%
pow299.6%
Applied egg-rr99.6%
Final simplification98.6%
(FPCore (x y) :precision binary64 (if (or (<= y -5.2e-66) (not (<= y 1.3e-78))) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* x x))))
double code(double x, double y) {
double tmp;
if ((y <= -5.2e-66) || !(y <= 1.3e-78)) {
tmp = (y * y) * ((x * x) - (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 ((y <= (-5.2d-66)) .or. (.not. (y <= 1.3d-78))) then
tmp = (y * y) * ((x * x) - (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 ((y <= -5.2e-66) || !(y <= 1.3e-78)) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (x * x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -5.2e-66) or not (y <= 1.3e-78): tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * (x * x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -5.2e-66) || !(y <= 1.3e-78)) tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - 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 ((y <= -5.2e-66) || ~((y <= 1.3e-78))) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * (x * x); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -5.2e-66], N[Not[LessEqual[y, 1.3e-78]], $MachinePrecision]], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{-66} \lor \neg \left(y \leq 1.3 \cdot 10^{-78}\right):\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\end{array}
\end{array}
if y < -5.1999999999999998e-66 or 1.3000000000000001e-78 < y Initial program 75.5%
sqr-pow75.5%
sqr-pow75.3%
difference-of-squares91.6%
metadata-eval91.6%
pow291.6%
metadata-eval91.6%
pow291.6%
metadata-eval91.6%
pow291.6%
metadata-eval91.6%
pow291.6%
Applied egg-rr91.6%
Taylor expanded in x around 0 85.1%
unpow285.1%
Simplified85.1%
if -5.1999999999999998e-66 < y < 1.3000000000000001e-78Initial program 100.0%
Taylor expanded in x around inf 100.0%
sqr-pow99.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
Applied egg-rr99.7%
Final simplification90.6%
(FPCore (x y) :precision binary64 (if (or (<= x -5.3e-44) (not (<= x 8.2e+16))) (* (* x x) (* x x)) (* (* y y) (* y (- y)))))
double code(double x, double y) {
double tmp;
if ((x <= -5.3e-44) || !(x <= 8.2e+16)) {
tmp = (x * x) * (x * x);
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-5.3d-44)) .or. (.not. (x <= 8.2d+16))) then
tmp = (x * x) * (x * x)
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -5.3e-44) || !(x <= 8.2e+16)) {
tmp = (x * x) * (x * x);
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -5.3e-44) or not (x <= 8.2e+16): tmp = (x * x) * (x * x) else: tmp = (y * y) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -5.3e-44) || !(x <= 8.2e+16)) tmp = Float64(Float64(x * x) * Float64(x * x)); else tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -5.3e-44) || ~((x <= 8.2e+16))) tmp = (x * x) * (x * x); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -5.3e-44], N[Not[LessEqual[x, 8.2e+16]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.3 \cdot 10^{-44} \lor \neg \left(x \leq 8.2 \cdot 10^{+16}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if x < -5.29999999999999971e-44 or 8.2e16 < x Initial program 69.5%
Taylor expanded in x around inf 83.6%
sqr-pow83.4%
metadata-eval83.4%
pow283.4%
metadata-eval83.4%
pow283.4%
Applied egg-rr83.4%
if -5.29999999999999971e-44 < x < 8.2e16Initial program 100.0%
sqr-pow99.9%
sqr-pow99.7%
difference-of-squares99.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 88.6%
unpow288.6%
Simplified88.6%
Taylor expanded in x around 0 88.9%
unpow288.9%
mul-1-neg88.9%
distribute-rgt-neg-out88.9%
Simplified88.9%
Final simplification86.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 84.8%
Taylor expanded in x around inf 60.6%
sqr-pow60.4%
metadata-eval60.4%
pow260.4%
metadata-eval60.4%
pow260.4%
Applied egg-rr60.4%
Final simplification60.4%
herbie shell --seed 2023189
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))