
(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 (if (<= (pow y 4.0) INFINITY) (- (pow x 4.0) (pow y 4.0)) (- (pow y 4.0))))
double code(double x, double y) {
double tmp;
if (pow(y, 4.0) <= ((double) INFINITY)) {
tmp = pow(x, 4.0) - pow(y, 4.0);
} else {
tmp = -pow(y, 4.0);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (Math.pow(y, 4.0) <= Double.POSITIVE_INFINITY) {
tmp = Math.pow(x, 4.0) - Math.pow(y, 4.0);
} else {
tmp = -Math.pow(y, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if math.pow(y, 4.0) <= math.inf: tmp = math.pow(x, 4.0) - math.pow(y, 4.0) else: tmp = -math.pow(y, 4.0) return tmp
function code(x, y) tmp = 0.0 if ((y ^ 4.0) <= Inf) tmp = Float64((x ^ 4.0) - (y ^ 4.0)); else tmp = Float64(-(y ^ 4.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y ^ 4.0) <= Inf) tmp = (x ^ 4.0) - (y ^ 4.0); else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[y, 4.0], $MachinePrecision], Infinity], N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq \infty:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y #s(literal 4 binary64)) < +inf.0Initial program 84.4%
if +inf.0 < (pow.f64 y #s(literal 4 binary64)) Initial program 84.4%
Taylor expanded in x around 0 56.5%
neg-mul-156.5%
Simplified56.5%
(FPCore (x y) :precision binary64 (if (<= (pow x 4.0) 5e+155) (- (pow y 4.0)) (pow (/ -1.0 (/ -1.0 x)) 4.0)))
double code(double x, double y) {
double tmp;
if (pow(x, 4.0) <= 5e+155) {
tmp = -pow(y, 4.0);
} else {
tmp = pow((-1.0 / (-1.0 / x)), 4.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x ** 4.0d0) <= 5d+155) then
tmp = -(y ** 4.0d0)
else
tmp = ((-1.0d0) / ((-1.0d0) / x)) ** 4.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.pow(x, 4.0) <= 5e+155) {
tmp = -Math.pow(y, 4.0);
} else {
tmp = Math.pow((-1.0 / (-1.0 / x)), 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if math.pow(x, 4.0) <= 5e+155: tmp = -math.pow(y, 4.0) else: tmp = math.pow((-1.0 / (-1.0 / x)), 4.0) return tmp
function code(x, y) tmp = 0.0 if ((x ^ 4.0) <= 5e+155) tmp = Float64(-(y ^ 4.0)); else tmp = Float64(-1.0 / Float64(-1.0 / x)) ^ 4.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x ^ 4.0) <= 5e+155) tmp = -(y ^ 4.0); else tmp = (-1.0 / (-1.0 / x)) ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[x, 4.0], $MachinePrecision], 5e+155], (-N[Power[y, 4.0], $MachinePrecision]), N[Power[N[(-1.0 / N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 5 \cdot 10^{+155}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{-1}{\frac{-1}{x}}\right)}^{4}\\
\end{array}
\end{array}
if (pow.f64 x #s(literal 4 binary64)) < 4.9999999999999999e155Initial program 100.0%
Taylor expanded in x around 0 87.0%
neg-mul-187.0%
Simplified87.0%
if 4.9999999999999999e155 < (pow.f64 x #s(literal 4 binary64)) Initial program 67.5%
Taylor expanded in x around inf 76.3%
add-exp-log75.4%
log-pow43.3%
Applied egg-rr43.3%
*-un-lft-identity43.3%
exp-prod43.2%
exp-1-e43.2%
Applied egg-rr43.2%
Taylor expanded in x around -inf 0.0%
*-commutative0.0%
exp-prod0.0%
log-E0.0%
*-lft-identity0.0%
mul-1-neg0.0%
unsub-neg0.0%
exp-diff0.0%
rem-exp-log32.2%
rem-exp-log76.3%
Simplified76.3%
(FPCore (x y) :precision binary64 (if (<= (pow x 4.0) 5e+155) (- (pow y 4.0)) (pow x 4.0)))
double code(double x, double y) {
double tmp;
if (pow(x, 4.0) <= 5e+155) {
tmp = -pow(y, 4.0);
} else {
tmp = pow(x, 4.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x ** 4.0d0) <= 5d+155) then
tmp = -(y ** 4.0d0)
else
tmp = x ** 4.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.pow(x, 4.0) <= 5e+155) {
tmp = -Math.pow(y, 4.0);
} else {
tmp = Math.pow(x, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if math.pow(x, 4.0) <= 5e+155: tmp = -math.pow(y, 4.0) else: tmp = math.pow(x, 4.0) return tmp
function code(x, y) tmp = 0.0 if ((x ^ 4.0) <= 5e+155) tmp = Float64(-(y ^ 4.0)); else tmp = x ^ 4.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x ^ 4.0) <= 5e+155) tmp = -(y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[x, 4.0], $MachinePrecision], 5e+155], (-N[Power[y, 4.0], $MachinePrecision]), N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 5 \cdot 10^{+155}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x #s(literal 4 binary64)) < 4.9999999999999999e155Initial program 100.0%
Taylor expanded in x around 0 87.0%
neg-mul-187.0%
Simplified87.0%
if 4.9999999999999999e155 < (pow.f64 x #s(literal 4 binary64)) Initial program 67.5%
Taylor expanded in x around inf 76.3%
(FPCore (x y) :precision binary64 (pow x 4.0))
double code(double x, double y) {
return pow(x, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x ** 4.0d0
end function
public static double code(double x, double y) {
return Math.pow(x, 4.0);
}
def code(x, y): return math.pow(x, 4.0)
function code(x, y) return x ^ 4.0 end
function tmp = code(x, y) tmp = x ^ 4.0; end
code[x_, y_] := N[Power[x, 4.0], $MachinePrecision]
\begin{array}{l}
\\
{x}^{4}
\end{array}
Initial program 84.4%
Taylor expanded in x around inf 56.7%
(FPCore (x y) :precision binary64 0.0)
double code(double x, double y) {
return 0.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.0d0
end function
public static double code(double x, double y) {
return 0.0;
}
def code(x, y): return 0.0
function code(x, y) return 0.0 end
function tmp = code(x, y) tmp = 0.0; end
code[x_, y_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 84.4%
Taylor expanded in x around 0 56.5%
neg-mul-156.5%
Simplified56.5%
add-sqr-sqrt12.6%
sqrt-unprod22.1%
sqr-neg22.1%
sqrt-unprod20.1%
add-log-exp25.9%
add-sqr-sqrt25.9%
add-sqr-sqrt25.9%
sqrt-unprod25.9%
*-un-lft-identity25.9%
exp-prod25.9%
add-sqr-sqrt25.9%
sqrt-unprod25.9%
sqr-neg25.9%
sqrt-unprod12.6%
add-sqr-sqrt13.3%
exp-prod13.3%
*-un-lft-identity13.3%
exp-neg13.3%
rgt-mult-inverse14.1%
Applied egg-rr14.1%
herbie shell --seed 2024123
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))