
(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}
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1.5e+97) (- (pow x 4.0) (pow y 4.0)) (if (<= x 5.7e+131) (- (pow y 4.0)) (pow x 4.0))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 1.5e+97) {
tmp = pow(x, 4.0) - pow(y, 4.0);
} else if (x <= 5.7e+131) {
tmp = -pow(y, 4.0);
} else {
tmp = pow(x, 4.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) :: tmp
if (x <= 1.5d+97) then
tmp = (x ** 4.0d0) - (y ** 4.0d0)
else if (x <= 5.7d+131) then
tmp = -(y ** 4.0d0)
else
tmp = x ** 4.0d0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (x <= 1.5e+97) {
tmp = Math.pow(x, 4.0) - Math.pow(y, 4.0);
} else if (x <= 5.7e+131) {
tmp = -Math.pow(y, 4.0);
} else {
tmp = Math.pow(x, 4.0);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if x <= 1.5e+97: tmp = math.pow(x, 4.0) - math.pow(y, 4.0) elif x <= 5.7e+131: tmp = -math.pow(y, 4.0) else: tmp = math.pow(x, 4.0) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (x <= 1.5e+97) tmp = Float64((x ^ 4.0) - (y ^ 4.0)); elseif (x <= 5.7e+131) tmp = Float64(-(y ^ 4.0)); else tmp = x ^ 4.0; end return tmp end
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.5e+97) tmp = (x ^ 4.0) - (y ^ 4.0); elseif (x <= 5.7e+131) tmp = -(y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[x, 1.5e+97], N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.7e+131], (-N[Power[y, 4.0], $MachinePrecision]), N[Power[x, 4.0], $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5 \cdot 10^{+97}:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{+131}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if x < 1.4999999999999999e97Initial program 89.6%
if 1.4999999999999999e97 < x < 5.7e131Initial program 50.0%
Taylor expanded in x around 0 50.8%
mul-1-neg50.8%
Simplified50.8%
if 5.7e131 < x Initial program 62.7%
Taylor expanded in x around inf 82.4%
Final simplification87.5%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= (pow x 4.0) 4.4e+285) (- (pow y 4.0)) (pow x 4.0)))
x = abs(x);
double code(double x, double y) {
double tmp;
if (pow(x, 4.0) <= 4.4e+285) {
tmp = -pow(y, 4.0);
} else {
tmp = pow(x, 4.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) :: tmp
if ((x ** 4.0d0) <= 4.4d+285) then
tmp = -(y ** 4.0d0)
else
tmp = x ** 4.0d0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (Math.pow(x, 4.0) <= 4.4e+285) {
tmp = -Math.pow(y, 4.0);
} else {
tmp = Math.pow(x, 4.0);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if math.pow(x, 4.0) <= 4.4e+285: tmp = -math.pow(y, 4.0) else: tmp = math.pow(x, 4.0) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if ((x ^ 4.0) <= 4.4e+285) tmp = Float64(-(y ^ 4.0)); else tmp = x ^ 4.0; end return tmp end
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if ((x ^ 4.0) <= 4.4e+285) tmp = -(y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[N[Power[x, 4.0], $MachinePrecision], 4.4e+285], (-N[Power[y, 4.0], $MachinePrecision]), N[Power[x, 4.0], $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} \leq 4.4 \cdot 10^{+285}:\\
\;\;\;\;-{y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x 4) < 4.4e285Initial program 100.0%
Taylor expanded in x around 0 90.1%
mul-1-neg90.1%
Simplified90.1%
if 4.4e285 < (pow.f64 x 4) Initial program 59.6%
Taylor expanded in x around inf 79.8%
Final simplification85.9%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (pow x 4.0))
x = abs(x);
double code(double x, double y) {
return pow(x, 4.0);
}
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 ** 4.0d0
end function
x = Math.abs(x);
public static double code(double x, double y) {
return Math.pow(x, 4.0);
}
x = abs(x) def code(x, y): return math.pow(x, 4.0)
x = abs(x) function code(x, y) return x ^ 4.0 end
x = abs(x) function tmp = code(x, y) tmp = x ^ 4.0; end
NOTE: x should be positive before calling this function code[x_, y_] := N[Power[x, 4.0], $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
{x}^{4}
\end{array}
Initial program 83.6%
Taylor expanded in x around inf 52.5%
Final simplification52.5%
herbie shell --seed 2023301
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))