
(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 2e+142) (* 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 <= 2e+142) {
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 <= 2d+142) 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 <= 2e+142) {
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 <= 2e+142: 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 <= 2e+142) 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 <= 2e+142) 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, 2e+142], 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 2 \cdot 10^{+142}:\\
\;\;\;\;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 < 2.0000000000000001e142Initial program 89.2%
sqr-pow89.1%
sqr-pow89.0%
difference-of-squares93.5%
metadata-eval93.5%
pow293.5%
metadata-eval93.5%
pow293.5%
metadata-eval93.5%
pow293.5%
metadata-eval93.5%
pow293.5%
Applied egg-rr93.5%
if 2.0000000000000001e142 < x Initial program 64.7%
sqr-pow64.7%
sqr-pow64.7%
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 inf 91.2%
unpow291.2%
Simplified91.2%
Final simplification93.2%
NOTE: x should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 2e-99)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 2.9e+153)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))x = abs(x);
double code(double x, double y) {
double tmp;
if (y <= 2e-99) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 2.9e+153) {
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 <= 2d-99) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 2.9d+153) 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 <= 2e-99) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 2.9e+153) {
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 <= 2e-99: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 2.9e+153: 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 <= 2e-99) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 2.9e+153) 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 <= 2e-99) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 2.9e+153) 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, 2e-99], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e+153], 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 2 \cdot 10^{-99}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+153}:\\
\;\;\;\;\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 < 2e-99Initial program 90.5%
sqr-pow90.4%
sqr-pow90.3%
difference-of-squares93.7%
metadata-eval93.7%
pow293.7%
metadata-eval93.7%
pow293.7%
metadata-eval93.7%
pow293.7%
metadata-eval93.7%
pow293.7%
Applied egg-rr93.7%
Taylor expanded in x around inf 65.9%
unpow265.9%
Simplified65.9%
if 2e-99 < y < 2.90000000000000002e153Initial program 90.7%
sqr-pow90.7%
sqr-pow90.4%
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 93.1%
unpow293.1%
Simplified93.1%
if 2.90000000000000002e153 < y Initial program 55.9%
sqr-pow55.9%
sqr-pow55.9%
difference-of-squares61.8%
metadata-eval61.8%
pow261.8%
metadata-eval61.8%
pow261.8%
metadata-eval61.8%
pow261.8%
metadata-eval61.8%
pow261.8%
Applied egg-rr61.8%
Taylor expanded in x around 0 61.8%
unpow261.8%
Simplified61.8%
Taylor expanded in x around 0 79.4%
unpow279.4%
mul-1-neg79.4%
distribute-rgt-neg-out79.4%
Simplified79.4%
Final simplification72.2%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 2e+142) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 2e+142) {
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 <= 2d+142) 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 <= 2e+142) {
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 <= 2e+142: 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 <= 2e+142) 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 <= 2e+142) 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, 2e+142], 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 2 \cdot 10^{+142}:\\
\;\;\;\;\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 < 2.0000000000000001e142Initial program 89.2%
sqr-pow89.1%
sqr-pow89.0%
difference-of-squares93.5%
metadata-eval93.5%
pow293.5%
metadata-eval93.5%
pow293.5%
metadata-eval93.5%
pow293.5%
metadata-eval93.5%
pow293.5%
Applied egg-rr93.5%
Taylor expanded in x around 0 70.8%
unpow270.8%
Simplified70.8%
if 2.0000000000000001e142 < x Initial program 64.7%
sqr-pow64.7%
sqr-pow64.7%
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 41.2%
unpow241.2%
Simplified41.2%
Taylor expanded in y around 0 61.8%
unpow261.8%
unpow261.8%
Simplified61.8%
Final simplification69.6%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 4.1e+173) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 4.1e+173) {
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 <= 4.1d+173) 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 <= 4.1e+173) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if x <= 4.1e+173: 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 <= 4.1e+173) 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 <= 4.1e+173) 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, 4.1e+173], 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 4.1 \cdot 10^{+173}:\\
\;\;\;\;\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 < 4.09999999999999976e173Initial program 88.2%
sqr-pow88.1%
sqr-pow88.0%
difference-of-squares92.4%
metadata-eval92.4%
pow292.4%
metadata-eval92.4%
pow292.4%
metadata-eval92.4%
pow292.4%
metadata-eval92.4%
pow292.4%
Applied egg-rr92.4%
Taylor expanded in x around 0 69.4%
unpow269.4%
Simplified69.4%
Taylor expanded in x around 0 67.7%
unpow267.7%
mul-1-neg67.7%
distribute-rgt-neg-out67.7%
Simplified67.7%
if 4.09999999999999976e173 < x Initial program 67.9%
sqr-pow67.9%
sqr-pow67.9%
difference-of-squares75.0%
metadata-eval75.0%
pow275.0%
metadata-eval75.0%
pow275.0%
metadata-eval75.0%
pow275.0%
metadata-eval75.0%
pow275.0%
Applied egg-rr75.0%
Taylor expanded in x around 0 46.4%
unpow246.4%
Simplified46.4%
Taylor expanded in y around 0 71.4%
unpow271.4%
unpow271.4%
Simplified71.4%
Final simplification68.1%
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.9%
sqr-pow85.9%
sqr-pow85.8%
difference-of-squares90.5%
metadata-eval90.5%
pow290.5%
metadata-eval90.5%
pow290.5%
metadata-eval90.5%
pow290.5%
metadata-eval90.5%
pow290.5%
Applied egg-rr90.5%
Taylor expanded in x around 0 66.9%
unpow266.9%
Simplified66.9%
Taylor expanded in y around 0 32.4%
unpow232.4%
unpow232.4%
Simplified32.4%
Final simplification32.4%
herbie shell --seed 2023207
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))