
(FPCore (x y) :precision binary64 (/ (fabs (- x y)) (fabs y)))
double code(double x, double y) {
return fabs((x - y)) / fabs(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = abs((x - y)) / abs(y)
end function
public static double code(double x, double y) {
return Math.abs((x - y)) / Math.abs(y);
}
def code(x, y): return math.fabs((x - y)) / math.fabs(y)
function code(x, y) return Float64(abs(Float64(x - y)) / abs(y)) end
function tmp = code(x, y) tmp = abs((x - y)) / abs(y); end
code[x_, y_] := N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x - y\right|}{\left|y\right|}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (fabs (- x y)) (fabs y)))
double code(double x, double y) {
return fabs((x - y)) / fabs(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = abs((x - y)) / abs(y)
end function
public static double code(double x, double y) {
return Math.abs((x - y)) / Math.abs(y);
}
def code(x, y): return math.fabs((x - y)) / math.fabs(y)
function code(x, y) return Float64(abs(Float64(x - y)) / abs(y)) end
function tmp = code(x, y) tmp = abs((x - y)) / abs(y); end
code[x_, y_] := N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x - y\right|}{\left|y\right|}
\end{array}
(FPCore (x y) :precision binary64 (fabs (- 1.0 (/ x y))))
double code(double x, double y) {
return fabs((1.0 - (x / y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = abs((1.0d0 - (x / y)))
end function
public static double code(double x, double y) {
return Math.abs((1.0 - (x / y)));
}
def code(x, y): return math.fabs((1.0 - (x / y)))
function code(x, y) return abs(Float64(1.0 - Float64(x / y))) end
function tmp = code(x, y) tmp = abs((1.0 - (x / y))); end
code[x_, y_] := N[Abs[N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|1 - \frac{x}{y}\right|
\end{array}
Initial program 100.0%
Taylor expanded in x around -inf 100.0%
fabs-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
fabs-div100.0%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ (/ x y) (- y x)))) (t_1 (/ y (+ x y))))
(if (<= x -6.6e+183)
(/ x y)
(if (<= x -3.3e+115)
t_1
(if (<= x -8e+96)
(+ (/ x y) -1.0)
(if (<= x -1.35e-30)
t_0
(if (<= x 1.5e+69)
t_1
(if (<= x 1.22e+92)
(/ x y)
(if (<= x 2.3e+216) t_0 (/ (* x x) (* y y)))))))))))
double code(double x, double y) {
double t_0 = x * ((x / y) / (y - x));
double t_1 = y / (x + y);
double tmp;
if (x <= -6.6e+183) {
tmp = x / y;
} else if (x <= -3.3e+115) {
tmp = t_1;
} else if (x <= -8e+96) {
tmp = (x / y) + -1.0;
} else if (x <= -1.35e-30) {
tmp = t_0;
} else if (x <= 1.5e+69) {
tmp = t_1;
} else if (x <= 1.22e+92) {
tmp = x / y;
} else if (x <= 2.3e+216) {
tmp = t_0;
} else {
tmp = (x * x) / (y * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * ((x / y) / (y - x))
t_1 = y / (x + y)
if (x <= (-6.6d+183)) then
tmp = x / y
else if (x <= (-3.3d+115)) then
tmp = t_1
else if (x <= (-8d+96)) then
tmp = (x / y) + (-1.0d0)
else if (x <= (-1.35d-30)) then
tmp = t_0
else if (x <= 1.5d+69) then
tmp = t_1
else if (x <= 1.22d+92) then
tmp = x / y
else if (x <= 2.3d+216) then
tmp = t_0
else
tmp = (x * x) / (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * ((x / y) / (y - x));
double t_1 = y / (x + y);
double tmp;
if (x <= -6.6e+183) {
tmp = x / y;
} else if (x <= -3.3e+115) {
tmp = t_1;
} else if (x <= -8e+96) {
tmp = (x / y) + -1.0;
} else if (x <= -1.35e-30) {
tmp = t_0;
} else if (x <= 1.5e+69) {
tmp = t_1;
} else if (x <= 1.22e+92) {
tmp = x / y;
} else if (x <= 2.3e+216) {
tmp = t_0;
} else {
tmp = (x * x) / (y * y);
}
return tmp;
}
def code(x, y): t_0 = x * ((x / y) / (y - x)) t_1 = y / (x + y) tmp = 0 if x <= -6.6e+183: tmp = x / y elif x <= -3.3e+115: tmp = t_1 elif x <= -8e+96: tmp = (x / y) + -1.0 elif x <= -1.35e-30: tmp = t_0 elif x <= 1.5e+69: tmp = t_1 elif x <= 1.22e+92: tmp = x / y elif x <= 2.3e+216: tmp = t_0 else: tmp = (x * x) / (y * y) return tmp
function code(x, y) t_0 = Float64(x * Float64(Float64(x / y) / Float64(y - x))) t_1 = Float64(y / Float64(x + y)) tmp = 0.0 if (x <= -6.6e+183) tmp = Float64(x / y); elseif (x <= -3.3e+115) tmp = t_1; elseif (x <= -8e+96) tmp = Float64(Float64(x / y) + -1.0); elseif (x <= -1.35e-30) tmp = t_0; elseif (x <= 1.5e+69) tmp = t_1; elseif (x <= 1.22e+92) tmp = Float64(x / y); elseif (x <= 2.3e+216) tmp = t_0; else tmp = Float64(Float64(x * x) / Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) t_0 = x * ((x / y) / (y - x)); t_1 = y / (x + y); tmp = 0.0; if (x <= -6.6e+183) tmp = x / y; elseif (x <= -3.3e+115) tmp = t_1; elseif (x <= -8e+96) tmp = (x / y) + -1.0; elseif (x <= -1.35e-30) tmp = t_0; elseif (x <= 1.5e+69) tmp = t_1; elseif (x <= 1.22e+92) tmp = x / y; elseif (x <= 2.3e+216) tmp = t_0; else tmp = (x * x) / (y * y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(N[(x / y), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.6e+183], N[(x / y), $MachinePrecision], If[LessEqual[x, -3.3e+115], t$95$1, If[LessEqual[x, -8e+96], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, -1.35e-30], t$95$0, If[LessEqual[x, 1.5e+69], t$95$1, If[LessEqual[x, 1.22e+92], N[(x / y), $MachinePrecision], If[LessEqual[x, 2.3e+216], t$95$0, N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{\frac{x}{y}}{y - x}\\
t_1 := \frac{y}{x + y}\\
\mathbf{if}\;x \leq -6.6 \cdot 10^{+183}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -3.3 \cdot 10^{+115}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -8 \cdot 10^{+96}:\\
\;\;\;\;\frac{x}{y} + -1\\
\mathbf{elif}\;x \leq -1.35 \cdot 10^{-30}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+69}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{+92}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+216}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y}\\
\end{array}
\end{array}
if x < -6.60000000000000019e183 or 1.49999999999999992e69 < x < 1.22e92Initial program 100.0%
div-inv99.6%
add-sqr-sqrt22.4%
fabs-sqr22.4%
add-sqr-sqrt22.9%
*-commutative22.9%
add-sqr-sqrt19.5%
fabs-sqr19.5%
add-sqr-sqrt64.6%
Applied egg-rr64.6%
Taylor expanded in y around 0 65.0%
if -6.60000000000000019e183 < x < -3.30000000000000005e115 or -1.34999999999999994e-30 < x < 1.49999999999999992e69Initial program 100.0%
div-inv99.7%
add-sqr-sqrt56.8%
fabs-sqr56.8%
add-sqr-sqrt57.6%
*-commutative57.6%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt13.6%
Applied egg-rr13.6%
flip--9.5%
associate-*r/9.5%
+-commutative9.5%
Applied egg-rr9.5%
Taylor expanded in x around 0 1.8%
unpow21.8%
mul-1-neg1.8%
distribute-rgt-neg-out1.8%
Simplified1.8%
associate-*r*2.0%
lft-mult-inverse2.0%
*-un-lft-identity2.0%
neg-sub02.0%
metadata-eval2.0%
sub-neg2.0%
metadata-eval2.0%
add-sqr-sqrt1.1%
sqrt-unprod18.6%
sqr-neg18.6%
sqrt-unprod31.6%
add-sqr-sqrt73.4%
Applied egg-rr73.4%
+-lft-identity73.4%
Simplified73.4%
if -3.30000000000000005e115 < x < -8.0000000000000004e96Initial program 100.0%
Taylor expanded in x around -inf 100.0%
fabs-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
fabs-sub100.0%
fabs-div100.0%
rem-square-sqrt66.4%
fabs-sqr66.4%
rem-square-sqrt67.0%
div-sub67.0%
sub-neg67.0%
*-inverses67.0%
metadata-eval67.0%
+-commutative67.0%
Simplified67.0%
if -8.0000000000000004e96 < x < -1.34999999999999994e-30 or 1.22e92 < x < 2.29999999999999996e216Initial program 100.0%
div-inv99.8%
add-sqr-sqrt50.6%
fabs-sqr50.6%
add-sqr-sqrt51.3%
*-commutative51.3%
add-sqr-sqrt13.1%
fabs-sqr13.1%
add-sqr-sqrt18.9%
Applied egg-rr18.9%
flip--13.5%
associate-*r/13.4%
+-commutative13.4%
Applied egg-rr13.4%
Taylor expanded in y around 0 14.5%
unpow214.5%
associate-/l*14.7%
associate-/r/14.7%
Simplified14.7%
associate-*l/14.5%
*-un-lft-identity14.5%
associate-*l/14.5%
frac-2neg14.5%
div-inv14.5%
associate-*l/14.5%
*-un-lft-identity14.5%
distribute-neg-frac14.5%
add-sqr-sqrt8.4%
sqrt-unprod20.5%
sqr-neg20.5%
sqrt-unprod12.1%
add-sqr-sqrt36.9%
frac-2neg36.9%
associate-*r/38.8%
distribute-neg-in38.8%
add-sqr-sqrt14.0%
sqrt-unprod39.0%
sqr-neg39.0%
sqrt-unprod25.1%
add-sqr-sqrt39.3%
sub-neg39.3%
Applied egg-rr39.3%
associate-*l*52.6%
associate-*r/52.8%
*-rgt-identity52.8%
Simplified52.8%
if 2.29999999999999996e216 < x Initial program 100.0%
div-inv99.9%
add-sqr-sqrt94.5%
fabs-sqr94.5%
add-sqr-sqrt94.7%
*-commutative94.7%
add-sqr-sqrt42.2%
fabs-sqr42.2%
add-sqr-sqrt42.3%
Applied egg-rr42.3%
flip--32.8%
associate-*r/32.8%
+-commutative32.8%
Applied egg-rr32.8%
Taylor expanded in y around 0 33.0%
unpow233.0%
associate-/l*33.2%
associate-/r/33.2%
Simplified33.2%
Taylor expanded in x around 0 60.3%
unpow260.3%
unpow260.3%
Simplified60.3%
Final simplification66.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ (/ x y) (- y x)))) (t_1 (/ y (+ x y))))
(if (<= x -6.5e+183)
(/ x y)
(if (<= x -2.4e+123)
t_1
(if (<= x -1.8e+97)
(+ (/ x y) -1.0)
(if (<= x -3.3e-31)
t_0
(if (<= x 6.9e+71)
t_1
(if (<= x 1.35e+93)
(/ (* x (/ x y)) (+ x y))
(if (<= x 1.06e+216) t_0 (/ (* x x) (* y y)))))))))))
double code(double x, double y) {
double t_0 = x * ((x / y) / (y - x));
double t_1 = y / (x + y);
double tmp;
if (x <= -6.5e+183) {
tmp = x / y;
} else if (x <= -2.4e+123) {
tmp = t_1;
} else if (x <= -1.8e+97) {
tmp = (x / y) + -1.0;
} else if (x <= -3.3e-31) {
tmp = t_0;
} else if (x <= 6.9e+71) {
tmp = t_1;
} else if (x <= 1.35e+93) {
tmp = (x * (x / y)) / (x + y);
} else if (x <= 1.06e+216) {
tmp = t_0;
} else {
tmp = (x * x) / (y * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * ((x / y) / (y - x))
t_1 = y / (x + y)
if (x <= (-6.5d+183)) then
tmp = x / y
else if (x <= (-2.4d+123)) then
tmp = t_1
else if (x <= (-1.8d+97)) then
tmp = (x / y) + (-1.0d0)
else if (x <= (-3.3d-31)) then
tmp = t_0
else if (x <= 6.9d+71) then
tmp = t_1
else if (x <= 1.35d+93) then
tmp = (x * (x / y)) / (x + y)
else if (x <= 1.06d+216) then
tmp = t_0
else
tmp = (x * x) / (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * ((x / y) / (y - x));
double t_1 = y / (x + y);
double tmp;
if (x <= -6.5e+183) {
tmp = x / y;
} else if (x <= -2.4e+123) {
tmp = t_1;
} else if (x <= -1.8e+97) {
tmp = (x / y) + -1.0;
} else if (x <= -3.3e-31) {
tmp = t_0;
} else if (x <= 6.9e+71) {
tmp = t_1;
} else if (x <= 1.35e+93) {
tmp = (x * (x / y)) / (x + y);
} else if (x <= 1.06e+216) {
tmp = t_0;
} else {
tmp = (x * x) / (y * y);
}
return tmp;
}
def code(x, y): t_0 = x * ((x / y) / (y - x)) t_1 = y / (x + y) tmp = 0 if x <= -6.5e+183: tmp = x / y elif x <= -2.4e+123: tmp = t_1 elif x <= -1.8e+97: tmp = (x / y) + -1.0 elif x <= -3.3e-31: tmp = t_0 elif x <= 6.9e+71: tmp = t_1 elif x <= 1.35e+93: tmp = (x * (x / y)) / (x + y) elif x <= 1.06e+216: tmp = t_0 else: tmp = (x * x) / (y * y) return tmp
function code(x, y) t_0 = Float64(x * Float64(Float64(x / y) / Float64(y - x))) t_1 = Float64(y / Float64(x + y)) tmp = 0.0 if (x <= -6.5e+183) tmp = Float64(x / y); elseif (x <= -2.4e+123) tmp = t_1; elseif (x <= -1.8e+97) tmp = Float64(Float64(x / y) + -1.0); elseif (x <= -3.3e-31) tmp = t_0; elseif (x <= 6.9e+71) tmp = t_1; elseif (x <= 1.35e+93) tmp = Float64(Float64(x * Float64(x / y)) / Float64(x + y)); elseif (x <= 1.06e+216) tmp = t_0; else tmp = Float64(Float64(x * x) / Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) t_0 = x * ((x / y) / (y - x)); t_1 = y / (x + y); tmp = 0.0; if (x <= -6.5e+183) tmp = x / y; elseif (x <= -2.4e+123) tmp = t_1; elseif (x <= -1.8e+97) tmp = (x / y) + -1.0; elseif (x <= -3.3e-31) tmp = t_0; elseif (x <= 6.9e+71) tmp = t_1; elseif (x <= 1.35e+93) tmp = (x * (x / y)) / (x + y); elseif (x <= 1.06e+216) tmp = t_0; else tmp = (x * x) / (y * y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(N[(x / y), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.5e+183], N[(x / y), $MachinePrecision], If[LessEqual[x, -2.4e+123], t$95$1, If[LessEqual[x, -1.8e+97], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, -3.3e-31], t$95$0, If[LessEqual[x, 6.9e+71], t$95$1, If[LessEqual[x, 1.35e+93], N[(N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.06e+216], t$95$0, N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{\frac{x}{y}}{y - x}\\
t_1 := \frac{y}{x + y}\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{+183}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq -2.4 \cdot 10^{+123}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{+97}:\\
\;\;\;\;\frac{x}{y} + -1\\
\mathbf{elif}\;x \leq -3.3 \cdot 10^{-31}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6.9 \cdot 10^{+71}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+93}:\\
\;\;\;\;\frac{x \cdot \frac{x}{y}}{x + y}\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{+216}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y}\\
\end{array}
\end{array}
if x < -6.49999999999999983e183Initial program 100.0%
div-inv99.7%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt0.5%
*-commutative0.5%
add-sqr-sqrt0.3%
fabs-sqr0.3%
add-sqr-sqrt61.0%
Applied egg-rr61.0%
Taylor expanded in y around 0 61.2%
if -6.49999999999999983e183 < x < -2.39999999999999989e123 or -3.2999999999999999e-31 < x < 6.89999999999999975e71Initial program 100.0%
div-inv99.7%
add-sqr-sqrt56.8%
fabs-sqr56.8%
add-sqr-sqrt57.6%
*-commutative57.6%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt13.6%
Applied egg-rr13.6%
flip--9.5%
associate-*r/9.5%
+-commutative9.5%
Applied egg-rr9.5%
Taylor expanded in x around 0 1.8%
unpow21.8%
mul-1-neg1.8%
distribute-rgt-neg-out1.8%
Simplified1.8%
associate-*r*2.0%
lft-mult-inverse2.0%
*-un-lft-identity2.0%
neg-sub02.0%
metadata-eval2.0%
sub-neg2.0%
metadata-eval2.0%
add-sqr-sqrt1.1%
sqrt-unprod18.6%
sqr-neg18.6%
sqrt-unprod31.6%
add-sqr-sqrt73.4%
Applied egg-rr73.4%
+-lft-identity73.4%
Simplified73.4%
if -2.39999999999999989e123 < x < -1.79999999999999983e97Initial program 100.0%
Taylor expanded in x around -inf 100.0%
fabs-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
fabs-sub100.0%
fabs-div100.0%
rem-square-sqrt66.4%
fabs-sqr66.4%
rem-square-sqrt67.0%
div-sub67.0%
sub-neg67.0%
*-inverses67.0%
metadata-eval67.0%
+-commutative67.0%
Simplified67.0%
if -1.79999999999999983e97 < x < -3.2999999999999999e-31 or 1.35e93 < x < 1.06e216Initial program 100.0%
div-inv99.8%
add-sqr-sqrt50.6%
fabs-sqr50.6%
add-sqr-sqrt51.3%
*-commutative51.3%
add-sqr-sqrt13.1%
fabs-sqr13.1%
add-sqr-sqrt18.9%
Applied egg-rr18.9%
flip--13.5%
associate-*r/13.4%
+-commutative13.4%
Applied egg-rr13.4%
Taylor expanded in y around 0 14.5%
unpow214.5%
associate-/l*14.7%
associate-/r/14.7%
Simplified14.7%
associate-*l/14.5%
*-un-lft-identity14.5%
associate-*l/14.5%
frac-2neg14.5%
div-inv14.5%
associate-*l/14.5%
*-un-lft-identity14.5%
distribute-neg-frac14.5%
add-sqr-sqrt8.4%
sqrt-unprod20.5%
sqr-neg20.5%
sqrt-unprod12.1%
add-sqr-sqrt36.9%
frac-2neg36.9%
associate-*r/38.8%
distribute-neg-in38.8%
add-sqr-sqrt14.0%
sqrt-unprod39.0%
sqr-neg39.0%
sqrt-unprod25.1%
add-sqr-sqrt39.3%
sub-neg39.3%
Applied egg-rr39.3%
associate-*l*52.6%
associate-*r/52.8%
*-rgt-identity52.8%
Simplified52.8%
if 6.89999999999999975e71 < x < 1.35e93Initial program 100.0%
div-inv99.6%
add-sqr-sqrt86.8%
fabs-sqr86.8%
add-sqr-sqrt87.3%
*-commutative87.3%
add-sqr-sqrt74.8%
fabs-sqr74.8%
add-sqr-sqrt75.0%
Applied egg-rr75.0%
flip--75.0%
associate-*r/74.9%
+-commutative74.9%
Applied egg-rr74.9%
Taylor expanded in y around 0 77.4%
unpow277.4%
associate-/l*77.4%
associate-/r/77.6%
Simplified77.6%
if 1.06e216 < x Initial program 100.0%
div-inv99.9%
add-sqr-sqrt94.5%
fabs-sqr94.5%
add-sqr-sqrt94.7%
*-commutative94.7%
add-sqr-sqrt42.2%
fabs-sqr42.2%
add-sqr-sqrt42.3%
Applied egg-rr42.3%
flip--32.8%
associate-*r/32.8%
+-commutative32.8%
Applied egg-rr32.8%
Taylor expanded in y around 0 33.0%
unpow233.0%
associate-/l*33.2%
associate-/r/33.2%
Simplified33.2%
Taylor expanded in x around 0 60.3%
unpow260.3%
unpow260.3%
Simplified60.3%
Final simplification66.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ x y))))
(if (<= x -1.65e+184)
(/ x y)
(if (<= x 1.16e+69)
t_0
(if (<= x 8e+89)
(/ x y)
(if (<= x 5.3e+171) t_0 (/ (* x x) (* y y))))))))
double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (x <= -1.65e+184) {
tmp = x / y;
} else if (x <= 1.16e+69) {
tmp = t_0;
} else if (x <= 8e+89) {
tmp = x / y;
} else if (x <= 5.3e+171) {
tmp = t_0;
} else {
tmp = (x * x) / (y * y);
}
return tmp;
}
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 = y / (x + y)
if (x <= (-1.65d+184)) then
tmp = x / y
else if (x <= 1.16d+69) then
tmp = t_0
else if (x <= 8d+89) then
tmp = x / y
else if (x <= 5.3d+171) then
tmp = t_0
else
tmp = (x * x) / (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (x <= -1.65e+184) {
tmp = x / y;
} else if (x <= 1.16e+69) {
tmp = t_0;
} else if (x <= 8e+89) {
tmp = x / y;
} else if (x <= 5.3e+171) {
tmp = t_0;
} else {
tmp = (x * x) / (y * y);
}
return tmp;
}
def code(x, y): t_0 = y / (x + y) tmp = 0 if x <= -1.65e+184: tmp = x / y elif x <= 1.16e+69: tmp = t_0 elif x <= 8e+89: tmp = x / y elif x <= 5.3e+171: tmp = t_0 else: tmp = (x * x) / (y * y) return tmp
function code(x, y) t_0 = Float64(y / Float64(x + y)) tmp = 0.0 if (x <= -1.65e+184) tmp = Float64(x / y); elseif (x <= 1.16e+69) tmp = t_0; elseif (x <= 8e+89) tmp = Float64(x / y); elseif (x <= 5.3e+171) tmp = t_0; else tmp = Float64(Float64(x * x) / Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (x + y); tmp = 0.0; if (x <= -1.65e+184) tmp = x / y; elseif (x <= 1.16e+69) tmp = t_0; elseif (x <= 8e+89) tmp = x / y; elseif (x <= 5.3e+171) tmp = t_0; else tmp = (x * x) / (y * y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.65e+184], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.16e+69], t$95$0, If[LessEqual[x, 8e+89], N[(x / y), $MachinePrecision], If[LessEqual[x, 5.3e+171], t$95$0, N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x + y}\\
\mathbf{if}\;x \leq -1.65 \cdot 10^{+184}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 1.16 \cdot 10^{+69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+89}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 5.3 \cdot 10^{+171}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y}\\
\end{array}
\end{array}
if x < -1.6499999999999999e184 or 1.16000000000000005e69 < x < 7.99999999999999996e89Initial program 100.0%
div-inv99.7%
add-sqr-sqrt17.1%
fabs-sqr17.1%
add-sqr-sqrt17.6%
*-commutative17.6%
add-sqr-sqrt17.5%
fabs-sqr17.5%
add-sqr-sqrt65.6%
Applied egg-rr65.6%
Taylor expanded in y around 0 66.0%
if -1.6499999999999999e184 < x < 1.16000000000000005e69 or 7.99999999999999996e89 < x < 5.29999999999999982e171Initial program 100.0%
div-inv99.7%
add-sqr-sqrt52.1%
fabs-sqr52.1%
add-sqr-sqrt53.0%
*-commutative53.0%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt15.4%
Applied egg-rr15.4%
flip--12.2%
associate-*r/11.8%
+-commutative11.8%
Applied egg-rr11.8%
Taylor expanded in x around 0 2.0%
unpow22.0%
mul-1-neg2.0%
distribute-rgt-neg-out2.0%
Simplified2.0%
associate-*r*2.2%
lft-mult-inverse2.2%
*-un-lft-identity2.2%
neg-sub02.2%
metadata-eval2.2%
sub-neg2.2%
metadata-eval2.2%
add-sqr-sqrt1.1%
sqrt-unprod15.7%
sqr-neg15.7%
sqrt-unprod27.1%
add-sqr-sqrt62.9%
Applied egg-rr62.9%
+-lft-identity62.9%
Simplified62.9%
if 5.29999999999999982e171 < x Initial program 100.0%
div-inv99.9%
add-sqr-sqrt93.2%
fabs-sqr93.2%
add-sqr-sqrt93.5%
*-commutative93.5%
add-sqr-sqrt42.0%
fabs-sqr42.0%
add-sqr-sqrt42.2%
Applied egg-rr42.2%
flip--27.1%
associate-*r/27.1%
+-commutative27.1%
Applied egg-rr27.1%
Taylor expanded in y around 0 27.4%
unpow227.4%
associate-/l*27.8%
associate-/r/27.8%
Simplified27.8%
Taylor expanded in x around 0 48.0%
unpow248.0%
unpow248.0%
Simplified48.0%
Final simplification61.4%
(FPCore (x y) :precision binary64 (if (or (<= y -2.65e-83) (not (<= y 6e-182))) (/ y (+ x y)) (/ x y)))
double code(double x, double y) {
double tmp;
if ((y <= -2.65e-83) || !(y <= 6e-182)) {
tmp = y / (x + y);
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-2.65d-83)) .or. (.not. (y <= 6d-182))) then
tmp = y / (x + y)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -2.65e-83) || !(y <= 6e-182)) {
tmp = y / (x + y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.65e-83) or not (y <= 6e-182): tmp = y / (x + y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.65e-83) || !(y <= 6e-182)) tmp = Float64(y / Float64(x + y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2.65e-83) || ~((y <= 6e-182))) tmp = y / (x + y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.65e-83], N[Not[LessEqual[y, 6e-182]], $MachinePrecision]], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.65 \cdot 10^{-83} \lor \neg \left(y \leq 6 \cdot 10^{-182}\right):\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if y < -2.65e-83 or 6.0000000000000003e-182 < y Initial program 100.0%
div-inv99.7%
add-sqr-sqrt50.9%
fabs-sqr50.9%
add-sqr-sqrt51.8%
*-commutative51.8%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt17.3%
Applied egg-rr17.3%
flip--11.1%
associate-*r/11.0%
+-commutative11.0%
Applied egg-rr11.0%
Taylor expanded in x around 0 1.8%
unpow21.8%
mul-1-neg1.8%
distribute-rgt-neg-out1.8%
Simplified1.8%
associate-*r*2.1%
lft-mult-inverse2.1%
*-un-lft-identity2.1%
neg-sub02.1%
metadata-eval2.1%
sub-neg2.1%
metadata-eval2.1%
add-sqr-sqrt0.9%
sqrt-unprod16.4%
sqr-neg16.4%
sqrt-unprod30.2%
add-sqr-sqrt62.2%
Applied egg-rr62.2%
+-lft-identity62.2%
Simplified62.2%
if -2.65e-83 < y < 6.0000000000000003e-182Initial program 100.0%
div-inv99.8%
add-sqr-sqrt59.7%
fabs-sqr59.7%
add-sqr-sqrt60.0%
*-commutative60.0%
add-sqr-sqrt19.9%
fabs-sqr19.9%
add-sqr-sqrt45.0%
Applied egg-rr45.0%
Taylor expanded in y around 0 45.6%
Final simplification58.0%
(FPCore (x y) :precision binary64 (/ x y))
double code(double x, double y) {
return x / y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / y
end function
public static double code(double x, double y) {
return x / y;
}
def code(x, y): return x / y
function code(x, y) return Float64(x / y) end
function tmp = code(x, y) tmp = x / y; end
code[x_, y_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y}
\end{array}
Initial program 100.0%
div-inv99.7%
add-sqr-sqrt53.1%
fabs-sqr53.1%
add-sqr-sqrt53.9%
*-commutative53.9%
add-sqr-sqrt13.3%
fabs-sqr13.3%
add-sqr-sqrt24.3%
Applied egg-rr24.3%
Taylor expanded in y around 0 25.3%
Final simplification25.3%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
div-inv99.7%
add-sqr-sqrt53.1%
fabs-sqr53.1%
add-sqr-sqrt53.9%
*-commutative53.9%
add-sqr-sqrt13.3%
fabs-sqr13.3%
add-sqr-sqrt24.3%
Applied egg-rr24.3%
Taylor expanded in y around inf 1.3%
Final simplification1.3%
herbie shell --seed 2023199
(FPCore (x y)
:name "Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5"
:precision binary64
(/ (fabs (- x y)) (fabs y)))