
(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 6 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.75e+138) (* 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.75e+138) {
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.75d+138) 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.75e+138) {
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.75e+138: 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.75e+138) 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.75e+138) 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.75e+138], 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.75 \cdot 10^{+138}:\\
\;\;\;\;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.7499999999999999e138Initial program 86.5%
sqr-pow86.4%
sqr-pow86.2%
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%
if 1.7499999999999999e138 < x Initial program 61.8%
sqr-pow61.8%
sqr-pow61.8%
difference-of-squares73.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
Applied egg-rr73.5%
Taylor expanded in x around inf 88.2%
unpow288.2%
Simplified88.2%
Final simplification95.1%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 4.5e-43) (* (* x x) (+ (* x x) (* y y))) (if (<= y 4e+148) (* (* y y) (- (* x x) (* y y))) (* (* y y) (* y (- y))))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (y <= 4.5e-43) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 4e+148) {
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 <= 4.5d-43) then
tmp = (x * x) * ((x * x) + (y * y))
else if (y <= 4d+148) 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 <= 4.5e-43) {
tmp = (x * x) * ((x * x) + (y * y));
} else if (y <= 4e+148) {
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 <= 4.5e-43: tmp = (x * x) * ((x * x) + (y * y)) elif y <= 4e+148: 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 <= 4.5e-43) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y))); elseif (y <= 4e+148) 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 <= 4.5e-43) tmp = (x * x) * ((x * x) + (y * y)); elseif (y <= 4e+148) 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, 4.5e-43], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e+148], 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 4.5 \cdot 10^{-43}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+148}:\\
\;\;\;\;\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 < 4.50000000000000025e-43Initial program 89.1%
sqr-pow89.0%
sqr-pow88.9%
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 inf 70.8%
unpow270.8%
Simplified70.8%
if 4.50000000000000025e-43 < y < 4.0000000000000002e148Initial program 79.5%
sqr-pow79.5%
sqr-pow79.3%
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 91.0%
unpow291.0%
Simplified91.0%
if 4.0000000000000002e148 < y Initial program 59.5%
sqr-pow59.5%
sqr-pow59.5%
difference-of-squares70.3%
metadata-eval70.3%
pow270.3%
metadata-eval70.3%
pow270.3%
metadata-eval70.3%
pow270.3%
metadata-eval70.3%
pow270.3%
Applied egg-rr70.3%
Taylor expanded in x around 0 70.3%
unpow270.3%
Simplified70.3%
Taylor expanded in x around 0 81.1%
unpow281.1%
mul-1-neg81.1%
distribute-rgt-neg-out81.1%
Simplified81.1%
Final simplification75.7%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 1.02e+141) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 1.02e+141) {
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.02d+141) 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.02e+141) {
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.02e+141: 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.02e+141) 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.02e+141) 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.02e+141], 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.02 \cdot 10^{+141}:\\
\;\;\;\;\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.02e141Initial program 86.5%
sqr-pow86.4%
sqr-pow86.2%
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 71.1%
unpow271.1%
Simplified71.1%
if 1.02e141 < x Initial program 61.8%
sqr-pow61.8%
sqr-pow61.8%
difference-of-squares73.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
Applied egg-rr73.5%
Taylor expanded in x around 0 47.2%
unpow247.2%
Simplified47.2%
Taylor expanded in y around 0 61.9%
unpow261.9%
unpow261.9%
Simplified61.9%
Final simplification69.9%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= x 2.1e+138) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
double tmp;
if (x <= 2.1e+138) {
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 <= 2.1d+138) 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 <= 2.1e+138) {
tmp = (y * y) * (y * -y);
} else {
tmp = (x * x) * (y * y);
}
return tmp;
}
x = abs(x) def code(x, y): tmp = 0 if x <= 2.1e+138: 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 <= 2.1e+138) 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 <= 2.1e+138) 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, 2.1e+138], 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 2.1 \cdot 10^{+138}:\\
\;\;\;\;\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 < 2.10000000000000007e138Initial program 86.5%
sqr-pow86.4%
sqr-pow86.2%
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 71.1%
unpow271.1%
Simplified71.1%
Taylor expanded in x around 0 64.2%
unpow264.2%
mul-1-neg64.2%
distribute-rgt-neg-out64.2%
Simplified64.2%
if 2.10000000000000007e138 < x Initial program 61.8%
sqr-pow61.8%
sqr-pow61.8%
difference-of-squares73.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
metadata-eval73.5%
pow273.5%
Applied egg-rr73.5%
Taylor expanded in x around 0 47.2%
unpow247.2%
Simplified47.2%
Taylor expanded in y around 0 61.9%
unpow261.9%
unpow261.9%
Simplified61.9%
Final simplification63.9%
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 83.2%
sqr-pow83.1%
sqr-pow83.0%
difference-of-squares93.1%
metadata-eval93.1%
pow293.1%
metadata-eval93.1%
pow293.1%
metadata-eval93.1%
pow293.1%
metadata-eval93.1%
pow293.1%
Applied egg-rr93.1%
Taylor expanded in x around 0 67.9%
unpow267.9%
Simplified67.9%
Taylor expanded in y around 0 32.0%
unpow232.0%
unpow232.0%
Simplified32.0%
Final simplification32.0%
NOTE: x should be positive before calling this function (FPCore (x y) :precision binary64 0.0)
x = abs(x);
double code(double x, double y) {
return 0.0;
}
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 = 0.0d0
end function
x = Math.abs(x);
public static double code(double x, double y) {
return 0.0;
}
x = abs(x) def code(x, y): return 0.0
x = abs(x) function code(x, y) return 0.0 end
x = abs(x) function tmp = code(x, y) tmp = 0.0; end
NOTE: x should be positive before calling this function code[x_, y_] := 0.0
\begin{array}{l}
x = |x|\\
\\
0
\end{array}
Initial program 83.2%
sqr-pow83.1%
sqr-pow83.0%
difference-of-squares93.1%
metadata-eval93.1%
pow293.1%
metadata-eval93.1%
pow293.1%
metadata-eval93.1%
pow293.1%
metadata-eval93.1%
pow293.1%
Applied egg-rr93.1%
*-commutative93.1%
+-commutative93.1%
distribute-lft-in79.5%
Applied egg-rr79.5%
Taylor expanded in x around inf 45.5%
unpow257.0%
Simplified45.5%
Taylor expanded in x around 0 14.6%
unpow214.6%
unpow214.6%
distribute-lft1-in14.6%
metadata-eval14.6%
mul0-lft14.9%
unpow214.9%
mul0-lft15.3%
Simplified15.3%
Final simplification15.3%
herbie shell --seed 2023264
(FPCore (x y)
:name "Radioactive exchange between two surfaces"
:precision binary64
(- (pow x 4.0) (pow y 4.0)))