
(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 5 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 (* (* (pow (hypot x y) 2.0) (+ x y)) (- x y)))
double code(double x, double y) {
return (pow(hypot(x, y), 2.0) * (x + y)) * (x - y);
}
public static double code(double x, double y) {
return (Math.pow(Math.hypot(x, y), 2.0) * (x + y)) * (x - y);
}
def code(x, y): return (math.pow(math.hypot(x, y), 2.0) * (x + y)) * (x - y)
function code(x, y) return Float64(Float64((hypot(x, y) ^ 2.0) * Float64(x + y)) * Float64(x - y)) end
function tmp = code(x, y) tmp = ((hypot(x, y) ^ 2.0) * (x + y)) * (x - y); end
code[x_, y_] := N[(N[(N[Power[N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision], 2.0], $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\mathsf{hypot}\left(x, y\right)\right)}^{2} \cdot \left(x + y\right)\right) \cdot \left(x - y\right)
\end{array}
Initial program 82.4%
sqr-pow82.3%
sqr-pow82.2%
difference-of-squares91.6%
metadata-eval91.6%
pow291.6%
fma-def91.6%
metadata-eval91.6%
metadata-eval91.6%
metadata-eval91.6%
Applied egg-rr91.6%
unpow291.6%
unpow291.6%
difference-of-squares99.8%
Applied egg-rr99.8%
associate-*r*99.9%
sub-neg99.9%
distribute-lft-in71.3%
add-sqr-sqrt71.3%
pow271.3%
fma-udef71.3%
unpow271.3%
hypot-def71.3%
Applied egg-rr71.3%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (or (<= (pow y 4.0) 2e-62)
(and (not (<= (pow y 4.0) 1e+61)) (<= (pow y 4.0) 4e+114)))
(pow x 4.0)
(* (- x y) (pow y 3.0))))
double code(double x, double y) {
double tmp;
if ((pow(y, 4.0) <= 2e-62) || (!(pow(y, 4.0) <= 1e+61) && (pow(y, 4.0) <= 4e+114))) {
tmp = pow(x, 4.0);
} else {
tmp = (x - y) * pow(y, 3.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) <= 2d-62) .or. (.not. ((y ** 4.0d0) <= 1d+61)) .and. ((y ** 4.0d0) <= 4d+114)) then
tmp = x ** 4.0d0
else
tmp = (x - y) * (y ** 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((Math.pow(y, 4.0) <= 2e-62) || (!(Math.pow(y, 4.0) <= 1e+61) && (Math.pow(y, 4.0) <= 4e+114))) {
tmp = Math.pow(x, 4.0);
} else {
tmp = (x - y) * Math.pow(y, 3.0);
}
return tmp;
}
def code(x, y): tmp = 0 if (math.pow(y, 4.0) <= 2e-62) or (not (math.pow(y, 4.0) <= 1e+61) and (math.pow(y, 4.0) <= 4e+114)): tmp = math.pow(x, 4.0) else: tmp = (x - y) * math.pow(y, 3.0) return tmp
function code(x, y) tmp = 0.0 if (((y ^ 4.0) <= 2e-62) || (!((y ^ 4.0) <= 1e+61) && ((y ^ 4.0) <= 4e+114))) tmp = x ^ 4.0; else tmp = Float64(Float64(x - y) * (y ^ 3.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((y ^ 4.0) <= 2e-62) || (~(((y ^ 4.0) <= 1e+61)) && ((y ^ 4.0) <= 4e+114))) tmp = x ^ 4.0; else tmp = (x - y) * (y ^ 3.0); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[Power[y, 4.0], $MachinePrecision], 2e-62], And[N[Not[LessEqual[N[Power[y, 4.0], $MachinePrecision], 1e+61]], $MachinePrecision], LessEqual[N[Power[y, 4.0], $MachinePrecision], 4e+114]]], N[Power[x, 4.0], $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq 2 \cdot 10^{-62} \lor \neg \left({y}^{4} \leq 10^{+61}\right) \land {y}^{4} \leq 4 \cdot 10^{+114}:\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot {y}^{3}\\
\end{array}
\end{array}
if (pow.f64 y 4) < 2.0000000000000001e-62 or 9.99999999999999949e60 < (pow.f64 y 4) < 4e114Initial program 100.0%
Taylor expanded in x around inf 91.7%
if 2.0000000000000001e-62 < (pow.f64 y 4) < 9.99999999999999949e60 or 4e114 < (pow.f64 y 4) Initial program 68.1%
sqr-pow68.0%
sqr-pow68.0%
difference-of-squares85.0%
metadata-eval85.0%
pow285.0%
fma-def85.0%
metadata-eval85.0%
metadata-eval85.0%
metadata-eval85.0%
Applied egg-rr85.0%
unpow285.0%
unpow285.0%
difference-of-squares99.9%
Applied egg-rr99.9%
associate-*r*99.9%
sub-neg99.9%
distribute-lft-in59.5%
add-sqr-sqrt59.5%
pow259.5%
fma-udef59.5%
unpow259.5%
hypot-def59.5%
Applied egg-rr59.5%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 87.3%
Final simplification89.3%
(FPCore (x y)
:precision binary64
(if (or (<= (pow y 4.0) 2.3e-51)
(and (not (<= (pow y 4.0) 8.5e+63)) (<= (pow y 4.0) 3.05e+153)))
(pow x 4.0)
(- (pow y 4.0))))
double code(double x, double y) {
double tmp;
if ((pow(y, 4.0) <= 2.3e-51) || (!(pow(y, 4.0) <= 8.5e+63) && (pow(y, 4.0) <= 3.05e+153))) {
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) <= 2.3d-51) .or. (.not. ((y ** 4.0d0) <= 8.5d+63)) .and. ((y ** 4.0d0) <= 3.05d+153)) 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) <= 2.3e-51) || (!(Math.pow(y, 4.0) <= 8.5e+63) && (Math.pow(y, 4.0) <= 3.05e+153))) {
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) <= 2.3e-51) or (not (math.pow(y, 4.0) <= 8.5e+63) and (math.pow(y, 4.0) <= 3.05e+153)): 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) <= 2.3e-51) || (!((y ^ 4.0) <= 8.5e+63) && ((y ^ 4.0) <= 3.05e+153))) 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) <= 2.3e-51) || (~(((y ^ 4.0) <= 8.5e+63)) && ((y ^ 4.0) <= 3.05e+153))) 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], 2.3e-51], And[N[Not[LessEqual[N[Power[y, 4.0], $MachinePrecision], 8.5e+63]], $MachinePrecision], LessEqual[N[Power[y, 4.0], $MachinePrecision], 3.05e+153]]], N[Power[x, 4.0], $MachinePrecision], (-N[Power[y, 4.0], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{y}^{4} \leq 2.3 \cdot 10^{-51} \lor \neg \left({y}^{4} \leq 8.5 \cdot 10^{+63}\right) \land {y}^{4} \leq 3.05 \cdot 10^{+153}:\\
\;\;\;\;{x}^{4}\\
\mathbf{else}:\\
\;\;\;\;-{y}^{4}\\
\end{array}
\end{array}
if (pow.f64 y 4) < 2.30000000000000002e-51 or 8.5000000000000004e63 < (pow.f64 y 4) < 3.0499999999999999e153Initial program 100.0%
Taylor expanded in x around inf 91.8%
if 2.30000000000000002e-51 < (pow.f64 y 4) < 8.5000000000000004e63 or 3.0499999999999999e153 < (pow.f64 y 4) Initial program 67.9%
Taylor expanded in x around 0 77.9%
neg-mul-177.9%
Simplified77.9%
Final simplification84.2%
(FPCore (x y) :precision binary64 (* (- x y) (pow (+ x y) 3.0)))
double code(double x, double y) {
return (x - y) * pow((x + y), 3.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) * ((x + y) ** 3.0d0)
end function
public static double code(double x, double y) {
return (x - y) * Math.pow((x + y), 3.0);
}
def code(x, y): return (x - y) * math.pow((x + y), 3.0)
function code(x, y) return Float64(Float64(x - y) * (Float64(x + y) ^ 3.0)) end
function tmp = code(x, y) tmp = (x - y) * ((x + y) ^ 3.0); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] * N[Power[N[(x + y), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - y\right) \cdot {\left(x + y\right)}^{3}
\end{array}
Initial program 82.4%
sqr-pow82.3%
sqr-pow82.2%
difference-of-squares91.6%
metadata-eval91.6%
pow291.6%
fma-def91.6%
metadata-eval91.6%
metadata-eval91.6%
metadata-eval91.6%
Applied egg-rr91.6%
unpow291.6%
unpow291.6%
difference-of-squares99.8%
Applied egg-rr99.8%
associate-*r*99.9%
sub-neg99.9%
distribute-lft-in71.3%
add-sqr-sqrt71.3%
pow271.3%
fma-udef71.3%
unpow271.3%
hypot-def71.3%
Applied egg-rr71.3%
distribute-lft-out99.9%
+-commutative99.9%
Simplified99.9%
distribute-rgt-in76.4%
Applied egg-rr75.7%
+-commutative75.7%
distribute-rgt-out99.1%
pow-plus99.2%
metadata-eval99.2%
+-commutative99.2%
Simplified99.2%
Final simplification99.2%
(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 82.4%
Taylor expanded in x around inf 54.2%
Final simplification54.2%
herbie shell --seed 2023309
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))