
(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) 3.2e+234) (- (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) <= 3.2e+234) {
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) <= 3.2d+234) 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) <= 3.2e+234) {
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) <= 3.2e+234: 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) <= 3.2e+234) 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) <= 3.2e+234) 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], 3.2e+234], 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 3.2 \cdot 10^{+234}:\\
\;\;\;\;{x}^{4} - {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if (pow.f64 x 4) < 3.19999999999999992e234Initial program 100.0%
if 3.19999999999999992e234 < (pow.f64 x 4) Initial program 59.6%
Taylor expanded in x around inf 81.8%
(FPCore (x y) :precision binary64 (if (<= x -6.1e+35) (pow x 4.0) (if (<= x 5.9e-5) (* -1.0 (pow y 4.0)) (pow x 4.0))))
double code(double x, double y) {
double tmp;
if (x <= -6.1e+35) {
tmp = pow(x, 4.0);
} else if (x <= 5.9e-5) {
tmp = -1.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 <= (-6.1d+35)) then
tmp = x ** 4.0d0
else if (x <= 5.9d-5) then
tmp = (-1.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 (x <= -6.1e+35) {
tmp = Math.pow(x, 4.0);
} else if (x <= 5.9e-5) {
tmp = -1.0 * Math.pow(y, 4.0);
} else {
tmp = Math.pow(x, 4.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.1e+35: tmp = math.pow(x, 4.0) elif x <= 5.9e-5: tmp = -1.0 * math.pow(y, 4.0) else: tmp = math.pow(x, 4.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -6.1e+35) tmp = x ^ 4.0; elseif (x <= 5.9e-5) tmp = Float64(-1.0 * (y ^ 4.0)); else tmp = x ^ 4.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -6.1e+35) tmp = x ^ 4.0; elseif (x <= 5.9e-5) tmp = -1.0 * (y ^ 4.0); else tmp = x ^ 4.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -6.1e+35], N[Power[x, 4.0], $MachinePrecision], If[LessEqual[x, 5.9e-5], N[(-1.0 * N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[x, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.1 \cdot 10^{+35}:\\
\;\;\;\;{x}^{4}\\
\mathbf{elif}\;x \leq 5.9 \cdot 10^{-5}:\\
\;\;\;\;-1 \cdot {y}^{4}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4}\\
\end{array}
\end{array}
if x < -6.09999999999999977e35 or 5.8999999999999998e-5 < x Initial program 66.1%
Taylor expanded in x around inf 78.8%
if -6.09999999999999977e35 < x < 5.8999999999999998e-5Initial program 100.0%
Taylor expanded in x around 0 91.1%
(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 57.6%
herbie shell --seed 2024050 -o generate:simplify
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))