Summary of Curve Sketching
A plotting library draws whatever window you give it, and a badly chosen window hides asymptotes, wiggles and extrema. Calculus tells you in advance where the interesting features are. This lesson collects everything from the previous lessons into one checklist, adds slant asymptotes, and works a complete example, with SymPy doing the algebra and Matplotlib confirming the result.
The checklist
| Step | Question | Tools |
|---|---|---|
| 1. Domain | Where is defined? | zero denominators, even roots of negatives, logs of non-positives |
| 2. Intercepts | ? Solutions of ? | algebra, sp.solve |
| 3. Symmetry | even (), odd (), periodic? | substitution |
| 4. Asymptotes | vertical, horizontal, slant | limits at infinity, one-sided limits |
| 5. Monotonicity | sign of | I/D Test |
| 6. Extrema | critical numbers, classified | First or Second Derivative Test |
| 7. Concavity | sign of , inflection points | Concavity Test |
| 8. Sketch | put the features together, then plot to confirm | Matplotlib |
Slant asymptotes
If with , the line is a slant (oblique) asymptote. A rational function has one exactly when the numerator's degree is one more than the denominator's, and polynomial long division finds it:
so is the slant asymptote. In general and , which also works for non-rational functions.
A full example:
import sympy as sp
x = sp.symbols('x', real=True)
f = (x**2 + 5) / (x - 2)
print("1. domain: x != 2")
print("2. f(0) =", f.subs(x, 0), " real roots:", sp.solve(x**2 + 5, x))
print("4. vertical at x=2: left", sp.limit(f, x, 2, '-'), " right", sp.limit(f, x, 2, '+'))
m = sp.limit(f / x, x, sp.oo); b = sp.limit(f - m * x, x, sp.oo)
print(" slant asymptote: y =", m * x + b, " (division:", sp.apart(f), ")")
f1 = sp.factor(sp.diff(f, x)); f2 = sp.factor(sp.diff(f, x, 2))
print("5. f' =", f1, " critical:", sp.solve(f1, x))
for c in sp.solve(f1, x):
print(f"6. f({c}) = {f.subs(x, c)}, f''({c}) = {f2.subs(x, c)}")
print("7. f'' =", f2)1. domain: x != 2
2. f(0) = -5/2 real roots: []
4. vertical at x=2: left -oo right oo
slant asymptote: y = x + 2 (division: x + 2 + 9/(x - 2) )
5. f' = (x - 5)*(x + 1)/(x - 2)**2 critical: [-1, 5]
6. f(-1) = -2, f''(-1) = -2/3
6. f(5) = 10, f''(5) = 2/3
7. f'' = 18/(x - 2)**3
Reading off the results:
- No x-intercepts (); y-intercept . No symmetry.
- Vertical asymptote : from the left, from the right. Slant asymptote in both directions.
- : positive for , negative on and , positive for .
- Local maximum , local minimum . Strange but true: the local maximum value is lower than the local minimum value, because the two branches are separated by the asymptote.
- : concave down for , up for . No inflection point, since is not in the domain.
Confirm with a plot
import numpy as np
import matplotlib.pyplot as plt
f = lambda x: (x**2 + 5) / (x - 2)
plt.figure(figsize=(6, 4))
for xs in (np.linspace(-8, 1.85, 300), np.linspace(2.15, 12, 300)):
plt.plot(xs, f(xs), color="C0")
xs = np.linspace(-8, 12, 2)
plt.plot(xs, xs + 2, "--", color="C1", label="slant asymptote y = x + 2")
plt.axvline(2, ls=":", color="gray", label="vertical asymptote x = 2")
plt.scatter([-1, 5], [-2, 10], color="C3", zorder=3, label="local max (−1, −2), local min (5, 10)")
plt.ylim(-25, 30); plt.legend(fontsize=8); plt.grid(alpha=0.3)
print("plotted both branches, both asymptotes and the two extrema")plotted both branches, both asymptotes and the two extrema
Plotting the two branches separately avoids the false vertical line a plotter draws when it connects the last point left of 2 to the first point right of it.
A transcendental example
is odd, defined everywhere, and tends to 0 at (exponentials beat powers). gives a maximum at and a minimum at ; gives inflection points at 0 and . Since , it is (minus) the derivative of the bell curve, the "derivative of Gaussian" filter that image-processing code uses to detect edges.
import sympy as sp
x = sp.symbols('x', real=True)
g = x * sp.exp(-x**2 / 2)
print("g' zeros:", sp.solve(sp.diff(g, x), x))
print("g'' zeros:", sp.solve(sp.diff(g, x, 2), x))
print("max value g(1) =", sp.N(g.subs(x, 1), 6))g' zeros: [-1, 1]
g'' zeros: [0, -sqrt(3), sqrt(3)]
max value g(1) = 0.606531
In software
- Auto-scaling axes. A good chart library chooses its view from the data. A function plotter that knows the critical points and asymptotes of an expression can choose a window that contains every feature instead of a fixed .
- Asymptotic behaviour of algorithms. "Slant asymptote" thinking is how you read benchmark curves: a cost of behaves like for large .
- Activation functions. Sketching ReLU, GELU, tanh and with this checklist explains their saturation (horizontal asymptotes), and where gradients vanish ().
Exercises
Exercise 1: Asymptotes only
Find all asymptotes of .
Answer
Vertical and ; horizontal .
Solution
The denominator is 0 at , where the numerator is 10 and 14, not 0, so both are vertical asymptotes. Equal degrees: the horizontal asymptote is the ratio of leading coefficients, .
Exercise 2: A slant asymptote
Find the slant asymptote of .
Answer
.
Solution
import sympy as sp
x = sp.symbols('x')
print(sp.apart((2*x**2 + 3*x - 1) / (x + 1)))2*x + 1 - 2/(x + 1)
Exercise 3: Full sketch data
For , give symmetry, extrema and inflection points.
Answer
Even; local max , minima ; inflection points at , where .
Solution
Exercise 4: Non-rational slant asymptote
Find the slant asymptote of as .
Answer
.
Solution
import sympy as sp
x = sp.symbols('x', positive=True)
k = sp.sqrt(x**2 + 4*x)
print(sp.limit(k / x, x, sp.oo), sp.limit(k - x, x, sp.oo))1 2
Test yourself
A rational function has a slant asymptote when…
- the degrees are equal
- the denominator has a double root
- the numerator's degree is exactly one more than the denominator's
- the numerator's degree is smaller
For , why is there no inflection point even though changes sign at ?
- is not in the domain of
- is never zero
- is odd
- The concavity does not change
How do you find in a slant asymptote ?