
(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}
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (let* ((t_0 (+ (* x x) (* y y)))) (if (<= x 1.32e+154) (* t_0 (- (* x x) (* y y))) (* (* x x) t_0))))
x = abs(x);
double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= 1.32e+154) {
tmp = t_0 * ((x * x) - (y * y));
} else {
tmp = (x * x) * t_0;
}
return tmp;
}
NOTE: x should be positive before calling this function
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 <= 1.32d+154) then
tmp = t_0 * ((x * x) - (y * y))
else
tmp = (x * x) * t_0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= 1.32e+154) {
tmp = t_0 * ((x * x) - (y * y));
} else {
tmp = (x * x) * t_0;
}
return tmp;
}
x = abs(x) def code(x, y): t_0 = (x * x) + (y * y) tmp = 0 if x <= 1.32e+154: tmp = t_0 * ((x * x) - (y * y)) else: tmp = (x * x) * t_0 return tmp
x = abs(x) function code(x, y) t_0 = Float64(Float64(x * x) + Float64(y * y)) tmp = 0.0 if (x <= 1.32e+154) tmp = Float64(t_0 * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(x * x) * t_0); end return tmp end
x = abs(x) function tmp_2 = code(x, y) t_0 = (x * x) + (y * y); tmp = 0.0; if (x <= 1.32e+154) tmp = t_0 * ((x * x) - (y * y)); else tmp = (x * x) * t_0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.32e+154], 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}
x = |x|\\
\\
\begin{array}{l}
t_0 := x \cdot x + y \cdot y\\
\mathbf{if}\;x \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;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 < 1.31999999999999998e154Initial program 89.2%
sqr-pow89.1%
sqr-pow89.0%
difference-of-squares97.2%
metadata-eval97.2%
pow297.2%
metadata-eval97.2%
pow297.2%
metadata-eval97.2%
pow297.2%
metadata-eval97.2%
pow297.2%
Applied egg-rr97.2%
if 1.31999999999999998e154 < x Initial program 52.0%
sqr-pow52.0%
sqr-pow52.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 inf 88.0%
unpow288.0%
Simplified88.0%
Final simplification96.3%
NOTE: x should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 5.6e-77)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 6.2e+151)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))x = abs(x);
double code(double x, double y) {
double tmp;
if (y <= 5.6e-77) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 6.2e+151) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.6d-77) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 6.2d+151) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (y <= 5.6e-77) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 6.2e+151) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if y <= 5.6e-77: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 6.2e+151: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (y <= 5.6e-77) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 6.2e+151) 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
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.6e-77) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 6.2e+151) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[y, 5.6e-77], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.2e+151], 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}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.6 \cdot 10^{-77}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+151}:\\
\;\;\;\;\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 < 5.5999999999999999e-77Initial program 92.6%
sqr-pow92.4%
sqr-pow92.4%
difference-of-squares98.7%
metadata-eval98.7%
pow298.7%
metadata-eval98.7%
pow298.7%
metadata-eval98.7%
pow298.7%
metadata-eval98.7%
pow298.7%
Applied egg-rr98.7%
Taylor expanded in x around inf 67.1%
unpow267.1%
Simplified67.1%
if 5.5999999999999999e-77 < y < 6.2000000000000004e151Initial program 84.4%
sqr-pow84.4%
sqr-pow84.1%
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 89.2%
unpow289.2%
Simplified89.2%
if 6.2000000000000004e151 < y Initial program 52.8%
sqr-pow52.8%
sqr-pow52.8%
difference-of-squares63.9%
metadata-eval63.9%
pow263.9%
metadata-eval63.9%
pow263.9%
metadata-eval63.9%
pow263.9%
metadata-eval63.9%
pow263.9%
Applied egg-rr63.9%
Taylor expanded in x around 0 63.9%
unpow263.9%
Simplified63.9%
Taylor expanded in x around 0 80.6%
unpow280.6%
mul-1-neg80.6%
distribute-rgt-neg-out80.6%
Simplified80.6%
Final simplification72.8%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1.32e+154) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 1.32e+154) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1.32d+154) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (x * x) * (y * y)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (x <= 1.32e+154) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if x <= 1.32e+154: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * (y * y) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (x <= 1.32e+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
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.32e+154) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[x, 1.32e+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}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.32 \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.31999999999999998e154Initial program 89.2%
sqr-pow89.1%
sqr-pow89.0%
difference-of-squares97.2%
metadata-eval97.2%
pow297.2%
metadata-eval97.2%
pow297.2%
metadata-eval97.2%
pow297.2%
metadata-eval97.2%
pow297.2%
Applied egg-rr97.2%
Taylor expanded in x around 0 73.4%
unpow273.4%
Simplified73.4%
if 1.31999999999999998e154 < x Initial program 52.0%
sqr-pow52.0%
sqr-pow52.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 40.0%
unpow240.0%
Simplified40.0%
Taylor expanded in y around 0 64.0%
unpow264.0%
unpow264.0%
Simplified64.0%
Final simplification72.5%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1.75e+127) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 1.75e+127) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1.75d+127) then
tmp = (y * y) * (y * -y)
else
tmp = (x * x) * (y * y)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (x <= 1.75e+127) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if x <= 1.75e+127: tmp = (y * y) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (x <= 1.75e+127) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); else tmp = Float64(Float64(x * x) * Float64(y * y)); end return tmp end
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.75e+127) tmp = (y * y) * (y * -y); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[x, 1.75e+127], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.75 \cdot 10^{+127}:\\
\;\;\;\;\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.74999999999999989e127Initial program 90.6%
sqr-pow90.5%
sqr-pow90.4%
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 0 74.2%
unpow274.2%
Simplified74.2%
Taylor expanded in x around 0 64.1%
unpow264.1%
mul-1-neg64.1%
distribute-rgt-neg-out64.1%
Simplified64.1%
if 1.74999999999999989e127 < x Initial program 51.5%
sqr-pow51.5%
sqr-pow51.5%
difference-of-squares72.7%
metadata-eval72.7%
pow272.7%
metadata-eval72.7%
pow272.7%
metadata-eval72.7%
pow272.7%
metadata-eval72.7%
pow272.7%
Applied egg-rr72.7%
Taylor expanded in x around 0 43.1%
unpow243.1%
Simplified43.1%
Taylor expanded in y around 0 55.2%
unpow255.2%
unpow255.2%
Simplified55.2%
Final simplification62.9%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (* (* x x) (* y y)))
x = abs(x);
double code(double x, double y) {
return (x * x) * (y * y);
}
NOTE: x should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * x) * (y * y)
end function
x = Math.abs(x);
public static double code(double x, double y) {
return (x * x) * (y * y);
}
x = abs(x) def code(x, y): return (x * x) * (y * y)
x = abs(x) function code(x, y) return Float64(Float64(x * x) * Float64(y * y)) end
x = abs(x) function tmp = code(x, y) tmp = (x * x) * (y * y); end
NOTE: x should be positive before calling this function code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\left(x \cdot x\right) \cdot \left(y \cdot y\right)
\end{array}
Initial program 85.5%
sqr-pow85.4%
sqr-pow85.4%
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.2%
unpow270.2%
Simplified70.2%
Taylor expanded in y around 0 32.0%
unpow232.0%
unpow232.0%
Simplified32.0%
Final simplification32.0%
herbie shell --seed 2023257
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))