TExcelTAD
Home › Calculus in Depth › Summary of Curve Sketching

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 ff defined? zero denominators, even roots of negatives, logs of non-positives
2. Intercepts f(0)f(0)? Solutions of f(x)=0f(x) = 0? algebra, sp.solve
3. Symmetry even (f(−x)=f(x)f(-x) = f(x)), odd (f(−x)=−f(x)f(-x) = -f(x)), periodic? substitution
4. Asymptotes vertical, horizontal, slant limits at infinity, one-sided limits
5. Monotonicity sign of f′f' I/D Test
6. Extrema critical numbers, classified First or Second Derivative Test
7. Concavity sign of f′′f'', inflection points Concavity Test
8. Sketch put the features together, then plot to confirm Matplotlib

Slant asymptotes

If lim⁡x→±∞[f(x)−(mx+b)]=0\lim_{x \to \pm\infty} \left[f(x) - (mx + b)\right] = 0 with m≠0m \ne 0, the line y=mx+by = mx + b 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:

x2+5x−2=x+2+9x−2and 9x−2→0 as x→±∞\frac{x^2 + 5}{x - 2} = x + 2 + \frac{9}{x - 2} \qquad \text{and } \frac{9}{x - 2} \to 0 \text{ as } x \to \pm\infty

so y=x+2y = x + 2 is the slant asymptote. In general m=lim⁡f(x)/xm = \lim f(x)/x and b=lim⁡(f(x)−mx)b = \lim (f(x) - mx), which also works for non-rational functions.

A full example: f(x)=x2+5x−2f(x) = \frac{x^2 + 5}{x - 2}

python · try it yourself
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 (x2+5>0x^2 + 5 > 0); y-intercept −5/2-5/2. No symmetry.
  • Vertical asymptote x=2x = 2: f→−∞f \to -\infty from the left, +∞+\infty from the right. Slant asymptote y=x+2y = x + 2 in both directions.
  • f′=(x−5)(x+1)(x−2)2f' = \frac{(x - 5)(x + 1)}{(x - 2)^2}: positive for x<−1x < -1, negative on (−1,2)(-1, 2) and (2,5)(2, 5), positive for x>5x > 5.
  • Local maximum f(−1)=−2f(-1) = -2, local minimum f(5)=10f(5) = 10. Strange but true: the local maximum value is lower than the local minimum value, because the two branches are separated by the asymptote.
  • f′′=18(x−2)3f'' = \frac{18}{(x - 2)^3}: concave down for x<2x < 2, up for x>2x > 2. No inflection point, since x=2x = 2 is not in the domain.

Confirm with a plot

python · try it yourself
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

g(x)=xe−x2/2g(x) = x e^{-x^2/2} is odd, defined everywhere, and tends to 0 at ±∞\pm\infty (exponentials beat powers). g′(x)=(1−x2)e−x2/2g'(x) = (1 - x^2)e^{-x^2/2} gives a maximum at x=1x = 1 and a minimum at x=−1x = -1; g′′(x)=x(x2−3)e−x2/2g''(x) = x(x^2 - 3)e^{-x^2/2} gives inflection points at 0 and ±3\pm\sqrt{3}. Since g=−ddxe−x2/2g = -\frac{d}{dx} e^{-x^2/2}, it is (minus) the derivative of the bell curve, the "derivative of Gaussian" filter that image-processing code uses to detect edges.

python · try it yourself
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 [−10,10][-10, 10].
  • Asymptotic behaviour of algorithms. "Slant asymptote" thinking is how you read benchmark curves: a cost of n2n−2\frac{n^2}{n - 2} behaves like n+2n + 2 for large nn.
  • Activation functions. Sketching ReLU, GELU, tanh and xe−x2/2x e^{-x^2/2} with this checklist explains their saturation (horizontal asymptotes), and where gradients vanish (f′→0f' \to 0).

Exercises

Exercise 1: Asymptotes only

Find all asymptotes of f(x)=3x2−xx2−4f(x) = \frac{3x^2 - x}{x^2 - 4}.

Answer

Vertical x=2x = 2 and x=−2x = -2; horizontal y=3y = 3.

Solution

The denominator is 0 at x=±2x = \pm 2, 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, 3/1=33/1 = 3.

Exercise 2: A slant asymptote

Find the slant asymptote of f(x)=2x2+3x−1x+1f(x) = \frac{2x^2 + 3x - 1}{x + 1}.

Answer

y=2x+1y = 2x + 1.

Solution
2x2+3x−1=(x+1)(2x+1)−2⇒f(x)=2x+1−2x+12x^2 + 3x - 1 = (x + 1)(2x + 1) - 2 \quad \Rightarrow \quad f(x) = 2x + 1 - \frac{2}{x + 1}
python · try it yourself
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 h(x)=x4−2x2h(x) = x^4 - 2x^2, give symmetry, extrema and inflection points.

Answer

Even; local max h(0)=0h(0) = 0, minima h(±1)=−1h(\pm 1) = -1; inflection points at x=±1/3x = \pm 1/\sqrt{3}, where h=−5/9h = -5/9.

Solution
h(−x)=h(x): evenh′=4x3−4x=4x(x−1)(x+1): zeros 0,±1; signs −+−+⇒min, max, minh′′=12x2−4=0⇒x=±1/3;h(1/3)=19−23=−59\begin{aligned} &h(-x) = h(x)\text{: even} \\ &h' = 4x^3 - 4x = 4x(x - 1)(x + 1)\text{: zeros } 0, \pm 1;\ \text{signs } - + - + \Rightarrow \text{min, max, min} \\ &h'' = 12x^2 - 4 = 0 \Rightarrow x = \pm 1/\sqrt{3}; \quad h(1/\sqrt{3}) = \tfrac{1}{9} - \tfrac{2}{3} = -\tfrac{5}{9} \end{aligned}

Exercise 4: Non-rational slant asymptote

Find the slant asymptote of k(x)=x2+4xk(x) = \sqrt{x^2 + 4x} as x→+∞x \to +\infty.

Answer

y=x+2y = x + 2.

Solution
m=lim⁡x2+4xx=lim⁡1+4/x=1b=lim⁡(x2+4x−x)=lim⁡4xx2+4x+x=42=2\begin{aligned} m &= \lim \frac{\sqrt{x^2 + 4x}}{x} = \lim \sqrt{1 + 4/x} = 1 \\ b &= \lim \left(\sqrt{x^2 + 4x} - x\right) = \lim \frac{4x}{\sqrt{x^2 + 4x} + x} = \frac{4}{2} = 2 \end{aligned}
python · try it yourself
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…

  1. the degrees are equal
  2. the denominator has a double root
  3. the numerator's degree is exactly one more than the denominator's
  4. the numerator's degree is smaller

For f(x)=x2+5x−2f(x) = \frac{x^2 + 5}{x - 2}, why is there no inflection point even though f′′f'' changes sign at x=2x = 2?

  1. x=2x = 2 is not in the domain of ff
  2. f′′f'' is never zero
  3. ff is odd
  4. The concavity does not change

How do you find bb in a slant asymptote y=mx+by = mx + b?

  1. b=f(0)b = f(0)
  2. b=lim⁡f(x)/xb = \lim f(x)/x
  3. b=lim⁡f′(x)b = \lim f'(x)
  4. b=lim⁡(f(x)−mx)b = \lim (f(x) - mx)