
(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 4e+149) (* (+ (* x x) (* y y)) (- (* x x) (* y y))) (* (* y y) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 4e+149) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (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 <= 4d+149) then
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 4e+149) {
tmp = ((x * x) + (y * y)) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 4e+149: tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 4e+149) tmp = Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4e+149) tmp = ((x * x) + (y * y)) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 4e+149], 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[(y * (-y)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+149}:\\
\;\;\;\;\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)\right)\\
\end{array}
\end{array}
if y < 4.0000000000000002e149Initial program 88.7%
sqr-pow88.6%
sqr-pow88.4%
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%
if 4.0000000000000002e149 < y Initial program 65.4%
sqr-pow65.4%
sqr-pow65.4%
difference-of-squares80.8%
metadata-eval80.8%
pow280.8%
metadata-eval80.8%
pow280.8%
metadata-eval80.8%
pow280.8%
metadata-eval80.8%
pow280.8%
Applied egg-rr80.8%
Taylor expanded in x around 0 80.8%
unpow280.8%
Simplified80.8%
Taylor expanded in x around 0 96.2%
unpow296.2%
mul-1-neg96.2%
distribute-rgt-neg-out96.2%
Simplified96.2%
Final simplification96.2%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 4e-60)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 4.8e+149)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 4e-60) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 4.8e+149) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (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 <= 4d-60) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 4.8d+149) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 4e-60) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 4.8e+149) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 4e-60: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 4.8e+149: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 4e-60) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 4.8e+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
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4e-60) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 4.8e+149) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 4e-60], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{-60}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 4.8 \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 < 3.9999999999999999e-60Initial program 90.9%
sqr-pow90.7%
sqr-pow90.6%
difference-of-squares95.2%
metadata-eval95.2%
pow295.2%
metadata-eval95.2%
pow295.2%
metadata-eval95.2%
pow295.2%
metadata-eval95.2%
pow295.2%
Applied egg-rr95.2%
Taylor expanded in x around inf 70.5%
unpow270.5%
Simplified70.5%
if 3.9999999999999999e-60 < y < 4.80000000000000024e149Initial program 81.8%
sqr-pow81.8%
sqr-pow81.5%
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 85.1%
unpow285.1%
Simplified85.1%
if 4.80000000000000024e149 < y Initial program 65.4%
sqr-pow65.4%
sqr-pow65.4%
difference-of-squares80.8%
metadata-eval80.8%
pow280.8%
metadata-eval80.8%
pow280.8%
metadata-eval80.8%
pow280.8%
metadata-eval80.8%
pow280.8%
Applied egg-rr80.8%
Taylor expanded in x around 0 80.8%
unpow280.8%
Simplified80.8%
Taylor expanded in x around 0 96.2%
unpow296.2%
mul-1-neg96.2%
distribute-rgt-neg-out96.2%
Simplified96.2%
Final simplification76.2%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 2e+149) (* (* y y) (- (* x x) (* y y))) (* (* y y) (* y (- y)))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 2e+149) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (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 <= 2d+149) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 2e+149) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 2e+149: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 2e+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
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2e+149) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 2e+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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \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.0000000000000001e149Initial program 88.7%
sqr-pow88.6%
sqr-pow88.4%
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 67.1%
unpow267.1%
Simplified67.1%
if 2.0000000000000001e149 < y Initial program 65.4%
sqr-pow65.4%
sqr-pow65.4%
difference-of-squares80.8%
metadata-eval80.8%
pow280.8%
metadata-eval80.8%
pow280.8%
metadata-eval80.8%
pow280.8%
metadata-eval80.8%
pow280.8%
Applied egg-rr80.8%
Taylor expanded in x around 0 80.8%
unpow280.8%
Simplified80.8%
Taylor expanded in x around 0 96.2%
unpow296.2%
mul-1-neg96.2%
distribute-rgt-neg-out96.2%
Simplified96.2%
Final simplification70.0%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 4.7e+92) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (x <= 4.7e+92) {
tmp = (y * y) * (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 (x <= 4.7d+92) then
tmp = (y * y) * (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 (x <= 4.7e+92) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if x <= 4.7e+92: tmp = (y * y) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (x <= 4.7e+92) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); else tmp = 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 <= 4.7e+92) tmp = (y * y) * (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[x, 4.7e+92], N[(N[(y * y), $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}\;x \leq 4.7 \cdot 10^{+92}:\\
\;\;\;\;\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 < 4.7e92Initial program 89.7%
sqr-pow89.5%
sqr-pow89.4%
difference-of-squares96.0%
metadata-eval96.0%
pow296.0%
metadata-eval96.0%
pow296.0%
metadata-eval96.0%
pow296.0%
metadata-eval96.0%
pow296.0%
Applied egg-rr96.0%
Taylor expanded in x around 0 70.5%
unpow270.5%
Simplified70.5%
Taylor expanded in x around 0 64.6%
unpow264.6%
mul-1-neg64.6%
distribute-rgt-neg-out64.6%
Simplified64.6%
if 4.7e92 < x Initial program 69.8%
sqr-pow69.8%
sqr-pow69.8%
difference-of-squares88.4%
metadata-eval88.4%
pow288.4%
metadata-eval88.4%
pow288.4%
metadata-eval88.4%
pow288.4%
metadata-eval88.4%
pow288.4%
Applied egg-rr88.4%
Taylor expanded in x around 0 58.5%
unpow258.5%
Simplified58.5%
Taylor expanded in y around 0 58.5%
unpow258.5%
unpow258.5%
*-commutative58.5%
Simplified58.5%
Final simplification63.6%
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.3%
sqr-pow86.2%
sqr-pow86.1%
difference-of-squares94.7%
metadata-eval94.7%
pow294.7%
metadata-eval94.7%
pow294.7%
metadata-eval94.7%
pow294.7%
metadata-eval94.7%
pow294.7%
Applied egg-rr94.7%
Taylor expanded in x around 0 68.5%
unpow268.5%
Simplified68.5%
Taylor expanded in y around 0 32.6%
unpow232.6%
unpow232.6%
*-commutative32.6%
Simplified32.6%
Final simplification32.6%
herbie shell --seed 2023271
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))