
(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 8 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 (/ y (+ x y))) (t_1 (/ (* x (/ x y)) (- y x))))
(if (<= y -1.15e-66)
t_0
(if (<= y -1.42e-182)
t_1
(if (<= y -1.8e-189)
t_0
(if (<= y -5e-262)
(/ x y)
(if (<= y 2.2e-304)
(/ (* x x) (* y y))
(if (<= y 2.3e-269) (/ x y) (if (<= y 1.7e-78) t_1 t_0)))))))))
double code(double x, double y) {
double t_0 = y / (x + y);
double t_1 = (x * (x / y)) / (y - x);
double tmp;
if (y <= -1.15e-66) {
tmp = t_0;
} else if (y <= -1.42e-182) {
tmp = t_1;
} else if (y <= -1.8e-189) {
tmp = t_0;
} else if (y <= -5e-262) {
tmp = x / y;
} else if (y <= 2.2e-304) {
tmp = (x * x) / (y * y);
} else if (y <= 2.3e-269) {
tmp = x / y;
} else if (y <= 1.7e-78) {
tmp = t_1;
} else {
tmp = t_0;
}
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 = y / (x + y)
t_1 = (x * (x / y)) / (y - x)
if (y <= (-1.15d-66)) then
tmp = t_0
else if (y <= (-1.42d-182)) then
tmp = t_1
else if (y <= (-1.8d-189)) then
tmp = t_0
else if (y <= (-5d-262)) then
tmp = x / y
else if (y <= 2.2d-304) then
tmp = (x * x) / (y * y)
else if (y <= 2.3d-269) then
tmp = x / y
else if (y <= 1.7d-78) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (x + y);
double t_1 = (x * (x / y)) / (y - x);
double tmp;
if (y <= -1.15e-66) {
tmp = t_0;
} else if (y <= -1.42e-182) {
tmp = t_1;
} else if (y <= -1.8e-189) {
tmp = t_0;
} else if (y <= -5e-262) {
tmp = x / y;
} else if (y <= 2.2e-304) {
tmp = (x * x) / (y * y);
} else if (y <= 2.3e-269) {
tmp = x / y;
} else if (y <= 1.7e-78) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y / (x + y) t_1 = (x * (x / y)) / (y - x) tmp = 0 if y <= -1.15e-66: tmp = t_0 elif y <= -1.42e-182: tmp = t_1 elif y <= -1.8e-189: tmp = t_0 elif y <= -5e-262: tmp = x / y elif y <= 2.2e-304: tmp = (x * x) / (y * y) elif y <= 2.3e-269: tmp = x / y elif y <= 1.7e-78: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y / Float64(x + y)) t_1 = Float64(Float64(x * Float64(x / y)) / Float64(y - x)) tmp = 0.0 if (y <= -1.15e-66) tmp = t_0; elseif (y <= -1.42e-182) tmp = t_1; elseif (y <= -1.8e-189) tmp = t_0; elseif (y <= -5e-262) tmp = Float64(x / y); elseif (y <= 2.2e-304) tmp = Float64(Float64(x * x) / Float64(y * y)); elseif (y <= 2.3e-269) tmp = Float64(x / y); elseif (y <= 1.7e-78) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y / (x + y); t_1 = (x * (x / y)) / (y - x); tmp = 0.0; if (y <= -1.15e-66) tmp = t_0; elseif (y <= -1.42e-182) tmp = t_1; elseif (y <= -1.8e-189) tmp = t_0; elseif (y <= -5e-262) tmp = x / y; elseif (y <= 2.2e-304) tmp = (x * x) / (y * y); elseif (y <= 2.3e-269) tmp = x / y; elseif (y <= 1.7e-78) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.15e-66], t$95$0, If[LessEqual[y, -1.42e-182], t$95$1, If[LessEqual[y, -1.8e-189], t$95$0, If[LessEqual[y, -5e-262], N[(x / y), $MachinePrecision], If[LessEqual[y, 2.2e-304], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3e-269], N[(x / y), $MachinePrecision], If[LessEqual[y, 1.7e-78], t$95$1, t$95$0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x + y}\\
t_1 := \frac{x \cdot \frac{x}{y}}{y - x}\\
\mathbf{if}\;y \leq -1.15 \cdot 10^{-66}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.42 \cdot 10^{-182}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -1.8 \cdot 10^{-189}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -5 \cdot 10^{-262}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-304}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y}\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-269}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-78}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.14999999999999996e-66 or -1.4199999999999999e-182 < y < -1.80000000000000008e-189 or 1.70000000000000006e-78 < y Initial program 100.0%
div-inv99.7%
add-sqr-sqrt48.2%
fabs-sqr48.2%
add-sqr-sqrt49.0%
*-commutative49.0%
add-sqr-sqrt6.6%
fabs-sqr6.6%
add-sqr-sqrt13.9%
Applied egg-rr13.9%
flip--8.3%
associate-*r/7.1%
+-commutative7.1%
Applied egg-rr7.1%
Taylor expanded in x around 0 1.6%
unpow21.6%
mul-1-neg1.6%
distribute-rgt-neg-out1.6%
Simplified1.6%
associate-*r*2.0%
lft-mult-inverse2.0%
*-un-lft-identity2.0%
add-sqr-sqrt0.9%
sqrt-unprod16.8%
sqr-neg16.8%
sqrt-unprod32.9%
add-sqr-sqrt69.8%
add-log-exp4.0%
*-un-lft-identity4.0%
log-prod4.0%
add-log-exp69.8%
metadata-eval69.8%
Applied egg-rr69.8%
+-lft-identity69.8%
Simplified69.8%
if -1.14999999999999996e-66 < y < -1.4199999999999999e-182 or 2.3e-269 < y < 1.70000000000000006e-78Initial program 100.0%
div-inv99.8%
add-sqr-sqrt42.3%
fabs-sqr42.3%
add-sqr-sqrt42.8%
*-commutative42.8%
add-sqr-sqrt15.1%
fabs-sqr15.1%
add-sqr-sqrt28.1%
Applied egg-rr28.1%
flip--28.3%
associate-*r/28.2%
+-commutative28.2%
Applied egg-rr28.2%
Taylor expanded in y around 0 28.3%
unpow228.3%
associate-/l*28.6%
associate-/r/28.7%
Simplified28.7%
associate-*l/28.3%
*-un-lft-identity28.3%
associate-*l/28.3%
frac-2neg28.3%
div-inv28.4%
associate-*l/28.4%
*-un-lft-identity28.4%
distribute-neg-frac28.4%
add-sqr-sqrt15.3%
sqrt-unprod28.4%
sqr-neg28.4%
sqrt-unprod21.4%
add-sqr-sqrt49.9%
frac-2neg49.9%
associate-*r/54.0%
distribute-neg-in54.0%
add-sqr-sqrt21.5%
sqrt-unprod54.1%
sqr-neg54.1%
sqrt-unprod32.8%
add-sqr-sqrt54.2%
sub-neg54.2%
Applied egg-rr54.2%
associate-*r/54.3%
*-rgt-identity54.3%
Simplified54.3%
if -1.80000000000000008e-189 < y < -4.99999999999999992e-262 or 2.2e-304 < y < 2.3e-269Initial program 100.0%
div-inv99.7%
add-sqr-sqrt53.2%
fabs-sqr53.2%
add-sqr-sqrt53.3%
*-commutative53.3%
add-sqr-sqrt36.6%
fabs-sqr36.6%
add-sqr-sqrt79.9%
Applied egg-rr79.9%
Taylor expanded in y around 0 80.1%
if -4.99999999999999992e-262 < y < 2.2e-304Initial program 100.0%
div-inv99.9%
add-sqr-sqrt49.7%
fabs-sqr49.7%
add-sqr-sqrt49.9%
*-commutative49.9%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt43.0%
Applied egg-rr43.0%
flip--43.3%
associate-*r/43.2%
+-commutative43.2%
Applied egg-rr43.2%
Taylor expanded in y around 0 43.3%
unpow243.3%
associate-/l*44.3%
associate-/r/44.3%
Simplified44.3%
Taylor expanded in x around 0 72.6%
unpow272.6%
unpow272.6%
Simplified72.6%
Final simplification68.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ x y))) (t_1 (/ (/ x y) (/ (- y x) x))))
(if (<= y -1.65e-66)
t_0
(if (<= y -9.6e-184)
t_1
(if (<= y -6.5e-189)
t_0
(if (<= y -2.25e-262)
(/ x y)
(if (<= y 2.2e-304)
(/ (* x x) (* y y))
(if (<= y 1.5e-269) (/ x y) (if (<= y 5.8e+57) t_1 t_0)))))))))
double code(double x, double y) {
double t_0 = y / (x + y);
double t_1 = (x / y) / ((y - x) / x);
double tmp;
if (y <= -1.65e-66) {
tmp = t_0;
} else if (y <= -9.6e-184) {
tmp = t_1;
} else if (y <= -6.5e-189) {
tmp = t_0;
} else if (y <= -2.25e-262) {
tmp = x / y;
} else if (y <= 2.2e-304) {
tmp = (x * x) / (y * y);
} else if (y <= 1.5e-269) {
tmp = x / y;
} else if (y <= 5.8e+57) {
tmp = t_1;
} else {
tmp = t_0;
}
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 = y / (x + y)
t_1 = (x / y) / ((y - x) / x)
if (y <= (-1.65d-66)) then
tmp = t_0
else if (y <= (-9.6d-184)) then
tmp = t_1
else if (y <= (-6.5d-189)) then
tmp = t_0
else if (y <= (-2.25d-262)) then
tmp = x / y
else if (y <= 2.2d-304) then
tmp = (x * x) / (y * y)
else if (y <= 1.5d-269) then
tmp = x / y
else if (y <= 5.8d+57) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (x + y);
double t_1 = (x / y) / ((y - x) / x);
double tmp;
if (y <= -1.65e-66) {
tmp = t_0;
} else if (y <= -9.6e-184) {
tmp = t_1;
} else if (y <= -6.5e-189) {
tmp = t_0;
} else if (y <= -2.25e-262) {
tmp = x / y;
} else if (y <= 2.2e-304) {
tmp = (x * x) / (y * y);
} else if (y <= 1.5e-269) {
tmp = x / y;
} else if (y <= 5.8e+57) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y / (x + y) t_1 = (x / y) / ((y - x) / x) tmp = 0 if y <= -1.65e-66: tmp = t_0 elif y <= -9.6e-184: tmp = t_1 elif y <= -6.5e-189: tmp = t_0 elif y <= -2.25e-262: tmp = x / y elif y <= 2.2e-304: tmp = (x * x) / (y * y) elif y <= 1.5e-269: tmp = x / y elif y <= 5.8e+57: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y / Float64(x + y)) t_1 = Float64(Float64(x / y) / Float64(Float64(y - x) / x)) tmp = 0.0 if (y <= -1.65e-66) tmp = t_0; elseif (y <= -9.6e-184) tmp = t_1; elseif (y <= -6.5e-189) tmp = t_0; elseif (y <= -2.25e-262) tmp = Float64(x / y); elseif (y <= 2.2e-304) tmp = Float64(Float64(x * x) / Float64(y * y)); elseif (y <= 1.5e-269) tmp = Float64(x / y); elseif (y <= 5.8e+57) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y / (x + y); t_1 = (x / y) / ((y - x) / x); tmp = 0.0; if (y <= -1.65e-66) tmp = t_0; elseif (y <= -9.6e-184) tmp = t_1; elseif (y <= -6.5e-189) tmp = t_0; elseif (y <= -2.25e-262) tmp = x / y; elseif (y <= 2.2e-304) tmp = (x * x) / (y * y); elseif (y <= 1.5e-269) tmp = x / y; elseif (y <= 5.8e+57) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] / N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.65e-66], t$95$0, If[LessEqual[y, -9.6e-184], t$95$1, If[LessEqual[y, -6.5e-189], t$95$0, If[LessEqual[y, -2.25e-262], N[(x / y), $MachinePrecision], If[LessEqual[y, 2.2e-304], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e-269], N[(x / y), $MachinePrecision], If[LessEqual[y, 5.8e+57], t$95$1, t$95$0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x + y}\\
t_1 := \frac{\frac{x}{y}}{\frac{y - x}{x}}\\
\mathbf{if}\;y \leq -1.65 \cdot 10^{-66}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -9.6 \cdot 10^{-184}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-189}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.25 \cdot 10^{-262}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-304}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y}\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-269}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+57}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.6499999999999999e-66 or -9.60000000000000097e-184 < y < -6.5000000000000001e-189 or 5.8000000000000003e57 < y Initial program 100.0%
div-inv99.8%
add-sqr-sqrt55.0%
fabs-sqr55.0%
add-sqr-sqrt55.8%
*-commutative55.8%
add-sqr-sqrt2.8%
fabs-sqr2.8%
add-sqr-sqrt11.9%
Applied egg-rr11.9%
flip--5.6%
associate-*r/4.9%
+-commutative4.9%
Applied egg-rr4.9%
Taylor expanded in x around 0 1.5%
unpow21.5%
mul-1-neg1.5%
distribute-rgt-neg-out1.5%
Simplified1.5%
associate-*r*1.9%
lft-mult-inverse1.9%
*-un-lft-identity1.9%
add-sqr-sqrt1.2%
sqrt-unprod12.3%
sqr-neg12.3%
sqrt-unprod32.4%
add-sqr-sqrt78.4%
add-log-exp3.8%
*-un-lft-identity3.8%
log-prod3.8%
add-log-exp78.4%
metadata-eval78.4%
Applied egg-rr78.4%
+-lft-identity78.4%
Simplified78.4%
if -1.6499999999999999e-66 < y < -9.60000000000000097e-184 or 1.4999999999999999e-269 < y < 5.8000000000000003e57Initial program 100.0%
div-inv99.7%
add-sqr-sqrt33.5%
fabs-sqr33.5%
add-sqr-sqrt34.1%
*-commutative34.1%
add-sqr-sqrt17.9%
fabs-sqr17.9%
add-sqr-sqrt25.5%
Applied egg-rr25.5%
flip--24.4%
associate-*r/23.2%
+-commutative23.2%
Applied egg-rr23.2%
Taylor expanded in y around 0 23.0%
unpow223.0%
associate-/l*23.1%
associate-/r/23.2%
Simplified23.2%
associate-*l/23.0%
*-un-lft-identity23.0%
associate-*l/23.0%
frac-2neg23.0%
div-inv23.0%
associate-*l/23.0%
*-un-lft-identity23.0%
distribute-neg-frac23.0%
add-sqr-sqrt15.3%
sqrt-unprod23.0%
sqr-neg23.0%
sqrt-unprod12.6%
add-sqr-sqrt34.0%
frac-2neg34.0%
associate-*r/36.4%
distribute-neg-in36.4%
add-sqr-sqrt12.6%
sqrt-unprod36.2%
sqr-neg36.2%
sqrt-unprod23.7%
add-sqr-sqrt36.2%
sub-neg36.2%
Applied egg-rr36.2%
associate-*r/36.3%
*-rgt-identity36.3%
*-commutative36.3%
associate-/l*52.6%
Simplified52.6%
if -6.5000000000000001e-189 < y < -2.24999999999999999e-262 or 2.2e-304 < y < 1.4999999999999999e-269Initial program 100.0%
div-inv99.7%
add-sqr-sqrt53.2%
fabs-sqr53.2%
add-sqr-sqrt53.3%
*-commutative53.3%
add-sqr-sqrt36.6%
fabs-sqr36.6%
add-sqr-sqrt79.9%
Applied egg-rr79.9%
Taylor expanded in y around 0 80.1%
if -2.24999999999999999e-262 < y < 2.2e-304Initial program 100.0%
div-inv99.9%
add-sqr-sqrt49.7%
fabs-sqr49.7%
add-sqr-sqrt49.9%
*-commutative49.9%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt43.0%
Applied egg-rr43.0%
flip--43.3%
associate-*r/43.2%
+-commutative43.2%
Applied egg-rr43.2%
Taylor expanded in y around 0 43.3%
unpow243.3%
associate-/l*44.3%
associate-/r/44.3%
Simplified44.3%
Taylor expanded in x around 0 72.6%
unpow272.6%
unpow272.6%
Simplified72.6%
Final simplification70.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ x y))))
(if (<= y -1.25e-66)
t_0
(if (<= y -2e-183)
(/ (* (/ x y) (- x)) (+ x y))
(if (<= y -1e-188)
t_0
(if (<= y -6.5e-262)
(/ x y)
(if (<= y 2.35e-304)
(/ (* x x) (* y y))
(if (<= y 9.6e-270)
(/ x y)
(if (<= y 3.3e+57) (/ (/ x y) (/ (- y x) x)) t_0)))))))))
double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (y <= -1.25e-66) {
tmp = t_0;
} else if (y <= -2e-183) {
tmp = ((x / y) * -x) / (x + y);
} else if (y <= -1e-188) {
tmp = t_0;
} else if (y <= -6.5e-262) {
tmp = x / y;
} else if (y <= 2.35e-304) {
tmp = (x * x) / (y * y);
} else if (y <= 9.6e-270) {
tmp = x / y;
} else if (y <= 3.3e+57) {
tmp = (x / y) / ((y - x) / x);
} else {
tmp = t_0;
}
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 (y <= (-1.25d-66)) then
tmp = t_0
else if (y <= (-2d-183)) then
tmp = ((x / y) * -x) / (x + y)
else if (y <= (-1d-188)) then
tmp = t_0
else if (y <= (-6.5d-262)) then
tmp = x / y
else if (y <= 2.35d-304) then
tmp = (x * x) / (y * y)
else if (y <= 9.6d-270) then
tmp = x / y
else if (y <= 3.3d+57) then
tmp = (x / y) / ((y - x) / x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (y <= -1.25e-66) {
tmp = t_0;
} else if (y <= -2e-183) {
tmp = ((x / y) * -x) / (x + y);
} else if (y <= -1e-188) {
tmp = t_0;
} else if (y <= -6.5e-262) {
tmp = x / y;
} else if (y <= 2.35e-304) {
tmp = (x * x) / (y * y);
} else if (y <= 9.6e-270) {
tmp = x / y;
} else if (y <= 3.3e+57) {
tmp = (x / y) / ((y - x) / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y / (x + y) tmp = 0 if y <= -1.25e-66: tmp = t_0 elif y <= -2e-183: tmp = ((x / y) * -x) / (x + y) elif y <= -1e-188: tmp = t_0 elif y <= -6.5e-262: tmp = x / y elif y <= 2.35e-304: tmp = (x * x) / (y * y) elif y <= 9.6e-270: tmp = x / y elif y <= 3.3e+57: tmp = (x / y) / ((y - x) / x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y / Float64(x + y)) tmp = 0.0 if (y <= -1.25e-66) tmp = t_0; elseif (y <= -2e-183) tmp = Float64(Float64(Float64(x / y) * Float64(-x)) / Float64(x + y)); elseif (y <= -1e-188) tmp = t_0; elseif (y <= -6.5e-262) tmp = Float64(x / y); elseif (y <= 2.35e-304) tmp = Float64(Float64(x * x) / Float64(y * y)); elseif (y <= 9.6e-270) tmp = Float64(x / y); elseif (y <= 3.3e+57) tmp = Float64(Float64(x / y) / Float64(Float64(y - x) / x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y / (x + y); tmp = 0.0; if (y <= -1.25e-66) tmp = t_0; elseif (y <= -2e-183) tmp = ((x / y) * -x) / (x + y); elseif (y <= -1e-188) tmp = t_0; elseif (y <= -6.5e-262) tmp = x / y; elseif (y <= 2.35e-304) tmp = (x * x) / (y * y); elseif (y <= 9.6e-270) tmp = x / y; elseif (y <= 3.3e+57) tmp = (x / y) / ((y - x) / x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.25e-66], t$95$0, If[LessEqual[y, -2e-183], N[(N[(N[(x / y), $MachinePrecision] * (-x)), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1e-188], t$95$0, If[LessEqual[y, -6.5e-262], N[(x / y), $MachinePrecision], If[LessEqual[y, 2.35e-304], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.6e-270], N[(x / y), $MachinePrecision], If[LessEqual[y, 3.3e+57], N[(N[(x / y), $MachinePrecision] / N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x + y}\\
\mathbf{if}\;y \leq -1.25 \cdot 10^{-66}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2 \cdot 10^{-183}:\\
\;\;\;\;\frac{\frac{x}{y} \cdot \left(-x\right)}{x + y}\\
\mathbf{elif}\;y \leq -1 \cdot 10^{-188}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-262}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{-304}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y}\\
\mathbf{elif}\;y \leq 9.6 \cdot 10^{-270}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{+57}:\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{y - x}{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.2499999999999999e-66 or -2.00000000000000001e-183 < y < -9.9999999999999995e-189 or 3.3000000000000001e57 < y Initial program 100.0%
div-inv99.8%
add-sqr-sqrt55.0%
fabs-sqr55.0%
add-sqr-sqrt55.8%
*-commutative55.8%
add-sqr-sqrt2.8%
fabs-sqr2.8%
add-sqr-sqrt11.9%
Applied egg-rr11.9%
flip--5.6%
associate-*r/4.9%
+-commutative4.9%
Applied egg-rr4.9%
Taylor expanded in x around 0 1.5%
unpow21.5%
mul-1-neg1.5%
distribute-rgt-neg-out1.5%
Simplified1.5%
associate-*r*1.9%
lft-mult-inverse1.9%
*-un-lft-identity1.9%
add-sqr-sqrt1.2%
sqrt-unprod12.3%
sqr-neg12.3%
sqrt-unprod32.4%
add-sqr-sqrt78.4%
add-log-exp3.8%
*-un-lft-identity3.8%
log-prod3.8%
add-log-exp78.4%
metadata-eval78.4%
Applied egg-rr78.4%
+-lft-identity78.4%
Simplified78.4%
if -1.2499999999999999e-66 < y < -2.00000000000000001e-183Initial program 100.0%
div-inv99.8%
add-sqr-sqrt67.9%
fabs-sqr67.9%
add-sqr-sqrt68.4%
*-commutative68.4%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt32.1%
Applied egg-rr32.1%
flip--32.1%
associate-*r/32.0%
+-commutative32.0%
Applied egg-rr32.0%
Taylor expanded in y around 0 32.2%
unpow232.2%
associate-/l*32.2%
associate-/r/32.3%
Simplified32.3%
associate-*l/32.2%
frac-2neg32.2%
add-sqr-sqrt32.1%
sqrt-unprod32.0%
sqr-neg32.0%
sqrt-unprod0.0%
add-sqr-sqrt53.3%
distribute-neg-frac53.3%
*-un-lft-identity53.3%
associate-*l/53.2%
neg-sub053.2%
*-commutative53.2%
associate-*r*53.1%
div-inv53.3%
Applied egg-rr53.3%
neg-sub053.3%
distribute-lft-neg-in53.3%
*-commutative53.3%
Simplified53.3%
if -9.9999999999999995e-189 < y < -6.5000000000000003e-262 or 2.35e-304 < y < 9.60000000000000007e-270Initial program 100.0%
div-inv99.7%
add-sqr-sqrt53.2%
fabs-sqr53.2%
add-sqr-sqrt53.3%
*-commutative53.3%
add-sqr-sqrt36.6%
fabs-sqr36.6%
add-sqr-sqrt79.9%
Applied egg-rr79.9%
Taylor expanded in y around 0 80.1%
if -6.5000000000000003e-262 < y < 2.35e-304Initial program 100.0%
div-inv99.9%
add-sqr-sqrt49.7%
fabs-sqr49.7%
add-sqr-sqrt49.9%
*-commutative49.9%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt43.0%
Applied egg-rr43.0%
flip--43.3%
associate-*r/43.2%
+-commutative43.2%
Applied egg-rr43.2%
Taylor expanded in y around 0 43.3%
unpow243.3%
associate-/l*44.3%
associate-/r/44.3%
Simplified44.3%
Taylor expanded in x around 0 72.6%
unpow272.6%
unpow272.6%
Simplified72.6%
if 9.60000000000000007e-270 < y < 3.3000000000000001e57Initial program 99.9%
div-inv99.6%
add-sqr-sqrt22.8%
fabs-sqr22.8%
add-sqr-sqrt23.5%
*-commutative23.5%
add-sqr-sqrt23.5%
fabs-sqr23.5%
add-sqr-sqrt23.5%
Applied egg-rr23.5%
flip--22.0%
associate-*r/20.5%
+-commutative20.5%
Applied egg-rr20.5%
Taylor expanded in y around 0 20.2%
unpow220.2%
associate-/l*20.3%
associate-/r/20.4%
Simplified20.4%
associate-*l/20.2%
*-un-lft-identity20.2%
associate-*l/20.1%
frac-2neg20.1%
div-inv20.2%
associate-*l/20.1%
*-un-lft-identity20.1%
distribute-neg-frac20.1%
add-sqr-sqrt20.1%
sqrt-unprod15.2%
sqr-neg15.2%
sqrt-unprod0.0%
add-sqr-sqrt28.0%
frac-2neg28.0%
associate-*r/31.2%
distribute-neg-in31.2%
add-sqr-sqrt0.0%
sqrt-unprod30.9%
sqr-neg30.9%
sqrt-unprod31.0%
add-sqr-sqrt31.0%
sub-neg31.0%
Applied egg-rr31.0%
associate-*r/31.1%
*-rgt-identity31.1%
*-commutative31.1%
associate-/l*52.5%
Simplified52.5%
Final simplification70.3%
(FPCore (x y) :precision binary64 (if (<= x -7e+40) (/ x y) (if (<= x 1.65e+156) (/ y (+ x y)) (/ (* x x) (* y y)))))
double code(double x, double y) {
double tmp;
if (x <= -7e+40) {
tmp = x / y;
} else if (x <= 1.65e+156) {
tmp = y / (x + y);
} 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) :: tmp
if (x <= (-7d+40)) then
tmp = x / y
else if (x <= 1.65d+156) then
tmp = y / (x + y)
else
tmp = (x * x) / (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -7e+40) {
tmp = x / y;
} else if (x <= 1.65e+156) {
tmp = y / (x + y);
} else {
tmp = (x * x) / (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7e+40: tmp = x / y elif x <= 1.65e+156: tmp = y / (x + y) else: tmp = (x * x) / (y * y) return tmp
function code(x, y) tmp = 0.0 if (x <= -7e+40) tmp = Float64(x / y); elseif (x <= 1.65e+156) tmp = Float64(y / Float64(x + y)); else tmp = Float64(Float64(x * x) / Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -7e+40) tmp = x / y; elseif (x <= 1.65e+156) tmp = y / (x + y); else tmp = (x * x) / (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7e+40], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.65e+156], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+156}:\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y}\\
\end{array}
\end{array}
if x < -6.9999999999999998e40Initial program 100.0%
div-inv99.7%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt12.6%
*-commutative12.6%
add-sqr-sqrt0.2%
fabs-sqr0.2%
add-sqr-sqrt41.9%
Applied egg-rr41.9%
Taylor expanded in y around 0 42.5%
if -6.9999999999999998e40 < x < 1.6499999999999999e156Initial program 100.0%
div-inv99.7%
add-sqr-sqrt53.7%
fabs-sqr53.7%
add-sqr-sqrt54.6%
*-commutative54.6%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt15.6%
Applied egg-rr15.6%
flip--12.4%
associate-*r/11.8%
+-commutative11.8%
Applied egg-rr11.8%
Taylor expanded in x around 0 1.9%
unpow21.9%
mul-1-neg1.9%
distribute-rgt-neg-out1.9%
Simplified1.9%
associate-*r*2.0%
lft-mult-inverse2.0%
*-un-lft-identity2.0%
add-sqr-sqrt1.0%
sqrt-unprod18.2%
sqr-neg18.2%
sqrt-unprod33.3%
add-sqr-sqrt68.1%
add-log-exp4.1%
*-un-lft-identity4.1%
log-prod4.1%
add-log-exp68.1%
metadata-eval68.1%
Applied egg-rr68.1%
+-lft-identity68.1%
Simplified68.1%
if 1.6499999999999999e156 < x Initial program 100.0%
div-inv100.0%
add-sqr-sqrt90.4%
fabs-sqr90.4%
add-sqr-sqrt90.7%
*-commutative90.7%
add-sqr-sqrt43.8%
fabs-sqr43.8%
add-sqr-sqrt44.1%
Applied egg-rr44.1%
flip--31.6%
associate-*r/31.6%
+-commutative31.6%
Applied egg-rr31.6%
Taylor expanded in y around 0 32.3%
unpow232.3%
associate-/l*37.3%
associate-/r/37.3%
Simplified37.3%
Taylor expanded in x around 0 57.3%
unpow257.3%
unpow257.3%
Simplified57.3%
Final simplification60.2%
(FPCore (x y) :precision binary64 (if (or (<= y -1.52e-58) (not (<= y 1.75e-69))) (/ y (+ x y)) (/ x y)))
double code(double x, double y) {
double tmp;
if ((y <= -1.52e-58) || !(y <= 1.75e-69)) {
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 <= (-1.52d-58)) .or. (.not. (y <= 1.75d-69))) 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 <= -1.52e-58) || !(y <= 1.75e-69)) {
tmp = y / (x + y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.52e-58) or not (y <= 1.75e-69): tmp = y / (x + y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.52e-58) || !(y <= 1.75e-69)) 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 <= -1.52e-58) || ~((y <= 1.75e-69))) tmp = y / (x + y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.52e-58], N[Not[LessEqual[y, 1.75e-69]], $MachinePrecision]], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.52 \cdot 10^{-58} \lor \neg \left(y \leq 1.75 \cdot 10^{-69}\right):\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if y < -1.51999999999999993e-58 or 1.7500000000000001e-69 < y Initial program 100.0%
div-inv99.7%
add-sqr-sqrt47.1%
fabs-sqr47.1%
add-sqr-sqrt48.0%
*-commutative48.0%
add-sqr-sqrt5.1%
fabs-sqr5.1%
add-sqr-sqrt11.5%
Applied egg-rr11.5%
flip--5.5%
associate-*r/4.9%
+-commutative4.9%
Applied egg-rr4.9%
Taylor expanded in x around 0 1.6%
unpow21.6%
mul-1-neg1.6%
distribute-rgt-neg-out1.6%
Simplified1.6%
associate-*r*2.0%
lft-mult-inverse2.0%
*-un-lft-identity2.0%
add-sqr-sqrt0.9%
sqrt-unprod17.0%
sqr-neg17.0%
sqrt-unprod34.1%
add-sqr-sqrt71.1%
add-log-exp4.0%
*-un-lft-identity4.0%
log-prod4.0%
add-log-exp71.1%
metadata-eval71.1%
Applied egg-rr71.1%
+-lft-identity71.1%
Simplified71.1%
if -1.51999999999999993e-58 < y < 1.7500000000000001e-69Initial program 100.0%
div-inv99.8%
add-sqr-sqrt48.8%
fabs-sqr48.8%
add-sqr-sqrt49.1%
*-commutative49.1%
add-sqr-sqrt21.1%
fabs-sqr21.1%
add-sqr-sqrt48.3%
Applied egg-rr48.3%
Taylor expanded in y around 0 48.6%
Final simplification62.4%
(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.8%
add-sqr-sqrt47.8%
fabs-sqr47.8%
add-sqr-sqrt48.4%
*-commutative48.4%
add-sqr-sqrt11.3%
fabs-sqr11.3%
add-sqr-sqrt25.8%
Applied egg-rr25.8%
Taylor expanded in y around 0 26.1%
Final simplification26.1%
(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.8%
add-sqr-sqrt47.8%
fabs-sqr47.8%
add-sqr-sqrt48.4%
*-commutative48.4%
add-sqr-sqrt11.3%
fabs-sqr11.3%
add-sqr-sqrt25.8%
Applied egg-rr25.8%
Taylor expanded in y around inf 1.3%
Final simplification1.3%
herbie shell --seed 2023224
(FPCore (x y)
:name "Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5"
:precision binary64
(/ (fabs (- x y)) (fabs y)))