
(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 87.0%
sqr-pow86.9%
sqr-pow86.7%
difference-of-squares94.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
Applied egg-rr94.8%
if 1.35000000000000003e154 < y Initial program 72.7%
sqr-pow72.7%
sqr-pow72.7%
difference-of-squares75.8%
metadata-eval75.8%
pow275.8%
metadata-eval75.8%
pow275.8%
metadata-eval75.8%
pow275.8%
metadata-eval75.8%
pow275.8%
Applied egg-rr75.8%
Taylor expanded in x around 0 75.8%
unpow275.8%
Simplified75.8%
Taylor expanded in x around 0 93.9%
unpow293.9%
mul-1-neg93.9%
distribute-rgt-neg-out93.9%
Simplified93.9%
Final simplification94.7%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 6.2e-36)
(* (* 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 <= 6.2e-36) {
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 <= 6.2d-36) 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 <= 6.2e-36) {
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 <= 6.2e-36: 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 <= 6.2e-36) 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 <= 6.2e-36) 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, 6.2e-36], 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 6.2 \cdot 10^{-36}:\\
\;\;\;\;\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 < 6.1999999999999997e-36Initial program 87.2%
sqr-pow87.1%
sqr-pow87.0%
difference-of-squares93.9%
metadata-eval93.9%
pow293.9%
metadata-eval93.9%
pow293.9%
metadata-eval93.9%
pow293.9%
metadata-eval93.9%
pow293.9%
Applied egg-rr93.9%
Taylor expanded in x around inf 73.3%
unpow273.3%
Simplified73.3%
if 6.1999999999999997e-36 < y < 1.35000000000000003e154Initial program 85.7%
sqr-pow85.7%
sqr-pow85.4%
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 89.1%
unpow289.1%
Simplified89.1%
if 1.35000000000000003e154 < y Initial program 72.7%
sqr-pow72.7%
sqr-pow72.7%
difference-of-squares75.8%
metadata-eval75.8%
pow275.8%
metadata-eval75.8%
pow275.8%
metadata-eval75.8%
pow275.8%
metadata-eval75.8%
pow275.8%
Applied egg-rr75.8%
Taylor expanded in x around 0 75.8%
unpow275.8%
Simplified75.8%
Taylor expanded in x around 0 93.9%
unpow293.9%
mul-1-neg93.9%
distribute-rgt-neg-out93.9%
Simplified93.9%
Final simplification78.1%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (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.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.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.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.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.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.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.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.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.35000000000000003e154Initial program 87.0%
sqr-pow86.9%
sqr-pow86.7%
difference-of-squares94.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
metadata-eval94.8%
pow294.8%
Applied egg-rr94.8%
Taylor expanded in x around 0 62.1%
unpow262.1%
Simplified62.1%
if 1.35000000000000003e154 < y Initial program 72.7%
sqr-pow72.7%
sqr-pow72.7%
difference-of-squares75.8%
metadata-eval75.8%
pow275.8%
metadata-eval75.8%
pow275.8%
metadata-eval75.8%
pow275.8%
metadata-eval75.8%
pow275.8%
Applied egg-rr75.8%
Taylor expanded in x around 0 75.8%
unpow275.8%
Simplified75.8%
Taylor expanded in x around 0 93.9%
unpow293.9%
mul-1-neg93.9%
distribute-rgt-neg-out93.9%
Simplified93.9%
Final simplification66.2%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 5.1e+132) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (x <= 5.1e+132) {
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 <= 5.1d+132) 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 <= 5.1e+132) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if x <= 5.1e+132: 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 <= 5.1e+132) 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 <= 5.1e+132) 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, 5.1e+132], 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 5.1 \cdot 10^{+132}:\\
\;\;\;\;\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 < 5.1000000000000001e132Initial program 90.8%
sqr-pow90.7%
sqr-pow90.6%
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 0 67.1%
unpow267.1%
Simplified67.1%
Taylor expanded in x around 0 58.6%
unpow258.6%
mul-1-neg58.6%
distribute-rgt-neg-out58.6%
Simplified58.6%
if 5.1000000000000001e132 < x Initial program 52.6%
sqr-pow52.6%
sqr-pow52.6%
difference-of-squares68.4%
metadata-eval68.4%
pow268.4%
metadata-eval68.4%
pow268.4%
metadata-eval68.4%
pow268.4%
metadata-eval68.4%
pow268.4%
Applied egg-rr68.4%
Taylor expanded in x around 0 44.9%
unpow244.9%
Simplified44.9%
Taylor expanded in y around 0 55.4%
unpow255.4%
unpow255.4%
Simplified55.4%
Final simplification58.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 85.2%
sqr-pow85.0%
sqr-pow84.9%
difference-of-squares92.4%
metadata-eval92.4%
pow292.4%
metadata-eval92.4%
pow292.4%
metadata-eval92.4%
pow292.4%
metadata-eval92.4%
pow292.4%
Applied egg-rr92.4%
Taylor expanded in x around 0 63.8%
unpow263.8%
Simplified63.8%
Taylor expanded in y around 0 31.8%
unpow231.8%
unpow231.8%
Simplified31.8%
Final simplification31.8%
herbie shell --seed 2023213
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))