Rational Functions and Asymptotes
A rational function divides one polynomial by another, and where the denominator vanishes the graph splits around invisible walls called asymptotes. Rates and normalisations all behave this way near zero.
Why Does This Exist?
Division by a variable creates the wildest well-behaved graphs in math. Far from zero the function is calm; near the denominator's zeros it explodes, and the explosion follows strict rules. Rates (distance over time), densities (mass over volume), normalisations (value over total) and rational activations all hide such walls, and reading them means knowing which side you approach from.
Asymptotes are the walls and the ceilings: vertical lines the graph can approach but never touch, horizontal lines it settles toward at the extremes. This page covers finding both and telling walls from removable holes. Keeping arithmetic safe near them is numerical stability; slopes near them belong to derivatives and partial derivatives.
The one idea you need first. A fraction is zero only with a zero numerator, and undefined with a zero denominator. So the numerator's zeros are crossings, the denominator's zeros are walls or holes. One sentence, and the whole topic follows.
Think of It Like This
A cliff with a fence and a plateau beyond
A trail runs toward a cliff edge fenced at exactly . From the left the ground falls away without limit; from the right it rises without limit. The fence itself is never part of the trail. Far past the cliff in either direction, the trail levels onto a plateau at height 1, closer with every step, never quite arriving.
The fence is the vertical asymptote, the plateau the horizontal one. Hikers care which side they approach from because the two sides do opposite things. And a painted line on the ground, a removable hole, looks like a fence but lifts away: the trail continues underneath.
Where it stops: cliffs end at the bottom, while asymptotes never land. The analogy shows the approach behaviour; the arithmetic below shows the unlimited part.
How It Actually Works
A rational function is with polynomials and . The domain excludes every with . At such a point: if the factor cancels with the numerator, the graph has a hole (a single missing point); otherwise it has a vertical asymptote, diving to one infinity on each side. Horizontal behaviour comes from degrees: if the graph settles to ; if equal, to the ratio of leading coefficients; if leads by exactly one, to a slant line.
Worked example: (x plus 1) over (x minus 2)
Function: . Denominator zero at , numerator nonzero there (), so a vertical asymptote, not a hole.
Sample it. . . . Near the wall: , diving; , soaring. Same wall, opposite infinities.
Horizontal: both degrees 1, leading ratio , so settles toward . Check: , , closing in from above. The diagram above shows both branches split by the wall at 2.
Code
def f(x: float) -> float: return (x + 1.0) / (x - 2.0)
for x in [0.0, 1.9, 2.1, 3.0, 4.0, 7.0]: print(x, f(x))# -> 0.0 -0.5# -> 1.9 -28.999999999999996# -> 2.1 31.000000000000004# -> 3.0 4.0# -> 4.0 2.5# -> 7.0 1.3333333333333333The near-wall values against calm values elsewhere are the signature: nothing between and was sampled because the function has no values worth sampling at the wall itself. Note the floating-point dust on and : exact in math, approximate in floats.
Watch Out For
Calling a hole an asymptote
simplifies to everywhere except , where the original is undefined: a hole at , not a wall. Code that "evaluates the asymptote" by sampling nearby concludes infinity, while the simplified form says nearly 4. The limit exists; the point does not.
Factor first, cancel second, and mark cancelled points as holes explicitly. Limits and values are different questions with different answers.
Evaluating exactly at the wall in code
f(2.0) raises ZeroDivisionError in plain Python and returns inf in NumPy, and a grid search that steps onto the pole injects either a crash or an infinity into the results. The symptom is one inf row in a results table with every neighbour sane.
Mask pole inputs before evaluating, or evaluate limits from documented sides. Never let a parameter grid include a known denominator zero.
The Quick Version
- Rational means polynomial over polynomial; denominator zeros leave the domain.
- Uncancelled zeros are vertical asymptotes with opposite infinities per side; cancelled ones are holes.
- Equal degrees settle to the leading-coefficient ratio; flattens toward 1.
- Near the example hits and ; far away it behaves calmly.
- Factor before judging; mask poles before evaluating grids.