
(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 88.3%
sqr-pow88.2%
sqr-pow88.1%
difference-of-squares95.1%
metadata-eval95.1%
pow295.1%
metadata-eval95.1%
pow295.1%
metadata-eval95.1%
pow295.1%
metadata-eval95.1%
pow295.1%
Applied egg-rr95.1%
difference-of-squares99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= y 2.45e-86)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 3.7e+149)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))
double code(double x, double y) {
double tmp;
if (y <= 2.45e-86) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 3.7e+149) {
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 <= 2.45d-86) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 3.7d+149) 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 <= 2.45e-86) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 3.7e+149) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.45e-86: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 3.7e+149: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
function code(x, y) tmp = 0.0 if (y <= 2.45e-86) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 3.7e+149) 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 <= 2.45e-86) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 3.7e+149) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.45e-86], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.7e+149], 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 2.45 \cdot 10^{-86}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+149}:\\
\;\;\;\;\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 < 2.44999999999999986e-86Initial program 91.6%
sqr-pow91.5%
sqr-pow91.4%
difference-of-squares96.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
metadata-eval96.5%
pow296.5%
Applied egg-rr96.5%
Taylor expanded in x around inf 63.2%
unpow263.2%
Simplified63.2%
if 2.44999999999999986e-86 < y < 3.69999999999999978e149Initial program 90.9%
sqr-pow90.9%
sqr-pow90.6%
difference-of-squares99.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
metadata-eval99.7%
pow299.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 88.4%
unpow288.4%
Simplified88.4%
if 3.69999999999999978e149 < y Initial program 67.6%
sqr-pow67.6%
sqr-pow67.6%
difference-of-squares82.4%
metadata-eval82.4%
pow282.4%
metadata-eval82.4%
pow282.4%
metadata-eval82.4%
pow282.4%
metadata-eval82.4%
pow282.4%
Applied egg-rr82.4%
Taylor expanded in x around 0 82.4%
unpow282.4%
Simplified82.4%
Taylor expanded in x around 0 91.2%
unpow291.2%
mul-1-neg91.2%
distribute-rgt-neg-out91.2%
Simplified91.2%
Final simplification71.2%
(FPCore (x y) :precision binary64 (if (<= x 5e+153) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 5e+153) {
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 <= 5d+153) 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 <= 5e+153) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5e+153: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 5e+153) 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 <= 5e+153) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5e+153], 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 5 \cdot 10^{+153}:\\
\;\;\;\;\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 < 5.00000000000000018e153Initial program 89.8%
sqr-pow89.8%
sqr-pow89.6%
difference-of-squares96.4%
metadata-eval96.4%
pow296.4%
metadata-eval96.4%
pow296.4%
metadata-eval96.4%
pow296.4%
metadata-eval96.4%
pow296.4%
Applied egg-rr96.4%
Taylor expanded in x around 0 72.1%
unpow272.1%
Simplified72.1%
if 5.00000000000000018e153 < x Initial program 70.0%
sqr-pow70.0%
sqr-pow70.0%
difference-of-squares80.0%
metadata-eval80.0%
pow280.0%
metadata-eval80.0%
pow280.0%
metadata-eval80.0%
pow280.0%
metadata-eval80.0%
pow280.0%
Applied egg-rr80.0%
Taylor expanded in x around 0 45.0%
unpow245.0%
Simplified45.0%
Taylor expanded in y around 0 60.0%
unpow260.0%
unpow260.0%
Simplified60.0%
Final simplification71.1%
(FPCore (x y) :precision binary64 (if (<= x 1.3e+135) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
double code(double x, double y) {
double tmp;
if (x <= 1.3e+135) {
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.3d+135) 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.3e+135) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.3e+135: tmp = (y * y) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.3e+135) 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.3e+135) tmp = (y * y) * (y * -y); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.3e+135], 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.3 \cdot 10^{+135}:\\
\;\;\;\;\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.3e135Initial program 90.7%
sqr-pow90.7%
sqr-pow90.6%
difference-of-squares96.3%
metadata-eval96.3%
pow296.3%
metadata-eval96.3%
pow296.3%
metadata-eval96.3%
pow296.3%
metadata-eval96.3%
pow296.3%
Applied egg-rr96.3%
Taylor expanded in x around 0 72.7%
unpow272.7%
Simplified72.7%
Taylor expanded in x around 0 66.6%
unpow266.6%
mul-1-neg66.6%
distribute-rgt-neg-out66.6%
Simplified66.6%
if 1.3e135 < x Initial program 69.0%
sqr-pow69.0%
sqr-pow69.0%
difference-of-squares86.2%
metadata-eval86.2%
pow286.2%
metadata-eval86.2%
pow286.2%
metadata-eval86.2%
pow286.2%
metadata-eval86.2%
pow286.2%
Applied egg-rr86.2%
Taylor expanded in x around 0 48.7%
unpow248.7%
Simplified48.7%
Taylor expanded in y around 0 48.7%
unpow248.7%
unpow248.7%
Simplified48.7%
Final simplification64.5%
(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 88.3%
sqr-pow88.2%
sqr-pow88.1%
difference-of-squares95.1%
metadata-eval95.1%
pow295.1%
metadata-eval95.1%
pow295.1%
metadata-eval95.1%
pow295.1%
metadata-eval95.1%
pow295.1%
Applied egg-rr95.1%
Taylor expanded in x around 0 70.0%
unpow270.0%
Simplified70.0%
Taylor expanded in y around 0 28.7%
unpow228.7%
unpow228.7%
Simplified28.7%
Final simplification28.7%
herbie shell --seed 2023240
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))