
(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 3 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) 4.8e+280) (- (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) <= 4.8e+280) {
tmp = pow(x, 4.0) - pow(y, 4.0);
} else {
tmp = -pow(y, 4.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y ** 4.0d0) <= 4.8d+280) then
tmp = (x ** 4.0d0) - (y ** 4.0d0)
else
tmp = -(y ** 4.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.pow(y, 4.0) <= 4.8e+280) {
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) <= 4.8e+280: 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) <= 4.8e+280) 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) <= 4.8e+280) 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], 4.8e+280], 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 4.8 \cdot 10^{+280}:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y 4) < 4.79999999999999967e280Initial program 100.0%
if 4.79999999999999967e280 < (pow.f64 y 4) Initial program 59.6%
Taylor expanded in x around 0 83.0%
neg-mul-183.0%
Simplified83.0%
Final simplification93.8%
(FPCore (x y)
:precision binary64
(if (or (<= (pow y 4.0) 9.5e+51)
(and (not (<= (pow y 4.0) 3.7e+118)) (<= (pow y 4.0) 1.75e+177)))
(pow x 4.0)
(- (pow y 4.0))))
double code(double x, double y) {
double tmp;
if ((pow(y, 4.0) <= 9.5e+51) || (!(pow(y, 4.0) <= 3.7e+118) && (pow(y, 4.0) <= 1.75e+177))) {
tmp = pow(x, 4.0);
} else {
tmp = -pow(y, 4.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (((y ** 4.0d0) <= 9.5d+51) .or. (.not. ((y ** 4.0d0) <= 3.7d+118)) .and. ((y ** 4.0d0) <= 1.75d+177)) then
tmp = x ** 4.0d0
else
tmp = -(y ** 4.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.pow(y, 4.0) <= 9.5e+51) || (!(Math.pow(y, 4.0) <= 3.7e+118) && (Math.pow(y, 4.0) <= 1.75e+177))) {
tmp = Math.pow(x, 4.0);
} else {
tmp = -Math.pow(y, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.pow(y, 4.0) <= 9.5e+51) or (not (math.pow(y, 4.0) <= 3.7e+118) and (math.pow(y, 4.0) <= 1.75e+177)): tmp = math.pow(x, 4.0) else: tmp = -math.pow(y, 4.0) return tmp
function code(x, y) tmp = 0.0 if (((y ^ 4.0) <= 9.5e+51) || (!((y ^ 4.0) <= 3.7e+118) && ((y ^ 4.0) <= 1.75e+177))) tmp = x ^ 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) <= 9.5e+51) || (~(((y ^ 4.0) <= 3.7e+118)) && ((y ^ 4.0) <= 1.75e+177))) tmp = x ^ 4.0; else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Power[y, 4.0], $MachinePrecision], 9.5e+51], And[N[Not[LessEqual[N[Power[y, 4.0], $MachinePrecision], 3.7e+118]], $MachinePrecision], LessEqual[N[Power[y, 4.0], $MachinePrecision], 1.75e+177]]], N[Power[x, 4.0], $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq 9.5 \cdot 10^{+51} \lor \neg \left({y}^{4} \leq 3.7 \cdot 10^{+118}\right) \land {y}^{4} \leq 1.75 \cdot 10^{+177}:\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y 4) < 9.4999999999999999e51 or 3.69999999999999987e118 < (pow.f64 y 4) < 1.74999999999999996e177Initial program 100.0%
Taylor expanded in x around inf 89.9%
if 9.4999999999999999e51 < (pow.f64 y 4) < 3.69999999999999987e118 or 1.74999999999999996e177 < (pow.f64 y 4) Initial program 66.4%
Taylor expanded in x around 0 80.5%
neg-mul-180.5%
Simplified80.5%
Final simplification85.8%
(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 85.2%
Taylor expanded in x around inf 59.2%
Final simplification59.2%
herbie shell --seed 2023314
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))