
(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 (* (+ (* x x) (* y y)) (* (- x y) (+ x y))))
double code(double x, double y) {
return ((x * x) + (y * y)) * ((x - y) * (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * x) + (y * y)) * ((x - y) * (x + y))
end function
public static double code(double x, double y) {
return ((x * x) + (y * y)) * ((x - y) * (x + y));
}
def code(x, y): return ((x * x) + (y * y)) * ((x - y) * (x + y))
function code(x, y) return Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x - y) * Float64(x + y))) end
function tmp = code(x, y) tmp = ((x * x) + (y * y)) * ((x - y) * (x + y)); end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x + y \cdot y\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)
\end{array}
Initial program 86.3%
sqr-pow86.2%
sqr-pow86.2%
difference-of-squares95.9%
metadata-eval95.9%
pow295.9%
metadata-eval95.9%
pow295.9%
metadata-eval95.9%
pow295.9%
metadata-eval95.9%
pow295.9%
Applied egg-rr95.9%
difference-of-squares99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y 1.72e-28)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 9.2e+149)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))
double code(double x, double y) {
double tmp;
if (y <= 1.72e-28) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 9.2e+149) {
tmp = (y * y) * ((x * x) - (y * y));
} 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 (y <= 1.72d-28) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 9.2d+149) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.72e-28) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 9.2e+149) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.72e-28: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 9.2e+149: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.72e-28) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 9.2e+149) tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.72e-28) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 9.2e+149) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.72e-28], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.2e+149], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.72 \cdot 10^{-28}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+149}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 1.7199999999999999e-28Initial program 88.0%
sqr-pow87.9%
sqr-pow87.9%
difference-of-squares97.1%
metadata-eval97.1%
pow297.1%
metadata-eval97.1%
pow297.1%
metadata-eval97.1%
pow297.1%
metadata-eval97.1%
pow297.1%
Applied egg-rr97.1%
Taylor expanded in x around inf 70.2%
unpow270.2%
Simplified70.2%
if 1.7199999999999999e-28 < y < 9.1999999999999993e149Initial program 90.4%
sqr-pow90.4%
sqr-pow90.3%
difference-of-squares99.8%
metadata-eval99.8%
pow299.8%
metadata-eval99.8%
pow299.8%
metadata-eval99.8%
pow299.8%
metadata-eval99.8%
pow299.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 85.5%
unpow285.5%
Simplified85.5%
if 9.1999999999999993e149 < y Initial program 70.0%
sqr-pow70.0%
sqr-pow70.0%
difference-of-squares83.3%
metadata-eval83.3%
pow283.3%
metadata-eval83.3%
pow283.3%
metadata-eval83.3%
pow283.3%
metadata-eval83.3%
pow283.3%
Applied egg-rr83.3%
Taylor expanded in x around 0 83.3%
unpow283.3%
Simplified83.3%
Taylor expanded in x around 0 93.3%
unpow293.3%
mul-1-neg93.3%
distribute-rgt-neg-out93.3%
Simplified93.3%
Final simplification75.4%
(FPCore (x y) :precision binary64 (if (<= y 1e+148) (* (* y y) (- (* x x) (* y y))) (* (* y y) (* y (- y)))))
double code(double x, double y) {
double tmp;
if (y <= 1e+148) {
tmp = (y * y) * ((x * x) - (y * y));
} 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 (y <= 1d+148) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1e+148) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1e+148: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1e+148) tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1e+148) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1e+148], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+148}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 1e148Initial program 88.5%
sqr-pow88.4%
sqr-pow88.3%
difference-of-squares97.6%
metadata-eval97.6%
pow297.6%
metadata-eval97.6%
pow297.6%
metadata-eval97.6%
pow297.6%
metadata-eval97.6%
pow297.6%
Applied egg-rr97.6%
Taylor expanded in x around 0 73.3%
unpow273.3%
Simplified73.3%
if 1e148 < y Initial program 70.0%
sqr-pow70.0%
sqr-pow70.0%
difference-of-squares83.3%
metadata-eval83.3%
pow283.3%
metadata-eval83.3%
pow283.3%
metadata-eval83.3%
pow283.3%
metadata-eval83.3%
pow283.3%
Applied egg-rr83.3%
Taylor expanded in x around 0 83.3%
unpow283.3%
Simplified83.3%
Taylor expanded in x around 0 93.3%
unpow293.3%
mul-1-neg93.3%
distribute-rgt-neg-out93.3%
Simplified93.3%
Final simplification75.6%
(FPCore (x y) :precision binary64 (if (<= x 1.35e+104) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 1.35e+104) {
tmp = (y * y) * (y * -y);
} else {
tmp = (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 <= 1.35d+104) then
tmp = (y * y) * (y * -y)
else
tmp = (x * x) * (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.35e+104) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.35e+104: tmp = (y * y) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.35e+104) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); else tmp = Float64(Float64(x * x) * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.35e+104) tmp = (y * y) * (y * -y); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.35e+104], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+104}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if x < 1.34999999999999992e104Initial program 88.3%
sqr-pow88.2%
sqr-pow88.1%
difference-of-squares97.6%
metadata-eval97.6%
pow297.6%
metadata-eval97.6%
pow297.6%
metadata-eval97.6%
pow297.6%
metadata-eval97.6%
pow297.6%
Applied egg-rr97.6%
Taylor expanded in x around 0 76.3%
unpow276.3%
Simplified76.3%
Taylor expanded in x around 0 66.8%
unpow266.8%
mul-1-neg66.8%
distribute-rgt-neg-out66.8%
Simplified66.8%
if 1.34999999999999992e104 < x Initial program 73.5%
sqr-pow73.5%
sqr-pow73.5%
difference-of-squares85.3%
metadata-eval85.3%
pow285.3%
metadata-eval85.3%
pow285.3%
metadata-eval85.3%
pow285.3%
metadata-eval85.3%
pow285.3%
Applied egg-rr85.3%
Taylor expanded in x around 0 62.3%
unpow262.3%
Simplified62.3%
Taylor expanded in y around 0 62.3%
unpow262.3%
unpow262.3%
Simplified62.3%
Final simplification66.2%
(FPCore (x y) :precision binary64 (* (* x x) (* y y)))
double code(double x, double y) {
return (x * x) * (y * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * x) * (y * y)
end function
public static double code(double x, double y) {
return (x * x) * (y * y);
}
def code(x, y): return (x * x) * (y * y)
function code(x, y) return Float64(Float64(x * x) * Float64(y * y)) end
function tmp = code(x, y) tmp = (x * x) * (y * y); end
code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(y \cdot y\right)
\end{array}
Initial program 86.3%
sqr-pow86.2%
sqr-pow86.2%
difference-of-squares95.9%
metadata-eval95.9%
pow295.9%
metadata-eval95.9%
pow295.9%
metadata-eval95.9%
pow295.9%
metadata-eval95.9%
pow295.9%
Applied egg-rr95.9%
Taylor expanded in x around 0 74.5%
unpow274.5%
Simplified74.5%
Taylor expanded in y around 0 37.5%
unpow237.5%
unpow237.5%
Simplified37.5%
Final simplification37.5%
herbie shell --seed 2023258
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))