How do I ensure that my function below is well conditioned as $s$ approaches $\infty$? The problem I get is that for large $s$ the function returns an indeterminate form $\frac{0}{0}$. I would otherwise have expected the function to increase monotonically from 0 to 1 as $s$  approaches $\infty$. \begin{align}f(s) = \frac{x_s^2+\sqrt{1-x_s^2}-1}{\sqrt{x_s^2(x_s(\sqrt{1-x_s^2}-1))^2+(x_s^2+\sqrt{1-x_s^2}-1)^2}}\end{align}\begin{align}x_s = e^{-s}\end{align}import numpy as npdef func(s):    xs = np.exp(-1*s)    num = xs**2+np.sqrt(1-xs**2)-1    den = np.sqrt(xs**2*(xs*(np.sqrt(1-xs**2)-1))**2+(xs**2+np.sqrt(1-xs**2)-1)**2)     return num/dens = np.linspace(0,20, 1000)plot(s, func(s))
How to deal with indeterminate function limit?
python;numerical analysis
The function is really smooth as $s \rightarrow \infty$. This allows you to do the following strategy:For $s\le s_0$, do the usual evaluation, i.e., return $f(s)$.For $s>s_0$, define the function $g(h)=f(1/h)$, do a Taylor expansion around $h=0$ (i.e., around $s=\infty$) and return $\bar g(h)|_{h=1/s}$ where $\bar g$ contains the first few Taylor terms of the expansion of $g(h)$. In the evaluation of these Taylor terms, you need to compute the $k$th derivatives $g^{(k)}(0)$ which will involve factors $\frac 00$ for which you will have to apply l'Hopital's rule.