
(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}
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 2.1e+151) (* (+ (* x x) (* y y)) (- (* x x) (* y y))) (* (* y y) (- (* y (- y)) (* x x)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 2.1e+151) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = (y * y) * ((y * -y) - (x * x));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.1d+151) then
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y))
else
tmp = (y * y) * ((y * -y) - (x * x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 2.1e+151) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = (y * y) * ((y * -y) - (x * x));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 2.1e+151: tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)) else: tmp = (y * y) * ((y * -y) - (x * x)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 2.1e+151) tmp = Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(Float64(y * Float64(-y)) - Float64(x * x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.1e+151) tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)); else tmp = (y * y) * ((y * -y) - (x * x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 2.1e+151], N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(N[(y * (-y)), $MachinePrecision] - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+151}:\\
\;\;\;\;\left(x \cdot x + 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) - x \cdot x\right)\\
\end{array}
\end{array}
if y < 2.1000000000000001e151Initial program 92.2%
sqr-pow92.1%
sqr-pow92.0%
difference-of-squares98.1%
metadata-eval98.1%
pow298.1%
metadata-eval98.1%
pow298.1%
metadata-eval98.1%
pow298.1%
metadata-eval98.1%
pow298.1%
Applied egg-rr98.1%
if 2.1000000000000001e151 < y Initial program 52.0%
sqr-pow52.0%
sqr-pow52.0%
difference-of-squares76.0%
metadata-eval76.0%
pow276.0%
metadata-eval76.0%
pow276.0%
metadata-eval76.0%
pow276.0%
metadata-eval76.0%
pow276.0%
Applied egg-rr76.0%
Taylor expanded in x around 0 96.0%
unpow296.0%
mul-1-neg96.0%
distribute-rgt-neg-out96.0%
Simplified96.0%
Final simplification97.9%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1.12e-27) (* (* x x) (+ (* x x) (* y y))) (* (* y y) (- (* y (- y)) (* x x)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.12e-27) {
tmp = (x * x) * ((x * x) + (y * y));
} else {
tmp = (y * y) * ((y * -y) - (x * x));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.12d-27) then
tmp = (x * x) * ((x * x) + (y * y))
else
tmp = (y * y) * ((y * -y) - (x * x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1.12e-27) {
tmp = (x * x) * ((x * x) + (y * y));
} else {
tmp = (y * y) * ((y * -y) - (x * x));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1.12e-27: tmp = (x * x) * ((x * x) + (y * y)) else: tmp = (y * y) * ((y * -y) - (x * x)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1.12e-27) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(Float64(y * Float64(-y)) - Float64(x * x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.12e-27) tmp = (x * x) * ((x * x) + (y * y)); else tmp = (y * y) * ((y * -y) - (x * x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1.12e-27], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(N[(y * (-y)), $MachinePrecision] - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.12 \cdot 10^{-27}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right) - x \cdot x\right)\\
\end{array}
\end{array}
if y < 1.1199999999999999e-27Initial program 94.5%
sqr-pow94.4%
sqr-pow94.3%
difference-of-squares97.8%
metadata-eval97.8%
pow297.8%
metadata-eval97.8%
pow297.8%
metadata-eval97.8%
pow297.8%
metadata-eval97.8%
pow297.8%
Applied egg-rr97.8%
Taylor expanded in x around inf 70.1%
unpow270.1%
Simplified70.1%
if 1.1199999999999999e-27 < y Initial program 66.7%
sqr-pow66.6%
sqr-pow66.4%
difference-of-squares89.3%
metadata-eval89.3%
pow289.3%
metadata-eval89.3%
pow289.3%
metadata-eval89.3%
pow289.3%
metadata-eval89.3%
pow289.3%
Applied egg-rr89.3%
Taylor expanded in x around 0 80.5%
unpow280.5%
mul-1-neg80.5%
distribute-rgt-neg-out80.5%
Simplified80.5%
Final simplification72.4%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 4.05e+105) (* (* x x) (+ (* x x) (* y y))) (* (* x x) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 4.05e+105) {
tmp = (x * x) * ((x * x) + (y * y));
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.05d+105) then
tmp = (x * x) * ((x * x) + (y * y))
else
tmp = (x * x) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 4.05e+105) {
tmp = (x * x) * ((x * x) + (y * y));
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 4.05e+105: tmp = (x * x) * ((x * x) + (y * y)) else: tmp = (x * x) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 4.05e+105) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); else tmp = Float64(Float64(x * x) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.05e+105) tmp = (x * x) * ((x * x) + (y * y)); else tmp = (x * x) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 4.05e+105], N[(N[(x * x), $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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.05 \cdot 10^{+105}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 4.04999999999999999e105Initial program 94.6%
sqr-pow94.5%
sqr-pow94.4%
difference-of-squares98.0%
metadata-eval98.0%
pow298.0%
metadata-eval98.0%
pow298.0%
metadata-eval98.0%
pow298.0%
metadata-eval98.0%
pow298.0%
Applied egg-rr98.0%
Taylor expanded in x around inf 66.4%
unpow266.4%
Simplified66.4%
if 4.04999999999999999e105 < y Initial program 48.6%
sqr-pow48.6%
sqr-pow48.6%
difference-of-squares82.9%
metadata-eval82.9%
pow282.9%
metadata-eval82.9%
pow282.9%
metadata-eval82.9%
pow282.9%
metadata-eval82.9%
pow282.9%
Applied egg-rr82.9%
Taylor expanded in x around 0 88.6%
unpow288.6%
mul-1-neg88.6%
distribute-rgt-neg-out88.6%
Simplified88.6%
Taylor expanded in x around inf 66.0%
mul-1-neg66.0%
unpow266.0%
unpow266.0%
*-commutative66.0%
Simplified66.0%
Final simplification66.4%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 3.7e+105) (* (* x x) (* y y)) (* (* x x) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 3.7e+105) {
tmp = (x * x) * (y * y);
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 3.7d+105) then
tmp = (x * x) * (y * y)
else
tmp = (x * x) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 3.7e+105) {
tmp = (x * x) * (y * y);
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 3.7e+105: tmp = (x * x) * (y * y) else: tmp = (x * x) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 3.7e+105) tmp = Float64(Float64(x * x) * Float64(y * y)); else tmp = Float64(Float64(x * x) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 3.7e+105) tmp = (x * x) * (y * y); else tmp = (x * x) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 3.7e+105], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.7 \cdot 10^{+105}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\
\end{array}
\end{array}
if y < 3.69999999999999985e105Initial program 94.6%
sqr-pow94.5%
sqr-pow94.4%
difference-of-squares98.0%
metadata-eval98.0%
pow298.0%
metadata-eval98.0%
pow298.0%
metadata-eval98.0%
pow298.0%
metadata-eval98.0%
pow298.0%
Applied egg-rr98.0%
Taylor expanded in x around inf 66.4%
unpow266.4%
Simplified66.4%
Taylor expanded in x around 0 36.8%
unpow236.8%
unpow236.8%
*-commutative36.8%
Simplified36.8%
if 3.69999999999999985e105 < y Initial program 48.6%
sqr-pow48.6%
sqr-pow48.6%
difference-of-squares82.9%
metadata-eval82.9%
pow282.9%
metadata-eval82.9%
pow282.9%
metadata-eval82.9%
pow282.9%
metadata-eval82.9%
pow282.9%
Applied egg-rr82.9%
Taylor expanded in x around 0 88.6%
unpow288.6%
mul-1-neg88.6%
distribute-rgt-neg-out88.6%
Simplified88.6%
Taylor expanded in x around inf 66.0%
mul-1-neg66.0%
unpow266.0%
unpow266.0%
*-commutative66.0%
Simplified66.0%
Final simplification40.8%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (* (* x x) (* y y)))
y = abs(y);
double code(double x, double y) {
return (x * x) * (y * y);
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * x) * (y * y)
end function
y = Math.abs(y);
public static double code(double x, double y) {
return (x * x) * (y * y);
}
y = abs(y) def code(x, y): return (x * x) * (y * y)
y = abs(y) function code(x, y) return Float64(Float64(x * x) * Float64(y * y)) end
y = abs(y) function tmp = code(x, y) tmp = (x * x) * (y * y); end
NOTE: y should be positive before calling this function code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\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.9%
metadata-eval95.9%
pow295.9%
metadata-eval95.9%
pow295.9%
metadata-eval95.9%
pow295.9%
metadata-eval95.9%
pow295.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 58.9%
unpow258.9%
Simplified58.9%
Taylor expanded in x around 0 33.3%
unpow233.3%
unpow233.3%
*-commutative33.3%
Simplified33.3%
Final simplification33.3%
herbie shell --seed 2023199
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))