
(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 (if (<= y -1.1e+50) (/ y (+ x y)) (if (<= y 1.25e-123) (fabs (/ x y)) 1.0)))
double code(double x, double y) {
double tmp;
if (y <= -1.1e+50) {
tmp = y / (x + y);
} else if (y <= 1.25e-123) {
tmp = fabs((x / y));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.1d+50)) then
tmp = y / (x + y)
else if (y <= 1.25d-123) then
tmp = abs((x / y))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.1e+50) {
tmp = y / (x + y);
} else if (y <= 1.25e-123) {
tmp = Math.abs((x / y));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.1e+50: tmp = y / (x + y) elif y <= 1.25e-123: tmp = math.fabs((x / y)) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.1e+50) tmp = Float64(y / Float64(x + y)); elseif (y <= 1.25e-123) tmp = abs(Float64(x / y)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.1e+50) tmp = y / (x + y); elseif (y <= 1.25e-123) tmp = abs((x / y)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.1e+50], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.25e-123], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{+50}:\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-123}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.10000000000000008e50Initial 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-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt1.5%
div-sub1.5%
sub-neg1.5%
*-inverses1.5%
metadata-eval1.5%
+-commutative1.5%
Simplified1.5%
+-commutative1.5%
metadata-eval1.5%
sub-neg1.5%
*-inverses1.5%
div-sub1.5%
clear-num1.5%
associate-/r/1.5%
flip--0.9%
associate-*r/0.9%
Applied egg-rr0.9%
Taylor expanded in y around inf 1.8%
neg-mul-11.8%
Simplified1.8%
expm1-log1p-u1.8%
expm1-udef1.7%
*-un-lft-identity1.7%
*-commutative1.7%
*-commutative1.7%
*-un-lft-identity1.7%
add-sqr-sqrt1.4%
sqrt-unprod0.7%
sqr-neg0.7%
sqrt-unprod0.0%
add-sqr-sqrt93.5%
Applied egg-rr93.5%
expm1-def93.5%
expm1-log1p93.5%
Simplified93.5%
if -1.10000000000000008e50 < y < 1.25000000000000007e-123Initial 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%
Taylor expanded in x around inf 81.9%
mul-1-neg81.9%
distribute-frac-neg81.9%
Simplified81.9%
if 1.25000000000000007e-123 < y 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%
Taylor expanded in x around 0 67.9%
Final simplification78.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (/ (- y x) (/ x y)))))
(if (<= x -2.55e+268)
t_0
(if (<= x -9.2e+121) (/ x y) (if (<= x 1.65e+91) (/ y (+ x y)) t_0)))))
double code(double x, double y) {
double t_0 = x / ((y - x) / (x / y));
double tmp;
if (x <= -2.55e+268) {
tmp = t_0;
} else if (x <= -9.2e+121) {
tmp = x / y;
} else if (x <= 1.65e+91) {
tmp = y / (x + y);
} 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 = x / ((y - x) / (x / y))
if (x <= (-2.55d+268)) then
tmp = t_0
else if (x <= (-9.2d+121)) then
tmp = x / y
else if (x <= 1.65d+91) then
tmp = y / (x + y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / ((y - x) / (x / y));
double tmp;
if (x <= -2.55e+268) {
tmp = t_0;
} else if (x <= -9.2e+121) {
tmp = x / y;
} else if (x <= 1.65e+91) {
tmp = y / (x + y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / ((y - x) / (x / y)) tmp = 0 if x <= -2.55e+268: tmp = t_0 elif x <= -9.2e+121: tmp = x / y elif x <= 1.65e+91: tmp = y / (x + y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(Float64(y - x) / Float64(x / y))) tmp = 0.0 if (x <= -2.55e+268) tmp = t_0; elseif (x <= -9.2e+121) tmp = Float64(x / y); elseif (x <= 1.65e+91) tmp = Float64(y / Float64(x + y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / ((y - x) / (x / y)); tmp = 0.0; if (x <= -2.55e+268) tmp = t_0; elseif (x <= -9.2e+121) tmp = x / y; elseif (x <= 1.65e+91) tmp = y / (x + y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(N[(y - x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.55e+268], t$95$0, If[LessEqual[x, -9.2e+121], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.65e+91], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\frac{y - x}{\frac{x}{y}}}\\
\mathbf{if}\;x \leq -2.55 \cdot 10^{+268}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -9.2 \cdot 10^{+121}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+91}:\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.54999999999999984e268 or 1.65000000000000009e91 < x Initial 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-sqrt32.6%
fabs-sqr32.6%
rem-square-sqrt33.1%
div-sub33.1%
sub-neg33.1%
*-inverses33.1%
metadata-eval33.1%
+-commutative33.1%
Simplified33.1%
+-commutative33.1%
metadata-eval33.1%
sub-neg33.1%
*-inverses33.1%
div-sub33.1%
clear-num33.1%
associate-/r/33.1%
flip--17.2%
associate-*r/17.2%
Applied egg-rr17.2%
Taylor expanded in y around 0 17.8%
unpow217.8%
associate-/l*22.8%
associate-/r/22.8%
Simplified22.8%
associate-*l/17.8%
*-un-lft-identity17.8%
associate-*l/17.8%
frac-2neg17.8%
div-inv17.8%
associate-*l/17.8%
*-un-lft-identity17.8%
distribute-neg-frac17.8%
add-sqr-sqrt15.6%
sqrt-unprod40.2%
sqr-neg40.2%
sqrt-unprod25.0%
add-sqr-sqrt31.1%
frac-2neg31.1%
associate-*r/34.6%
distribute-neg-in34.6%
neg-mul-134.6%
add-sqr-sqrt26.8%
sqrt-unprod31.1%
sqr-neg31.1%
sqrt-unprod7.4%
add-sqr-sqrt34.3%
fma-def34.3%
Applied egg-rr34.3%
associate-*r/34.3%
*-rgt-identity34.3%
associate-/l*56.4%
fma-udef56.4%
neg-mul-156.4%
+-commutative56.4%
sub-neg56.4%
Simplified56.4%
if -2.54999999999999984e268 < x < -9.1999999999999995e121Initial 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-sqrt51.6%
fabs-sqr51.6%
rem-square-sqrt52.1%
div-sub52.1%
sub-neg52.1%
*-inverses52.1%
metadata-eval52.1%
+-commutative52.1%
Simplified52.1%
Taylor expanded in x around inf 52.9%
if -9.1999999999999995e121 < x < 1.65000000000000009e91Initial 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-sqrt12.8%
fabs-sqr12.8%
rem-square-sqrt14.2%
div-sub14.2%
sub-neg14.2%
*-inverses14.2%
metadata-eval14.2%
+-commutative14.2%
Simplified14.2%
+-commutative14.2%
metadata-eval14.2%
sub-neg14.2%
*-inverses14.2%
div-sub14.2%
clear-num14.1%
associate-/r/14.1%
flip--11.7%
associate-*r/11.1%
Applied egg-rr11.1%
Taylor expanded in y around inf 1.9%
neg-mul-11.9%
Simplified1.9%
expm1-log1p-u1.9%
expm1-udef1.7%
*-un-lft-identity1.7%
*-commutative1.7%
*-commutative1.7%
*-un-lft-identity1.7%
add-sqr-sqrt0.7%
sqrt-unprod26.1%
sqr-neg26.1%
sqrt-unprod39.1%
add-sqr-sqrt72.3%
Applied egg-rr72.3%
expm1-def72.5%
expm1-log1p72.5%
Simplified72.5%
Final simplification66.6%
(FPCore (x y)
:precision binary64
(if (<= x -5.8e+269)
(* x (/ (/ (- x) y) (+ x y)))
(if (<= x -2.9e+121)
(/ x y)
(if (<= x 5.2e+95) (/ y (+ x y)) (/ x (/ (- y x) (/ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -5.8e+269) {
tmp = x * ((-x / y) / (x + y));
} else if (x <= -2.9e+121) {
tmp = x / y;
} else if (x <= 5.2e+95) {
tmp = y / (x + y);
} else {
tmp = x / ((y - x) / (x / y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-5.8d+269)) then
tmp = x * ((-x / y) / (x + y))
else if (x <= (-2.9d+121)) then
tmp = x / y
else if (x <= 5.2d+95) then
tmp = y / (x + y)
else
tmp = x / ((y - x) / (x / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.8e+269) {
tmp = x * ((-x / y) / (x + y));
} else if (x <= -2.9e+121) {
tmp = x / y;
} else if (x <= 5.2e+95) {
tmp = y / (x + y);
} else {
tmp = x / ((y - x) / (x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.8e+269: tmp = x * ((-x / y) / (x + y)) elif x <= -2.9e+121: tmp = x / y elif x <= 5.2e+95: tmp = y / (x + y) else: tmp = x / ((y - x) / (x / y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -5.8e+269) tmp = Float64(x * Float64(Float64(Float64(-x) / y) / Float64(x + y))); elseif (x <= -2.9e+121) tmp = Float64(x / y); elseif (x <= 5.2e+95) tmp = Float64(y / Float64(x + y)); else tmp = Float64(x / Float64(Float64(y - x) / Float64(x / y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.8e+269) tmp = x * ((-x / y) / (x + y)); elseif (x <= -2.9e+121) tmp = x / y; elseif (x <= 5.2e+95) tmp = y / (x + y); else tmp = x / ((y - x) / (x / y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.8e+269], N[(x * N[(N[((-x) / y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.9e+121], N[(x / y), $MachinePrecision], If[LessEqual[x, 5.2e+95], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(y - x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{+269}:\\
\;\;\;\;x \cdot \frac{\frac{-x}{y}}{x + y}\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{+121}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+95}:\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y - x}{\frac{x}{y}}}\\
\end{array}
\end{array}
if x < -5.80000000000000051e269Initial 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-sqrt11.1%
fabs-sqr11.1%
rem-square-sqrt11.6%
div-sub11.6%
sub-neg11.6%
*-inverses11.6%
metadata-eval11.6%
+-commutative11.6%
Simplified11.6%
+-commutative11.6%
metadata-eval11.6%
sub-neg11.6%
*-inverses11.6%
div-sub11.6%
clear-num11.6%
associate-/r/11.6%
flip--11.2%
associate-*r/11.2%
Applied egg-rr11.2%
Taylor expanded in y around 0 11.3%
unpow211.3%
associate-/l*11.4%
associate-/r/11.4%
Simplified11.4%
associate-*l/11.3%
*-un-lft-identity11.3%
associate-*l/11.3%
frac-2neg11.3%
distribute-frac-neg11.3%
*-commutative11.3%
div-inv11.3%
frac-2neg11.3%
add-sqr-sqrt11.1%
sqrt-unprod46.0%
sqr-neg46.0%
sqrt-unprod35.7%
add-sqr-sqrt35.7%
distribute-neg-frac35.7%
associate-*l/46.3%
frac-2neg46.3%
associate-/l*88.9%
associate-/r/88.5%
Applied egg-rr88.5%
distribute-rgt-neg-in88.5%
Simplified88.5%
if -5.80000000000000051e269 < x < -2.8999999999999999e121Initial 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-sqrt51.6%
fabs-sqr51.6%
rem-square-sqrt52.1%
div-sub52.1%
sub-neg52.1%
*-inverses52.1%
metadata-eval52.1%
+-commutative52.1%
Simplified52.1%
Taylor expanded in x around inf 52.9%
if -2.8999999999999999e121 < x < 5.19999999999999981e95Initial 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-sqrt12.8%
fabs-sqr12.8%
rem-square-sqrt14.2%
div-sub14.2%
sub-neg14.2%
*-inverses14.2%
metadata-eval14.2%
+-commutative14.2%
Simplified14.2%
+-commutative14.2%
metadata-eval14.2%
sub-neg14.2%
*-inverses14.2%
div-sub14.2%
clear-num14.1%
associate-/r/14.1%
flip--11.7%
associate-*r/11.1%
Applied egg-rr11.1%
Taylor expanded in y around inf 1.9%
neg-mul-11.9%
Simplified1.9%
expm1-log1p-u1.9%
expm1-udef1.7%
*-un-lft-identity1.7%
*-commutative1.7%
*-commutative1.7%
*-un-lft-identity1.7%
add-sqr-sqrt0.7%
sqrt-unprod26.1%
sqr-neg26.1%
sqrt-unprod39.1%
add-sqr-sqrt72.3%
Applied egg-rr72.3%
expm1-def72.5%
expm1-log1p72.5%
Simplified72.5%
if 5.19999999999999981e95 < x Initial 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-sqrt36.8%
fabs-sqr36.8%
rem-square-sqrt37.3%
div-sub37.3%
sub-neg37.3%
*-inverses37.3%
metadata-eval37.3%
+-commutative37.3%
Simplified37.3%
+-commutative37.3%
metadata-eval37.3%
sub-neg37.3%
*-inverses37.3%
div-sub37.3%
clear-num37.3%
associate-/r/37.3%
flip--18.4%
associate-*r/18.3%
Applied egg-rr18.3%
Taylor expanded in y around 0 19.1%
unpow219.1%
associate-/l*25.0%
associate-/r/25.1%
Simplified25.1%
associate-*l/19.1%
*-un-lft-identity19.1%
associate-*l/19.1%
frac-2neg19.1%
div-inv19.1%
associate-*l/19.1%
*-un-lft-identity19.1%
distribute-neg-frac19.1%
add-sqr-sqrt18.6%
sqrt-unprod48.1%
sqr-neg48.1%
sqrt-unprod29.9%
add-sqr-sqrt30.1%
frac-2neg30.1%
associate-*r/32.4%
distribute-neg-in32.4%
neg-mul-132.4%
add-sqr-sqrt32.0%
sqrt-unprod30.3%
sqr-neg30.3%
sqrt-unprod0.5%
add-sqr-sqrt32.7%
fma-def32.7%
Applied egg-rr32.7%
associate-*r/32.7%
*-rgt-identity32.7%
associate-/l*50.7%
fma-udef50.7%
neg-mul-150.7%
+-commutative50.7%
sub-neg50.7%
Simplified50.7%
Final simplification66.8%
(FPCore (x y) :precision binary64 (if (<= x -3.6e+121) (/ x y) (if (<= x 2.7e+141) (/ y (+ x y)) (+ (/ x y) -1.0))))
double code(double x, double y) {
double tmp;
if (x <= -3.6e+121) {
tmp = x / y;
} else if (x <= 2.7e+141) {
tmp = y / (x + y);
} else {
tmp = (x / y) + -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-3.6d+121)) then
tmp = x / y
else if (x <= 2.7d+141) then
tmp = y / (x + y)
else
tmp = (x / y) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.6e+121) {
tmp = x / y;
} else if (x <= 2.7e+141) {
tmp = y / (x + y);
} else {
tmp = (x / y) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.6e+121: tmp = x / y elif x <= 2.7e+141: tmp = y / (x + y) else: tmp = (x / y) + -1.0 return tmp
function code(x, y) tmp = 0.0 if (x <= -3.6e+121) tmp = Float64(x / y); elseif (x <= 2.7e+141) tmp = Float64(y / Float64(x + y)); else tmp = Float64(Float64(x / y) + -1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.6e+121) tmp = x / y; elseif (x <= 2.7e+141) tmp = y / (x + y); else tmp = (x / y) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.6e+121], N[(x / y), $MachinePrecision], If[LessEqual[x, 2.7e+141], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{+121}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+141}:\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + -1\\
\end{array}
\end{array}
if x < -3.59999999999999981e121Initial 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-sqrt42.5%
fabs-sqr42.5%
rem-square-sqrt43.0%
div-sub43.0%
sub-neg43.0%
*-inverses43.0%
metadata-eval43.0%
+-commutative43.0%
Simplified43.0%
Taylor expanded in x around inf 43.6%
if -3.59999999999999981e121 < x < 2.7000000000000001e141Initial 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-sqrt13.6%
fabs-sqr13.6%
rem-square-sqrt14.9%
div-sub14.9%
sub-neg14.9%
*-inverses14.9%
metadata-eval14.9%
+-commutative14.9%
Simplified14.9%
+-commutative14.9%
metadata-eval14.9%
sub-neg14.9%
*-inverses14.9%
div-sub14.9%
clear-num14.8%
associate-/r/14.8%
flip--12.5%
associate-*r/12.0%
Applied egg-rr12.0%
Taylor expanded in y around inf 1.9%
neg-mul-11.9%
Simplified1.9%
expm1-log1p-u1.9%
expm1-udef1.8%
*-un-lft-identity1.8%
*-commutative1.8%
*-commutative1.8%
*-un-lft-identity1.8%
add-sqr-sqrt0.7%
sqrt-unprod24.4%
sqr-neg24.4%
sqrt-unprod37.5%
add-sqr-sqrt70.0%
Applied egg-rr70.0%
expm1-def70.1%
expm1-log1p70.1%
Simplified70.1%
if 2.7000000000000001e141 < x Initial 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-sqrt42.1%
fabs-sqr42.1%
rem-square-sqrt42.6%
div-sub42.6%
sub-neg42.6%
*-inverses42.6%
metadata-eval42.6%
+-commutative42.6%
Simplified42.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%
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-sqrt21.8%
fabs-sqr21.8%
rem-square-sqrt22.8%
div-sub22.8%
sub-neg22.8%
*-inverses22.8%
metadata-eval22.8%
+-commutative22.8%
Simplified22.8%
Taylor expanded in x around inf 23.4%
Final simplification23.4%
(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%
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-sqrt21.8%
fabs-sqr21.8%
rem-square-sqrt22.8%
div-sub22.8%
sub-neg22.8%
*-inverses22.8%
metadata-eval22.8%
+-commutative22.8%
Simplified22.8%
Taylor expanded in x around 0 1.3%
Final simplification1.3%
herbie shell --seed 2023274
(FPCore (x y)
:name "Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5"
:precision binary64
(/ (fabs (- x y)) (fabs y)))