
(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 (* (+ (* x x) (* y y)) (* (- x y) (+ x y))))
double code(double x, double y) {
return ((x * x) + (y * y)) * ((x - y) * (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * x) + (y * y)) * ((x - y) * (x + y))
end function
public static double code(double x, double y) {
return ((x * x) + (y * y)) * ((x - y) * (x + y));
}
def code(x, y): return ((x * x) + (y * y)) * ((x - y) * (x + y))
function code(x, y) return Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x - y) * Float64(x + y))) end
function tmp = code(x, y) tmp = ((x * x) + (y * y)) * ((x - y) * (x + y)); end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x + y \cdot y\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)
\end{array}
Initial program 82.0%
sqr-pow81.9%
sqr-pow81.9%
difference-of-squares88.5%
metadata-eval88.5%
pow288.5%
metadata-eval88.5%
pow288.5%
metadata-eval88.5%
pow288.5%
metadata-eval88.5%
pow288.5%
Applied egg-rr88.5%
difference-of-squares99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= y 8.3e-69)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 1.15e+139)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))
double code(double x, double y) {
double tmp;
if (y <= 8.3e-69) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 1.15e+139) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 8.3d-69) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 1.15d+139) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 8.3e-69) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 1.15e+139) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8.3e-69: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 1.15e+139: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if (y <= 8.3e-69) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 1.15e+139) tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 8.3e-69) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 1.15e+139) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8.3e-69], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.15e+139], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.3 \cdot 10^{-69}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{+139}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 8.3000000000000004e-69Initial program 88.9%
sqr-pow88.7%
sqr-pow88.7%
difference-of-squares94.0%
metadata-eval94.0%
pow294.0%
metadata-eval94.0%
pow294.0%
metadata-eval94.0%
pow294.0%
metadata-eval94.0%
pow294.0%
Applied egg-rr94.0%
Taylor expanded in x around inf 73.6%
unpow273.6%
Simplified73.6%
if 8.3000000000000004e-69 < y < 1.15e139Initial program 87.5%
sqr-pow87.4%
sqr-pow87.1%
difference-of-squares99.6%
metadata-eval99.6%
pow299.6%
metadata-eval99.6%
pow299.6%
metadata-eval99.6%
pow299.6%
metadata-eval99.6%
pow299.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 88.0%
unpow288.0%
Simplified88.0%
if 1.15e139 < y Initial program 48.8%
sqr-pow48.8%
sqr-pow48.8%
difference-of-squares58.1%
metadata-eval58.1%
pow258.1%
metadata-eval58.1%
pow258.1%
metadata-eval58.1%
pow258.1%
metadata-eval58.1%
pow258.1%
Applied egg-rr58.1%
Taylor expanded in x around 0 58.1%
unpow258.1%
Simplified58.1%
Taylor expanded in x around 0 76.7%
unpow276.7%
mul-1-neg76.7%
distribute-rgt-neg-out76.7%
Simplified76.7%
Final simplification75.5%
(FPCore (x y) :precision binary64 (if (or (<= x 1.5e+170) (and (not (<= x 6.4e+179)) (<= x 4.2e+221))) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if ((x <= 1.5e+170) || (!(x <= 6.4e+179) && (x <= 4.2e+221))) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= 1.5d+170) .or. (.not. (x <= 6.4d+179)) .and. (x <= 4.2d+221)) then
tmp = (y * y) * (y * -y)
else
tmp = (x * x) * (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= 1.5e+170) || (!(x <= 6.4e+179) && (x <= 4.2e+221))) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= 1.5e+170) or (not (x <= 6.4e+179) and (x <= 4.2e+221)): tmp = (y * y) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if ((x <= 1.5e+170) || (!(x <= 6.4e+179) && (x <= 4.2e+221))) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); else tmp = Float64(Float64(x * x) * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= 1.5e+170) || (~((x <= 6.4e+179)) && (x <= 4.2e+221))) tmp = (y * y) * (y * -y); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, 1.5e+170], And[N[Not[LessEqual[x, 6.4e+179]], $MachinePrecision], LessEqual[x, 4.2e+221]]], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5 \cdot 10^{+170} \lor \neg \left(x \leq 6.4 \cdot 10^{+179}\right) \land x \leq 4.2 \cdot 10^{+221}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if x < 1.49999999999999998e170 or 6.4000000000000003e179 < x < 4.20000000000000004e221Initial program 83.3%
sqr-pow83.1%
sqr-pow83.1%
difference-of-squares89.8%
metadata-eval89.8%
pow289.8%
metadata-eval89.8%
pow289.8%
metadata-eval89.8%
pow289.8%
metadata-eval89.8%
pow289.8%
Applied egg-rr89.8%
Taylor expanded in x around 0 65.5%
unpow265.5%
Simplified65.5%
Taylor expanded in x around 0 62.9%
unpow262.9%
mul-1-neg62.9%
distribute-rgt-neg-out62.9%
Simplified62.9%
if 1.49999999999999998e170 < x < 6.4000000000000003e179 or 4.20000000000000004e221 < x Initial program 64.7%
sqr-pow64.7%
sqr-pow64.7%
difference-of-squares70.6%
metadata-eval70.6%
pow270.6%
metadata-eval70.6%
pow270.6%
metadata-eval70.6%
pow270.6%
metadata-eval70.6%
pow270.6%
Applied egg-rr70.6%
Taylor expanded in x around 0 52.9%
unpow252.9%
Simplified52.9%
Taylor expanded in y around 0 82.4%
unpow282.4%
unpow282.4%
Simplified82.4%
Final simplification64.2%
(FPCore (x y) :precision binary64 (if (<= x 1.35e+154) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 1.35e+154) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1.35d+154) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (x * x) * (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.35e+154) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.35e+154: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(x * x) * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.35e+154) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.35e+154], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 84.1%
sqr-pow84.0%
sqr-pow83.9%
difference-of-squares90.8%
metadata-eval90.8%
pow290.8%
metadata-eval90.8%
pow290.8%
metadata-eval90.8%
pow290.8%
metadata-eval90.8%
pow290.8%
Applied egg-rr90.8%
Taylor expanded in x around 0 67.1%
unpow267.1%
Simplified67.1%
if 1.35000000000000003e154 < x Initial program 60.9%
sqr-pow60.9%
sqr-pow60.9%
difference-of-squares65.2%
metadata-eval65.2%
pow265.2%
metadata-eval65.2%
pow265.2%
metadata-eval65.2%
pow265.2%
metadata-eval65.2%
pow265.2%
Applied egg-rr65.2%
Taylor expanded in x around 0 39.1%
unpow239.1%
Simplified39.1%
Taylor expanded in y around 0 60.9%
unpow260.9%
unpow260.9%
Simplified60.9%
Final simplification66.6%
(FPCore (x y) :precision binary64 (* (* x x) (* y y)))
double code(double x, double y) {
return (x * x) * (y * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * x) * (y * y)
end function
public static double code(double x, double y) {
return (x * x) * (y * y);
}
def code(x, y): return (x * x) * (y * y)
function code(x, y) return Float64(Float64(x * x) * Float64(y * y)) end
function tmp = code(x, y) tmp = (x * x) * (y * y); end
code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(y \cdot y\right)
\end{array}
Initial program 82.0%
sqr-pow81.9%
sqr-pow81.9%
difference-of-squares88.5%
metadata-eval88.5%
pow288.5%
metadata-eval88.5%
pow288.5%
metadata-eval88.5%
pow288.5%
metadata-eval88.5%
pow288.5%
Applied egg-rr88.5%
Taylor expanded in x around 0 64.6%
unpow264.6%
Simplified64.6%
Taylor expanded in y around 0 38.0%
unpow238.0%
unpow238.0%
Simplified38.0%
Final simplification38.0%
herbie shell --seed 2023238
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))