
(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 1.6e+145) (* (+ (* 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 <= 1.6e+145) {
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 <= 1.6d+145) 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 <= 1.6e+145) {
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 <= 1.6e+145: 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 <= 1.6e+145) 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 <= 1.6e+145) 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, 1.6e+145], 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 1.6 \cdot 10^{+145}:\\
\;\;\;\;\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 < 1.60000000000000004e145Initial program 89.7%
sqr-pow89.6%
sqr-pow89.5%
difference-of-squares96.7%
metadata-eval96.7%
pow296.7%
metadata-eval96.7%
pow296.7%
metadata-eval96.7%
pow296.7%
metadata-eval96.7%
pow296.7%
Applied egg-rr96.7%
if 1.60000000000000004e145 < y Initial program 65.6%
sqr-pow65.6%
sqr-pow65.6%
difference-of-squares78.1%
metadata-eval78.1%
pow278.1%
metadata-eval78.1%
pow278.1%
metadata-eval78.1%
pow278.1%
metadata-eval78.1%
pow278.1%
Applied egg-rr78.1%
Taylor expanded in x around 0 90.6%
unpow290.6%
mul-1-neg90.6%
distribute-rgt-neg-out90.6%
Simplified90.6%
Final simplification95.9%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (or (<= x 2.65e-62) (and (not (<= x 7e-55)) (<= x 1.15e+22))) (* (* y y) (- (* y (- y)) (* x x))) (* (* x x) (+ (* x x) (* y y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if ((x <= 2.65e-62) || (!(x <= 7e-55) && (x <= 1.15e+22))) {
tmp = (y * y) * ((y * -y) - (x * x));
} else {
tmp = (x * x) * ((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 ((x <= 2.65d-62) .or. (.not. (x <= 7d-55)) .and. (x <= 1.15d+22)) then
tmp = (y * y) * ((y * -y) - (x * x))
else
tmp = (x * x) * ((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 ((x <= 2.65e-62) || (!(x <= 7e-55) && (x <= 1.15e+22))) {
tmp = (y * y) * ((y * -y) - (x * x));
} else {
tmp = (x * x) * ((x * x) + (y * y));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if (x <= 2.65e-62) or (not (x <= 7e-55) and (x <= 1.15e+22)): tmp = (y * y) * ((y * -y) - (x * x)) else: tmp = (x * x) * ((x * x) + (y * y)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if ((x <= 2.65e-62) || (!(x <= 7e-55) && (x <= 1.15e+22))) tmp = Float64(Float64(y * y) * Float64(Float64(y * Float64(-y)) - Float64(x * x))); else tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if ((x <= 2.65e-62) || (~((x <= 7e-55)) && (x <= 1.15e+22))) tmp = (y * y) * ((y * -y) - (x * x)); else tmp = (x * x) * ((x * x) + (y * y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[Or[LessEqual[x, 2.65e-62], And[N[Not[LessEqual[x, 7e-55]], $MachinePrecision], LessEqual[x, 1.15e+22]]], N[(N[(y * y), $MachinePrecision] * N[(N[(y * (-y)), $MachinePrecision] - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.65 \cdot 10^{-62} \lor \neg \left(x \leq 7 \cdot 10^{-55}\right) \land x \leq 1.15 \cdot 10^{+22}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right) - x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\end{array}
\end{array}
if x < 2.6499999999999998e-62 or 7.00000000000000051e-55 < x < 1.1500000000000001e22Initial program 90.7%
sqr-pow90.6%
sqr-pow90.5%
difference-of-squares96.2%
metadata-eval96.2%
pow296.2%
metadata-eval96.2%
pow296.2%
metadata-eval96.2%
pow296.2%
metadata-eval96.2%
pow296.2%
Applied egg-rr96.2%
Taylor expanded in x around 0 68.9%
unpow268.9%
mul-1-neg68.9%
distribute-rgt-neg-out68.9%
Simplified68.9%
if 2.6499999999999998e-62 < x < 7.00000000000000051e-55 or 1.1500000000000001e22 < x Initial program 74.6%
sqr-pow74.4%
sqr-pow74.4%
difference-of-squares88.7%
metadata-eval88.7%
pow288.7%
metadata-eval88.7%
pow288.7%
metadata-eval88.7%
pow288.7%
metadata-eval88.7%
pow288.7%
Applied egg-rr88.7%
Taylor expanded in x around inf 87.1%
unpow287.1%
Simplified87.1%
Final simplification73.4%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 5.5e+127) (* (* x x) (+ (* x x) (* y y))) (* (* x x) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 5.5e+127) {
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 <= 5.5d+127) 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 <= 5.5e+127) {
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 <= 5.5e+127: 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 <= 5.5e+127) 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 <= 5.5e+127) 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, 5.5e+127], 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 5.5 \cdot 10^{+127}:\\
\;\;\;\;\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 < 5.50000000000000041e127Initial program 90.1%
sqr-pow90.0%
sqr-pow89.9%
difference-of-squares96.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
Applied egg-rr96.6%
Taylor expanded in x around inf 66.6%
unpow266.6%
Simplified66.6%
if 5.50000000000000041e127 < y Initial program 63.6%
sqr-pow63.6%
sqr-pow63.6%
difference-of-squares78.8%
metadata-eval78.8%
pow278.8%
metadata-eval78.8%
pow278.8%
metadata-eval78.8%
pow278.8%
metadata-eval78.8%
pow278.8%
Applied egg-rr78.8%
Taylor expanded in x around 0 87.9%
unpow287.9%
mul-1-neg87.9%
distribute-rgt-neg-out87.9%
Simplified87.9%
Taylor expanded in x around inf 60.7%
mul-1-neg60.7%
unpow260.7%
unpow260.7%
*-commutative60.7%
Simplified60.7%
Final simplification65.9%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1e+128) (* (* x x) (* y y)) (* (* x x) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1e+128) {
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 <= 1d+128) 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 <= 1e+128) {
tmp = (x * x) * (y * y);
} else {
tmp = (x * x) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1e+128: 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 <= 1e+128) 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 <= 1e+128) 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, 1e+128], 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 10^{+128}:\\
\;\;\;\;\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 < 1.0000000000000001e128Initial program 90.1%
sqr-pow90.0%
sqr-pow89.9%
difference-of-squares96.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
metadata-eval96.6%
pow296.6%
Applied egg-rr96.6%
Taylor expanded in x around inf 66.6%
unpow266.6%
Simplified66.6%
Taylor expanded in x around 0 38.7%
unpow238.7%
unpow238.7%
*-commutative38.7%
Simplified38.7%
if 1.0000000000000001e128 < y Initial program 63.6%
sqr-pow63.6%
sqr-pow63.6%
difference-of-squares78.8%
metadata-eval78.8%
pow278.8%
metadata-eval78.8%
pow278.8%
metadata-eval78.8%
pow278.8%
metadata-eval78.8%
pow278.8%
Applied egg-rr78.8%
Taylor expanded in x around 0 87.9%
unpow287.9%
mul-1-neg87.9%
distribute-rgt-neg-out87.9%
Simplified87.9%
Taylor expanded in x around inf 60.7%
mul-1-neg60.7%
unpow260.7%
unpow260.7%
*-commutative60.7%
Simplified60.7%
Final simplification41.5%
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 86.7%
sqr-pow86.6%
sqr-pow86.5%
difference-of-squares94.3%
metadata-eval94.3%
pow294.3%
metadata-eval94.3%
pow294.3%
metadata-eval94.3%
pow294.3%
metadata-eval94.3%
pow294.3%
Applied egg-rr94.3%
Taylor expanded in x around inf 59.6%
unpow259.6%
Simplified59.6%
Taylor expanded in x around 0 35.3%
unpow235.3%
unpow235.3%
*-commutative35.3%
Simplified35.3%
Final simplification35.3%
herbie shell --seed 2023217
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))