
(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 x 4.0) 2.8e+297) (- (pow x 4.0) (pow y 4.0)) (pow x 4.0)))
double code(double x, double y) {
double tmp;
if (pow(x, 4.0) <= 2.8e+297) {
tmp = pow(x, 4.0) - 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) <= 2.8d+297) then
tmp = (x ** 4.0d0) - (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) <= 2.8e+297) {
tmp = Math.pow(x, 4.0) - 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) <= 2.8e+297: tmp = math.pow(x, 4.0) - 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) <= 2.8e+297) tmp = Float64((x ^ 4.0) - (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) <= 2.8e+297) tmp = (x ^ 4.0) - (y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[x, 4.0], $MachinePrecision], 2.8e+297], N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 2.8 \cdot 10^{+297}:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x #s(literal 4 binary64)) < 2.8000000000000002e297Initial program 100.0%
if 2.8000000000000002e297 < (pow.f64 x #s(literal 4 binary64)) Initial program 65.5%
Taylor expanded in x around inf 87.1%
Final simplification94.1%
(FPCore (x y)
:precision binary64
(if (or (<= (pow x 4.0) 7.8e-234)
(and (not (<= (pow x 4.0) 1.4e-142))
(or (<= (pow x 4.0) 3.4e-86)
(and (not (<= (pow x 4.0) 2.35e-14))
(<= (pow x 4.0) 3.3e+142)))))
(- (pow y 4.0))
(pow x 4.0)))
double code(double x, double y) {
double tmp;
if ((pow(x, 4.0) <= 7.8e-234) || (!(pow(x, 4.0) <= 1.4e-142) && ((pow(x, 4.0) <= 3.4e-86) || (!(pow(x, 4.0) <= 2.35e-14) && (pow(x, 4.0) <= 3.3e+142))))) {
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) <= 7.8d-234) .or. (.not. ((x ** 4.0d0) <= 1.4d-142)) .and. ((x ** 4.0d0) <= 3.4d-86) .or. (.not. ((x ** 4.0d0) <= 2.35d-14)) .and. ((x ** 4.0d0) <= 3.3d+142)) 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) <= 7.8e-234) || (!(Math.pow(x, 4.0) <= 1.4e-142) && ((Math.pow(x, 4.0) <= 3.4e-86) || (!(Math.pow(x, 4.0) <= 2.35e-14) && (Math.pow(x, 4.0) <= 3.3e+142))))) {
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) <= 7.8e-234) or (not (math.pow(x, 4.0) <= 1.4e-142) and ((math.pow(x, 4.0) <= 3.4e-86) or (not (math.pow(x, 4.0) <= 2.35e-14) and (math.pow(x, 4.0) <= 3.3e+142)))): 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) <= 7.8e-234) || (!((x ^ 4.0) <= 1.4e-142) && (((x ^ 4.0) <= 3.4e-86) || (!((x ^ 4.0) <= 2.35e-14) && ((x ^ 4.0) <= 3.3e+142))))) 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) <= 7.8e-234) || (~(((x ^ 4.0) <= 1.4e-142)) && (((x ^ 4.0) <= 3.4e-86) || (~(((x ^ 4.0) <= 2.35e-14)) && ((x ^ 4.0) <= 3.3e+142))))) tmp = -(y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Power[x, 4.0], $MachinePrecision], 7.8e-234], And[N[Not[LessEqual[N[Power[x, 4.0], $MachinePrecision], 1.4e-142]], $MachinePrecision], Or[LessEqual[N[Power[x, 4.0], $MachinePrecision], 3.4e-86], And[N[Not[LessEqual[N[Power[x, 4.0], $MachinePrecision], 2.35e-14]], $MachinePrecision], LessEqual[N[Power[x, 4.0], $MachinePrecision], 3.3e+142]]]]], (-N[Power[y, 4.0], $MachinePrecision]), N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 7.8 \cdot 10^{-234} \lor \neg \left({x}^{4} \leq 1.4 \cdot 10^{-142}\right) \land \left({x}^{4} \leq 3.4 \cdot 10^{-86} \lor \neg \left({x}^{4} \leq 2.35 \cdot 10^{-14}\right) \land {x}^{4} \leq 3.3 \cdot 10^{+142}\right):\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x #s(literal 4 binary64)) < 7.8000000000000002e-234 or 1.40000000000000002e-142 < (pow.f64 x #s(literal 4 binary64)) < 3.4e-86 or 2.3500000000000001e-14 < (pow.f64 x #s(literal 4 binary64)) < 3.3000000000000002e142Initial program 100.0%
Taylor expanded in x around 0 95.2%
neg-mul-195.2%
Simplified95.2%
if 7.8000000000000002e-234 < (pow.f64 x #s(literal 4 binary64)) < 1.40000000000000002e-142 or 3.4e-86 < (pow.f64 x #s(literal 4 binary64)) < 2.3500000000000001e-14 or 3.3000000000000002e142 < (pow.f64 x #s(literal 4 binary64)) Initial program 74.4%
Taylor expanded in x around inf 82.9%
Final simplification87.7%
(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 63.2%
Final simplification63.2%
herbie shell --seed 2024079
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))