
(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) (* y y)))) (if (<= x 6.2e+124) (* t_0 (- (* x x) (* y y))) (* (* x x) t_0))))
double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= 6.2e+124) {
tmp = t_0 * ((x * x) - (y * y));
} else {
tmp = (x * x) * t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x * x) + (y * y)
if (x <= 6.2d+124) then
tmp = t_0 * ((x * x) - (y * y))
else
tmp = (x * x) * t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= 6.2e+124) {
tmp = t_0 * ((x * x) - (y * y));
} else {
tmp = (x * x) * t_0;
}
return tmp;
}
def code(x, y): t_0 = (x * x) + (y * y) tmp = 0 if x <= 6.2e+124: tmp = t_0 * ((x * x) - (y * y)) else: tmp = (x * x) * t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x * x) + Float64(y * y)) tmp = 0.0 if (x <= 6.2e+124) tmp = Float64(t_0 * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(x * x) * t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = (x * x) + (y * y); tmp = 0.0; if (x <= 6.2e+124) tmp = t_0 * ((x * x) - (y * y)); else tmp = (x * x) * t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 6.2e+124], N[(t$95$0 * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot x + y \cdot y\\
\mathbf{if}\;x \leq 6.2 \cdot 10^{+124}:\\
\;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot t_0\\
\end{array}
\end{array}
if x < 6.2000000000000004e124Initial program 93.0%
sqr-pow92.9%
sqr-pow92.9%
difference-of-squares97.5%
metadata-eval97.5%
pow297.5%
metadata-eval97.5%
pow297.5%
metadata-eval97.5%
pow297.5%
metadata-eval97.5%
pow297.5%
Applied egg-rr97.5%
if 6.2000000000000004e124 < x Initial program 65.9%
sqr-pow65.9%
sqr-pow65.9%
difference-of-squares75.6%
metadata-eval75.6%
pow275.6%
metadata-eval75.6%
pow275.6%
metadata-eval75.6%
pow275.6%
metadata-eval75.6%
pow275.6%
Applied egg-rr75.6%
Taylor expanded in x around inf 87.8%
unpow287.8%
Simplified87.8%
Final simplification96.0%
(FPCore (x y)
:precision binary64
(if (<= y -1.85e+168)
(* (* y y) (* y (- y)))
(if (or (<= y -2.65e-33) (not (<= y 2.2e-30)))
(* (* y y) (- (* x x) (* y y)))
(* (* x x) (+ (* x x) (* y y))))))
double code(double x, double y) {
double tmp;
if (y <= -1.85e+168) {
tmp = (y * y) * (y * -y);
} else if ((y <= -2.65e-33) || !(y <= 2.2e-30)) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * ((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 (y <= (-1.85d+168)) then
tmp = (y * y) * (y * -y)
else if ((y <= (-2.65d-33)) .or. (.not. (y <= 2.2d-30))) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (x * x) * ((x * x) + (y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.85e+168) {
tmp = (y * y) * (y * -y);
} else if ((y <= -2.65e-33) || !(y <= 2.2e-30)) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.85e+168: tmp = (y * y) * (y * -y) elif (y <= -2.65e-33) or not (y <= 2.2e-30): tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * ((x * x) + (y * y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.85e+168) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); elseif ((y <= -2.65e-33) || !(y <= 2.2e-30)) tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.85e+168) tmp = (y * y) * (y * -y); elseif ((y <= -2.65e-33) || ~((y <= 2.2e-30))) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * ((x * x) + (y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.85e+168], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -2.65e-33], N[Not[LessEqual[y, 2.2e-30]], $MachinePrecision]], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{+168}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\mathbf{elif}\;y \leq -2.65 \cdot 10^{-33} \lor \neg \left(y \leq 2.2 \cdot 10^{-30}\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 + y \cdot y\right)\\
\end{array}
\end{array}
if y < -1.85000000000000005e168Initial program 56.0%
sqr-pow56.0%
sqr-pow56.0%
difference-of-squares64.0%
metadata-eval64.0%
pow264.0%
metadata-eval64.0%
pow264.0%
metadata-eval64.0%
pow264.0%
metadata-eval64.0%
pow264.0%
Applied egg-rr64.0%
Taylor expanded in x around 0 64.0%
unpow264.0%
Simplified64.0%
Taylor expanded in x around 0 84.0%
unpow284.0%
mul-1-neg84.0%
distribute-rgt-neg-out84.0%
Simplified84.0%
if -1.85000000000000005e168 < y < -2.64999999999999984e-33 or 2.19999999999999983e-30 < y Initial program 83.8%
sqr-pow83.8%
sqr-pow83.7%
difference-of-squares94.5%
metadata-eval94.5%
pow294.5%
metadata-eval94.5%
pow294.5%
metadata-eval94.5%
pow294.5%
metadata-eval94.5%
pow294.5%
Applied egg-rr94.5%
Taylor expanded in x around 0 91.1%
unpow291.1%
Simplified91.1%
if -2.64999999999999984e-33 < y < 2.19999999999999983e-30Initial program 100.0%
sqr-pow99.8%
sqr-pow99.8%
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 inf 96.5%
unpow296.5%
Simplified96.5%
Final simplification93.0%
(FPCore (x y) :precision binary64 (if (<= x 1.35e+154) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 1.35e+154) {
tmp = (y * y) * ((x * x) - (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+154) then
tmp = (y * y) * ((x * x) - (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+154) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.35e+154: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * 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+154) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.35e+154], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $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^{+154}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 92.8%
sqr-pow92.7%
sqr-pow92.6%
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 1.35000000000000003e154 < x Initial program 61.8%
sqr-pow61.8%
sqr-pow61.8%
difference-of-squares70.6%
metadata-eval70.6%
pow270.6%
metadata-eval70.6%
pow270.6%
metadata-eval70.6%
pow270.6%
metadata-eval70.6%
pow270.6%
Applied egg-rr70.6%
Taylor expanded in x around 0 52.9%
unpow252.9%
Simplified52.9%
Taylor expanded in y around 0 67.6%
unpow267.6%
unpow267.6%
Simplified67.6%
Final simplification72.6%
(FPCore (x y) :precision binary64 (if (or (<= x -1.3e+111) (not (<= x 2.8e+124))) (* (* x x) (* y y)) (* (* y y) (* y (- y)))))
double code(double x, double y) {
double tmp;
if ((x <= -1.3e+111) || !(x <= 2.8e+124)) {
tmp = (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 ((x <= (-1.3d+111)) .or. (.not. (x <= 2.8d+124))) then
tmp = (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 ((x <= -1.3e+111) || !(x <= 2.8e+124)) {
tmp = (x * x) * (y * y);
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.3e+111) or not (x <= 2.8e+124): tmp = (x * x) * (y * y) else: tmp = (y * y) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.3e+111) || !(x <= 2.8e+124)) tmp = 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 ((x <= -1.3e+111) || ~((x <= 2.8e+124))) tmp = (x * x) * (y * y); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.3e+111], N[Not[LessEqual[x, 2.8e+124]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{+111} \lor \neg \left(x \leq 2.8 \cdot 10^{+124}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if x < -1.2999999999999999e111 or 2.8e124 < x Initial program 66.7%
sqr-pow66.7%
sqr-pow66.7%
difference-of-squares79.2%
metadata-eval79.2%
pow279.2%
metadata-eval79.2%
pow279.2%
metadata-eval79.2%
pow279.2%
metadata-eval79.2%
pow279.2%
Applied egg-rr79.2%
Taylor expanded in x around 0 51.6%
unpow251.6%
Simplified51.6%
Taylor expanded in y around 0 61.3%
unpow261.3%
unpow261.3%
Simplified61.3%
if -1.2999999999999999e111 < x < 2.8e124Initial program 97.3%
sqr-pow97.2%
sqr-pow97.1%
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 78.0%
unpow278.0%
Simplified78.0%
Taylor expanded in x around 0 77.8%
unpow277.8%
mul-1-neg77.8%
distribute-rgt-neg-out77.8%
Simplified77.8%
Final simplification73.1%
(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 88.7%
sqr-pow88.6%
sqr-pow88.5%
difference-of-squares94.0%
metadata-eval94.0%
pow294.0%
metadata-eval94.0%
pow294.0%
metadata-eval94.0%
pow294.0%
metadata-eval94.0%
pow294.0%
Applied egg-rr94.0%
Taylor expanded in x around 0 70.6%
unpow270.6%
Simplified70.6%
Taylor expanded in y around 0 36.4%
unpow236.4%
unpow236.4%
Simplified36.4%
Final simplification36.4%
herbie shell --seed 2023185
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))