CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
calculuslab

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: calculuslab/Calculus_Lab
Path: blob/main/141-Labs/Lab 04 - Limits, Infinity, and Asymptotes.ipynb
Views: 491
Kernel: SageMath 9.2

Lab 04 - Limits, Inifinity, and Asymptotes

Overview

The concept of a limit is the central idea in Calculus. Limits involving infininity are important because they are closely related to asymptotes. While asymptotes for functions are sometimes easy to identify from a graph, the actual definition of asymptotes is in terms of limits. There are several types of asymptotes and the two simplest are:

ParseError: KaTeX parse error: Undefined control sequence: \hfill at position 31: …l|l|l|} \hline \̲h̲f̲i̲l̲l̲ ̲\textbf{Asympto…

In this lab, we will use SageMath to evaluate the limit of a function at a point and we will use limits to identify asymptotes.

Important SageMath Commands Introduced in this Lab

ParseError: KaTeX parse error: Undefined control sequence: \hfill at position 32: …|l|l|} \hline \̲h̲f̲i̲l̲l̲ ̲\textbf{Command…
Sections 2.1, 2.2, 2.4, and 2.6

Example 1

Use SageMath to evaluate limh0f(x+h)f(x)h\displaystyle \lim_{h\rightarrow 0} \dfrac{f(x+h) - f(x)}{h} for the functions below. Don't forget that you must make hh a variable before you can use it as one.

  1. f(x)=x2f(x) = x^2

  2. f(x)=xf(x) = \sqrt{x}

  3. f(x)=1xf(x) = \frac{1}{x}

  4. f(x)=sin(x)f(x) = \sin(x)

  5. f(x)=exf(x) = e^x (Depending on your version of SageMath, you may need to add the line assume(x, ’noninteger’)\textbf{assume(x, 'noninteger')} in order for SageMath to compute this limit)

Example 2

Let f(x)=xxf(x) = \frac{|x|}{x} and use SageMath to calculate the following limits. You can use abs(xx) command for the absolute value function.

  1. limx5f(x)\displaystyle \lim_{x\rightarrow 5} f(x)

  2. limxf(x)\displaystyle \lim_{x\rightarrow -\infty} f(x)

  3. limx0f(x)\displaystyle \lim_{x\rightarrow 0} f(x)

  4. limx0+f(x)\displaystyle \lim_{x\rightarrow 0^+} f(x)

  5. limx0f(x)\displaystyle \lim_{x\rightarrow 0^-} f(x)

Based off of your results, what do you think the graph of f(x)f(x) looks like? Check your guess below.

Example 3

Now, we will use SageMath to identify the asymptotes of a function. Let f(x)=5+2x2x21f(x) = \dfrac{5 + 2x^2}{x^2 - 1}. Recall that the values which make the denominator of a rational function equal zero are all of the possible places for a vertical asymptote. We can find all xx-values which make the denominator of f(x)f(x) equal zero by hand or we can use SageMath to help us. If we use SageMath, we need to use the functions expression.denominator(normalize=False)\textit{expression}\textbf{.denominator(normalize=False)} and solve(equation,variable)\textbf{solve}(\textit{equation}, \textit{variable}). When creating an equation in SageMath, you must use ==\textbf{==} in place of =\textbf{=}.

def f(x): return (5 + 2*x^2)/(x^2-1) solve(f(x).denominator(normalize=False) == 0,x)

SageMath either returned [1,1][1, -1] or [][ ]. We know that the answers to the equation should be x=1,1x = 1, -1, so why did SageMath return [][ ] which means that there isn't an answer? This is because earlier in Example 1, part 5 we added the condition that xx is a noninteger in order to compute the limit. Therefore, SageMath still thinks that SageMath is a noninteger and is not allowed to be 11 or 1-1. We can remove the assumption on xx by using the forget()\textbf{forget()} command.

forget() solve(f(x).denominator(normalize=False) == 0,x)

SageMath tells us that the only xx-values which make the denomiator equal zero are x=1x = -1 and x=1x = 1. Therefore, the only possible vertical asymptotes are at x=1x=-1 and x=1x=1. We can use SageMath to calculate the one-sided limits of f(x)f(x) at these xx-values to determine if either of them are actually vertical asymptotes.

limit(f(x), x=-1, dir='+')
limit(f(x), x=-1, dir='-')

Since at least one of the one-sided llimits at x=1x = -1 was either \infty or -\infty, we have that the graph of f(x)f(x) has a vertical asymptote at x=1x = -1.

Check the one sided limits at x=1x = 1 to see if there is also a vertical asymptote at x=1x=1.

Therefore, the graph of f(x)f(x) has vertical asymptotes at both x=1x=-1 and x=1x=1.

To find the horizontal asymptotes, we calculate the limit of f(x)f(x) as xx approaches \infty and -\infty.

limit(f(x), x=infinity)
limit(f(x), x=-infinity)

Both limits tell us that y=2y = 2 is a horizontal asymptote. Therefore, we have that y=2y = 2 is our only horizontal asymptote.

We can check our conclusion by plotting the function in an appropriate viewing window which will show all of the asymptotes. The option ParseError: KaTeX parse error: Expected 'EOF', got '_' at position 15: \textbf{detect_̲poles = 'show'} will plot the vertical asymptote(s) on the graph. We can also plot the horizontal asymptote(s) by inclding the yy-value(s) in our plot.

Note:\textbf{Note:} Sometimes, ParseError: KaTeX parse error: Expected 'EOF', got '_' at position 15: \textbf{detect_̲poles = 'show'} does not plot the vertical asymptote.

plot([f(x), 2], xmin=-10, xmax=10, ymin=-10, ymax=10, color = ['blue', 'gray'], linestyle = ['-', '--'], detect_poles = 'show')

Example 4

Repeat Example 3 with the following functions:

  1. f(x)=3x+2(x+2)2f(x) = \dfrac{3x + 2}{(x+2)^2}

  2. f(x)=9x2+42x+1f(x) = \dfrac{\sqrt{9x^2 + 4} - 2}{x + 1}

  3. f(x)=(x21)4x2+1x32x2x+2f(x) = \dfrac{(x^2 - 1)\sqrt{4x^2 + 1}}{x^3 - 2x^2 - x + 2}

  4. f(x)=sin(x)xf(x) = \dfrac{\sin(x)}{x}