
(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.95e+148) (* 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.95e+148) {
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.95d+148) 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.95e+148) {
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.95e+148: 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.95e+148) 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.95e+148) 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.95e+148], 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.95 \cdot 10^{+148}:\\
\;\;\;\;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.95000000000000001e148Initial program 88.8%
sqr-pow88.7%
sqr-pow88.6%
difference-of-squares95.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
Applied egg-rr95.5%
if 1.95000000000000001e148 < x Initial program 66.7%
sqr-pow66.7%
sqr-pow66.7%
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 inf 87.5%
unpow287.5%
Simplified87.5%
Final simplification94.7%
NOTE: x should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 3.5e-80)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 3.2e+149)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))x = abs(x);
double code(double x, double y) {
double tmp;
if (y <= 3.5e-80) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 3.2e+149) {
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 <= 3.5d-80) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 3.2d+149) 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 <= 3.5e-80) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 3.2e+149) {
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 <= 3.5e-80: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 3.2e+149: 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 <= 3.5e-80) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 3.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
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.5e-80) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 3.2e+149) 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, 3.5e-80], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.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}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{-80}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 3.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 < 3.50000000000000015e-80Initial program 91.0%
sqr-pow90.9%
sqr-pow90.8%
difference-of-squares95.6%
metadata-eval95.6%
pow295.6%
metadata-eval95.6%
pow295.6%
metadata-eval95.6%
pow295.6%
metadata-eval95.6%
pow295.6%
Applied egg-rr95.6%
Taylor expanded in x around inf 69.1%
unpow269.1%
Simplified69.1%
if 3.50000000000000015e-80 < y < 3.2000000000000002e149Initial program 88.9%
sqr-pow88.9%
sqr-pow88.7%
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 89.5%
unpow289.5%
Simplified89.5%
if 3.2000000000000002e149 < y Initial program 62.9%
sqr-pow62.9%
sqr-pow62.9%
difference-of-squares74.3%
metadata-eval74.3%
pow274.3%
metadata-eval74.3%
pow274.3%
metadata-eval74.3%
pow274.3%
metadata-eval74.3%
pow274.3%
Applied egg-rr74.3%
Taylor expanded in x around 0 74.3%
unpow274.3%
Simplified74.3%
Taylor expanded in x around 0 82.9%
unpow282.9%
mul-1-neg82.9%
distribute-rgt-neg-out82.9%
Simplified82.9%
Final simplification75.3%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1.05e+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.05e+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.05d+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.05e+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.05e+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.05e+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.05e+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.05e+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.05 \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.04999999999999997e154Initial program 88.8%
sqr-pow88.7%
sqr-pow88.6%
difference-of-squares95.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
metadata-eval95.5%
pow295.5%
Applied egg-rr95.5%
Taylor expanded in x around 0 73.6%
unpow273.6%
Simplified73.6%
if 1.04999999999999997e154 < x Initial program 65.2%
sqr-pow65.2%
sqr-pow65.2%
difference-of-squares73.9%
metadata-eval73.9%
pow273.9%
metadata-eval73.9%
pow273.9%
metadata-eval73.9%
pow273.9%
metadata-eval73.9%
pow273.9%
Applied egg-rr73.9%
Taylor expanded in x around 0 60.9%
unpow260.9%
Simplified60.9%
Taylor expanded in y around 0 73.9%
unpow273.9%
unpow273.9%
*-commutative73.9%
Simplified73.9%
Final simplification73.6%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1.6e+141) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 1.6e+141) {
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.6d+141) 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.6e+141) {
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.6e+141: 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.6e+141) 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.6e+141) 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.6e+141], 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.6 \cdot 10^{+141}:\\
\;\;\;\;\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.60000000000000009e141Initial program 89.2%
sqr-pow89.1%
sqr-pow89.0%
difference-of-squares95.4%
metadata-eval95.4%
pow295.4%
metadata-eval95.4%
pow295.4%
metadata-eval95.4%
pow295.4%
metadata-eval95.4%
pow295.4%
Applied egg-rr95.4%
Taylor expanded in x around 0 73.8%
unpow273.8%
Simplified73.8%
Taylor expanded in x around 0 64.0%
unpow264.0%
mul-1-neg64.0%
distribute-rgt-neg-out64.0%
Simplified64.0%
if 1.60000000000000009e141 < x Initial program 64.0%
sqr-pow64.0%
sqr-pow64.0%
difference-of-squares76.0%
metadata-eval76.0%
pow276.0%
metadata-eval76.0%
pow276.0%
metadata-eval76.0%
pow276.0%
metadata-eval76.0%
pow276.0%
Applied egg-rr76.0%
Taylor expanded in x around 0 60.1%
unpow260.1%
Simplified60.1%
Taylor expanded in y around 0 68.1%
unpow268.1%
unpow268.1%
*-commutative68.1%
Simplified68.1%
Final simplification64.4%
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 86.7%
sqr-pow86.6%
sqr-pow86.5%
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 72.4%
unpow272.4%
Simplified72.4%
Taylor expanded in y around 0 35.8%
unpow235.8%
unpow235.8%
*-commutative35.8%
Simplified35.8%
Final simplification35.8%
herbie shell --seed 2023285
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))