
(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: x should be positive before calling this function (FPCore (x y) :precision binary64 (let* ((t_0 (+ (* x x) (* y y)))) (if (<= x 1.35e+154) (* t_0 (- (* x x) (* y y))) (* (* x x) t_0))))
x = abs(x);
double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= 1.35e+154) {
tmp = t_0 * ((x * x) - (y * y));
} else {
tmp = (x * x) * t_0;
}
return tmp;
}
NOTE: x 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) :: t_0
real(8) :: tmp
t_0 = (x * x) + (y * y)
if (x <= 1.35d+154) then
tmp = t_0 * ((x * x) - (y * y))
else
tmp = (x * x) * t_0
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double t_0 = (x * x) + (y * y);
double tmp;
if (x <= 1.35e+154) {
tmp = t_0 * ((x * x) - (y * y));
} else {
tmp = (x * x) * t_0;
}
return tmp;
}
x = abs(x) def code(x, y): t_0 = (x * x) + (y * y) tmp = 0 if x <= 1.35e+154: tmp = t_0 * ((x * x) - (y * y)) else: tmp = (x * x) * t_0 return tmp
x = abs(x) function code(x, y) t_0 = Float64(Float64(x * x) + Float64(y * y)) tmp = 0.0 if (x <= 1.35e+154) tmp = Float64(t_0 * Float64(Float64(x * x) - Float64(y * y))); else tmp = Float64(Float64(x * x) * t_0); end return tmp end
x = abs(x) function tmp_2 = code(x, y) t_0 = (x * x) + (y * y); tmp = 0.0; if (x <= 1.35e+154) tmp = t_0 * ((x * x) - (y * y)); else tmp = (x * x) * t_0; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.35e+154], N[(t$95$0 * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := x \cdot x + y \cdot y\\
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot t_0\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 88.4%
sqr-pow88.3%
sqr-pow88.2%
difference-of-squares95.8%
metadata-eval95.8%
pow295.8%
metadata-eval95.8%
pow295.8%
metadata-eval95.8%
pow295.8%
metadata-eval95.8%
pow295.8%
Applied egg-rr95.8%
if 1.35000000000000003e154 < x Initial program 64.5%
sqr-pow64.5%
sqr-pow64.5%
difference-of-squares74.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
Applied egg-rr74.2%
Taylor expanded in x around inf 96.8%
unpow296.8%
Simplified96.8%
Final simplification95.9%
NOTE: x should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 5.5e-55)
(* (* x x) (+ (* x x) (* y y)))
(if (<= y 1.52e+144)
(* (* y y) (- (* x x) (* y y)))
(* (* y y) (* y (- y))))))x = abs(x);
double code(double x, double y) {
double tmp;
if (y <= 5.5e-55) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 1.52e+144) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
NOTE: x 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-55) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 1.52d+144) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (y * y) * (y * -y)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (y <= 5.5e-55) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 1.52e+144) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (y * y) * (y * -y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if y <= 5.5e-55: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 1.52e+144: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (y * y) * (y * -y) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (y <= 5.5e-55) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 1.52e+144) 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
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.5e-55) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 1.52e+144) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (y * y) * (y * -y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[y, 5.5e-55], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.52e+144], 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}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{-55}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 1.52 \cdot 10^{+144}:\\
\;\;\;\;\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 < 5.4999999999999999e-55Initial program 90.3%
sqr-pow90.1%
sqr-pow90.1%
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 70.3%
unpow270.3%
Simplified70.3%
if 5.4999999999999999e-55 < y < 1.52e144Initial program 83.3%
sqr-pow83.2%
sqr-pow82.9%
difference-of-squares99.5%
metadata-eval99.5%
pow299.5%
metadata-eval99.5%
pow299.5%
metadata-eval99.5%
pow299.5%
metadata-eval99.5%
pow299.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 91.8%
unpow291.8%
Simplified91.8%
if 1.52e144 < y Initial program 62.9%
sqr-pow62.9%
sqr-pow62.9%
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 82.9%
unpow282.9%
Simplified82.9%
Taylor expanded in x around 0 91.4%
unpow291.4%
neg-mul-191.4%
distribute-rgt-neg-in91.4%
Simplified91.4%
Final simplification76.2%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1.35e+154) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 1.35e+154) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
NOTE: x 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 <= 1.35d+154) then
tmp = (y * y) * ((x * x) - (y * y))
else
tmp = (x * x) * (y * y)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (x <= 1.35e+154) {
tmp = (y * y) * ((x * x) - (y * y));
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if x <= 1.35e+154: tmp = (y * y) * ((x * x) - (y * y)) else: tmp = (x * x) * (y * y) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (x <= 1.35e+154) 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
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.35e+154) tmp = (y * y) * ((x * x) - (y * y)); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[x, 1.35e+154], 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}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\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 < 1.35000000000000003e154Initial program 88.4%
sqr-pow88.3%
sqr-pow88.2%
difference-of-squares95.8%
metadata-eval95.8%
pow295.8%
metadata-eval95.8%
pow295.8%
metadata-eval95.8%
pow295.8%
metadata-eval95.8%
pow295.8%
Applied egg-rr95.8%
Taylor expanded in x around 0 69.4%
unpow269.4%
Simplified69.4%
if 1.35000000000000003e154 < x Initial program 64.5%
sqr-pow64.5%
sqr-pow64.5%
difference-of-squares74.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
Applied egg-rr74.2%
Taylor expanded in x around 0 45.2%
unpow245.2%
Simplified45.2%
Taylor expanded in y around 0 67.7%
unpow267.7%
unpow267.7%
Simplified67.7%
Final simplification69.2%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1.25e+161) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 1.25e+161) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
NOTE: x 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 <= 1.25d+161) then
tmp = (y * y) * (y * -y)
else
tmp = (x * x) * (y * y)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
double tmp;
if (x <= 1.25e+161) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if x <= 1.25e+161: tmp = (y * y) * (y * -y) else: tmp = (x * x) * (y * y) return tmp
x = abs(x) function code(x, y) tmp = 0.0 if (x <= 1.25e+161) tmp = Float64(Float64(y * y) * Float64(y * Float64(-y))); else tmp = Float64(Float64(x * x) * Float64(y * y)); end return tmp end
x = abs(x) function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.25e+161) tmp = (y * y) * (y * -y); else tmp = (x * x) * (y * y); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_, y_] := If[LessEqual[x, 1.25e+161], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.25 \cdot 10^{+161}:\\
\;\;\;\;\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 < 1.2499999999999999e161Initial program 88.4%
sqr-pow88.3%
sqr-pow88.2%
difference-of-squares95.8%
metadata-eval95.8%
pow295.8%
metadata-eval95.8%
pow295.8%
metadata-eval95.8%
pow295.8%
metadata-eval95.8%
pow295.8%
Applied egg-rr95.8%
Taylor expanded in x around 0 69.4%
unpow269.4%
Simplified69.4%
Taylor expanded in x around 0 64.9%
unpow264.9%
neg-mul-164.9%
distribute-rgt-neg-in64.9%
Simplified64.9%
if 1.2499999999999999e161 < x Initial program 64.5%
sqr-pow64.5%
sqr-pow64.5%
difference-of-squares74.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
metadata-eval74.2%
pow274.2%
Applied egg-rr74.2%
Taylor expanded in x around 0 45.2%
unpow245.2%
Simplified45.2%
Taylor expanded in y around 0 67.7%
unpow267.7%
unpow267.7%
Simplified67.7%
Final simplification65.3%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (* (* x x) (* y y)))
x = abs(x);
double code(double x, double y) {
return (x * x) * (y * y);
}
NOTE: x 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
x = Math.abs(x);
public static double code(double x, double y) {
return (x * x) * (y * y);
}
x = abs(x) def code(x, y): return (x * x) * (y * y)
x = abs(x) function code(x, y) return Float64(Float64(x * x) * Float64(y * y)) end
x = abs(x) function tmp = code(x, y) tmp = (x * x) * (y * y); end
NOTE: x should be positive before calling this function code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\left(x \cdot x\right) \cdot \left(y \cdot y\right)
\end{array}
Initial program 85.5%
sqr-pow85.4%
sqr-pow85.4%
difference-of-squares93.2%
metadata-eval93.2%
pow293.2%
metadata-eval93.2%
pow293.2%
metadata-eval93.2%
pow293.2%
metadata-eval93.2%
pow293.2%
Applied egg-rr93.2%
Taylor expanded in x around 0 66.5%
unpow266.5%
Simplified66.5%
Taylor expanded in y around 0 30.7%
unpow230.7%
unpow230.7%
Simplified30.7%
Final simplification30.7%
herbie shell --seed 2023272
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))