Limits
Given two functions f,g: \mathbb R\to \mathbb R, I’m assuming you are already familiar with how to compute \displaystyle \lim_{x\to +\infty}\frac{f(x)}{g(x)}. For instance, whether the limit exists or the indeterminate forms \frac{0}{0}, \frac{\infty}{\infty}. This theory bit only recalls de l’Hôpital’s rule, and give some tools to compute limits in a Computer Algebra System.
De l’Hôpital’s rule
For differentiable functions f,g: [a,+\infty)\to \mathbb R, if
- \displaystyle\lim_{x\to+\infty} f(x)=\lim_{x\to+\infty} g(x)=0 or \pm \infty,
- g'(x)\neq 0 in the whole interval [a,+\infty), and
- \displaystyle\lim_{x\to+\infty}\frac{f'(x)}{g'(x)} exists
then \lim_{x\to+\infty}\frac{f(x)}{g(x)}=\lim_{x\to+\infty}\frac{f'(x)}{g'(x)}\ .
This is not the most general statement of De l’Hôpital’s rule, but it is the statement we will use in computing the asymptotic behaviour of functions.
Limits in SageMath
There are several CAS (Computer Algebra Systems) that allow to perform exact symbolic computations. Some examples are SymPy, Maxima, or Mathematica (among many others). Each has its own slightly different syntax and they are all extremely useful to automate routine calculations such as limits, derivatives, integration, and matrix operations (among a lot of other things).
In this course you need to be able to compute limits step-by-step and justify your calculations, but: you might want to use some CAS to double-check the correctness of your calculations. Treat CASs as being 90% correct, that is they might be wrong but it is quite unlikely.
For instance, we can use SageMath to compute limits as in the following example.
The following table recaps the syntax of common functions in SageMath.
Function | Representation in SageMath |
---|---|
e^x | e^x or exp(x) |
2^x | 2^x |
\displaystyle\frac{3x^2+4x^{1/3}+2}{x+1} | (3*x^2 + 4*x^(1/3) + 2)/(x+1) |
\ln(x) | log(x) |
\log_2(x) | log(x,2) |
\sqrt{x} | sqrt(x) |
x! | factorial(x) |
Do not use n as the name of your variable, since this would tell SageMath to treat it as an integer. In our context, this would only create problems. Use x instead.
Exercise: Use SageMath to verify Stirling’s approximation, i.e. that the ratio of x! with \sqrt{x}\left(\frac{x}{e}\right)^x tends to a constant when x\to \infty.