
(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) 6.1e+277) (- (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) <= 6.1e+277) {
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) <= 6.1d+277) 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) <= 6.1e+277) {
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) <= 6.1e+277: 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) <= 6.1e+277) 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) <= 6.1e+277) 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], 6.1e+277], 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 6.1 \cdot 10^{+277}:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y 4) < 6.1000000000000004e277Initial program 100.0%
if 6.1000000000000004e277 < (pow.f64 y 4) Initial program 57.9%
Taylor expanded in x around 0 78.9%
neg-mul-178.9%
Simplified78.9%
Final simplification92.2%
(FPCore (x y) :precision binary64 (if (<= (pow y 4.0) 105000000000.0) (pow x 4.0) (- (pow y 4.0))))
double code(double x, double y) {
double tmp;
if (pow(y, 4.0) <= 105000000000.0) {
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) <= 105000000000.0d0) 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) <= 105000000000.0) {
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) <= 105000000000.0: 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) <= 105000000000.0) 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) <= 105000000000.0) tmp = x ^ 4.0; else tmp = -(y ^ 4.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Power[y, 4.0], $MachinePrecision], 105000000000.0], N[Power[x, 4.0], $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq 105000000000:\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y 4) < 1.05e11Initial program 100.0%
Taylor expanded in x around inf 92.3%
if 1.05e11 < (pow.f64 y 4) Initial program 65.2%
Taylor expanded in x around 0 78.3%
neg-mul-178.3%
Simplified78.3%
Final simplification86.0%
(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 61.0%
Final simplification61.0%
herbie shell --seed 2024026
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))