
(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.35e+154) (* (+ (* 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 <= 1.35e+154) {
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 <= 1.35d+154) 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 <= 1.35e+154) {
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 <= 1.35e+154: 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 <= 1.35e+154) 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 <= 1.35e+154) 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, 1.35e+154], 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 1.35 \cdot 10^{+154}:\\
\;\;\;\;\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 < 1.35000000000000003e154Initial program 89.8%
sqr-pow89.7%
sqr-pow89.6%
difference-of-squares97.6%
metadata-eval97.6%
pow297.6%
metadata-eval97.6%
pow297.6%
metadata-eval97.6%
pow297.6%
metadata-eval97.6%
pow297.6%
Applied egg-rr97.6%
if 1.35000000000000003e154 < y Initial program 66.7%
sqr-pow66.7%
sqr-pow66.7%
difference-of-squares76.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
Applied egg-rr76.7%
Taylor expanded in x around 0 76.7%
unpow276.7%
Simplified76.7%
Taylor expanded in x around 0 90.0%
unpow290.0%
mul-1-neg90.0%
distribute-rgt-neg-out90.0%
Simplified90.0%
Final simplification96.7%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 1.16e-78)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 1.35e+154)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.16e-78) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 1.35e+154) {
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 <= 1.16d-78) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 1.35d+154) 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 <= 1.16e-78) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 1.35e+154) {
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 <= 1.16e-78: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 1.35e+154: 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 <= 1.16e-78) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 1.35e+154) 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 <= 1.16e-78) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 1.35e+154) 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, 1.16e-78], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+154], 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 1.16 \cdot 10^{-78}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\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 < 1.16e-78Initial program 90.4%
sqr-pow90.3%
sqr-pow90.2%
difference-of-squares97.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
metadata-eval97.0%
pow297.0%
Applied egg-rr97.0%
Taylor expanded in x around inf 68.6%
unpow268.6%
Simplified68.6%
if 1.16e-78 < y < 1.35000000000000003e154Initial program 87.8%
sqr-pow87.7%
sqr-pow87.5%
difference-of-squares99.8%
metadata-eval99.8%
pow299.8%
metadata-eval99.8%
pow299.8%
metadata-eval99.8%
pow299.8%
metadata-eval99.8%
pow299.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 92.3%
unpow292.3%
Simplified92.3%
if 1.35000000000000003e154 < y Initial program 66.7%
sqr-pow66.7%
sqr-pow66.7%
difference-of-squares76.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
metadata-eval76.7%
pow276.7%
Applied egg-rr76.7%
Taylor expanded in x around 0 76.7%
unpow276.7%
Simplified76.7%
Taylor expanded in x around 0 90.0%
unpow290.0%
mul-1-neg90.0%
distribute-rgt-neg-out90.0%
Simplified90.0%
Final simplification75.6%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 5.9e+150) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (x <= 5.9e+150) {
tmp = (y * y) * ((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 (x <= 5.9d+150) then
tmp = (y * y) * ((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 (x <= 5.9e+150) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if x <= 5.9e+150: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * (y * y) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (x <= 5.9e+150) 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
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5.9e+150) tmp = (y * y) * ((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[x, 5.9e+150], 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}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.9 \cdot 10^{+150}:\\
\;\;\;\;\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.90000000000000023e150Initial program 88.2%
sqr-pow88.1%
sqr-pow88.0%
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 71.1%
unpow271.1%
Simplified71.1%
if 5.90000000000000023e150 < x Initial program 81.8%
sqr-pow81.8%
sqr-pow81.8%
difference-of-squares90.9%
metadata-eval90.9%
pow290.9%
metadata-eval90.9%
pow290.9%
metadata-eval90.9%
pow290.9%
metadata-eval90.9%
pow290.9%
Applied egg-rr90.9%
Taylor expanded in x around 0 65.9%
unpow265.9%
Simplified65.9%
Taylor expanded in y around 0 70.5%
unpow270.5%
unpow270.5%
Simplified70.5%
Final simplification70.9%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 6.5e+133) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (x <= 6.5e+133) {
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 <= 6.5d+133) 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 <= 6.5e+133) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if x <= 6.5e+133: 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 <= 6.5e+133) 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 <= 6.5e+133) 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, 6.5e+133], 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 6.5 \cdot 10^{+133}:\\
\;\;\;\;\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 < 6.5000000000000004e133Initial program 88.6%
sqr-pow88.5%
sqr-pow88.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.9%
unpow270.9%
Simplified70.9%
Taylor expanded in x around 0 63.1%
unpow263.1%
mul-1-neg63.1%
distribute-rgt-neg-out63.1%
Simplified63.1%
if 6.5000000000000004e133 < x Initial program 80.0%
sqr-pow80.0%
sqr-pow80.0%
difference-of-squares91.1%
metadata-eval91.1%
pow291.1%
metadata-eval91.1%
pow291.1%
metadata-eval91.1%
pow291.1%
metadata-eval91.1%
pow291.1%
Applied egg-rr91.1%
Taylor expanded in x around 0 66.7%
unpow266.7%
Simplified66.7%
Taylor expanded in y around 0 68.9%
unpow268.9%
unpow268.9%
Simplified68.9%
Final simplification64.1%
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 87.1%
sqr-pow87.0%
sqr-pow86.9%
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.2%
unpow270.2%
Simplified70.2%
Taylor expanded in y around 0 33.2%
unpow233.2%
unpow233.2%
Simplified33.2%
Final simplification33.2%
herbie shell --seed 2023230
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))