Zero Labs
Industry News / AI

Polynomial Degree And Turning Points, Made Simple, Really Simple!!

Source · Towards AI By Kamrun Nahar

From the publisher’s feed, collected in the ZeroLabs newsroom.

Four Datasets, Identical Statistics, And One Of Them Is A DinosaurSomewhere in this building there is a curve that will show up in your exam.Two numbers, straight out of the UK driving manual.At 30 mph, a car needs 23 metres to come to a complete stop. At 60 mph, it needs 73 metres.Read those again. You doubled the speed. The distance did not double. It more than tripled.I have shown that pair of numbers to a lot of people and almost nobody guesses right the first time. They are not bad at driving. They are doing something much more human, which is looking at a column of numbers and quietly assuming a straight line, because a straight line is the only shape most of us were ever really taught to expect.That table is not a straight line. It is two different shapes stacked on top of each other. Once you can see them apart, the number stops being surprising and starts being obvious.This article is about learning to do that on purpose. Not for driving. For everything.Learn the silhouettes and you stop needing the little brass labels.There is a thing experienced birdwatchers do that looks like a party trick. A dot crosses the sky four hundred metres out and they say “kestrel” before they have visibly thought about it. They are not reading feathers. At that range there are no feathers. They are reading the silhouette, and there are only so many silhouettes.Functions are the same. There are not a thousand of them. There are about eight, and the rest are those eight wearing different clothes.The whole field guide on one page. Learn these eight silhouettes and most curves in a statistics degree stop being surprises.Two of the eight, the exponential and the logarithm, are big enough that they get their own articles later. Everything else lives here.Right, one boring thing first, because nobody ever says it plainlyA function is a machine with one slot and one chute.You push something in. Exactly one thing comes out. That is the whole rule, and the important half is exactly one. A vending machine that sometimes gives you a chocolate bar and sometimes gives you two chocolate bars is a delightful machine and a terrible function.One thing in, exactly one thing out. The moment a machine gives you two, it stops being a function and starts being an incident.Three words you need, and then I will stop.The domain is the list of things the machine will accept. Some machines refuse certain inputs, and refusing is not a bug, it is part of the design. A coefficient is just a number sitting in front of an x, doing the multiplying. And the degree of a formula is the biggest power of x in it. `x³ − 4x + 7` has degree three, because three is the largest exponent anywhere in it.That is genuinely all the vocabulary you need for the rest of this. Everything else I will explain as it turns up.Back to the car, because the answer is goodHere is that driving table drawn out.Reaction time is the blue block and it grows in a straight line. Braking is the orange block and it does not. Two shapes, one table.Stopping distance is two things added together.The first is thinking distance, which is how far you travel while your brain is still processing that a child has stepped off the pavement. Your reaction time is roughly constant no matter how fast you are going, so this part scales in a perfectly straight line. It works out at about 0.3 metres for every mph. At 20 mph that is 6 metres. At 70 mph it is 21. Straight line, no drama.The second is braking distance, and this one is physics rather than psychology. Your car has to shed kinetic energy, and kinetic energy goes with the square of speed. Double the speed and you have four times as much energy to get rid of. So braking distance quadruples.Six metres of braking at 20 mph. Seventy five at 70 mph.Add a straight line to a squared curve and you get the total, which grows faster than either. That is why 30 to 60 is 23 to 73 and not 23 to 46.Nothing about that requires you to be good at maths. It requires you to notice there were two shapes in the table instead of one. That noticing is the skill this whole article is about.The line, which we can get through quickly`y = mx + b`. Two knobs, and both of them mean something you can say out loud.`b` is the height when x is zero. It is where the line crosses the vertical axis, and in the driving example it is zero, because a car parked at 0 mph travels 0 metres before stopping. `m` is the tilt. Take one step right, and `m` tells you how far up you went. For thinking distance, `m` is 0.3.Slope and intercept, plus what actually happens to the picture when you move each dial. Two numbers, infinite lines.The reason statisticians are so fond of lines is not laziness. It is that fitting a line means estimating exactly two numbers, and both of them convert into a plain English sentence. “Every extra year of education is associated with 4% more income” is just `m`, wearing a suit.Flatten it out, set `m` to zero, and you get a horizontal line. That flat line is the null model, the picture of “this input tells us nothing at all about that output”. Every hypothesis test you will ever run is, underneath the notation, an argument about whether `m` is really zero.Now guess before you scrollHere is the dare. A ball is thrown. It goes up, it comes down. Sketch the path in your head.You already drew a parabola. Everybody does, because you have watched thousands of them since you were about two years old. Galileo worked out that projectiles follow this exact curve and published it in 1638, and it has not needed updating.Vertex, roots, axis of symmetry, intercept. Four separate facts, and all four are readable off three coefficients.`y = ax² + bx + c`, and each letter is visible in the picture.`a` sets the direction and the width. Positive opens up like a bowl, negative opens down like a hill, bigger means narrower. `c` is the height at zero, same job `b` had for the line. And `b` is the awkward one. On its own it means nothing much. Together with `a` it slides the whole thing sideways.The single most useful fact in this entire section is where the turn happens. The vertex sits at `x = −b / 2a`. Always. Every parabola, no exceptions, no special cases. Feed that x back into the formula and you have the height of the peak.The one-subtraction magic trickHow many times does the curve cross the horizontal axis? Twice, once, or not at all?You could solve the whole quadratic. Or you could work out `b² − 4ac`, glance at whether it is positive, zero or negative, and then stop working.Slide the parabola up and watch two roots merge into one and then disappear. That is the discriminant, animated.Positive, zero, negative. Two crossings, one touch, or a curve floating clear of the axis. One subtraction decides which.Positive means it slices through twice. Zero means it grazes the axis at exactly one point and bounces back. Negative means it never gets there at all, and the roots have run off into complex numbers.import numpy as npimport sympy as spa, b, c = 0.5, -1.0, -1.5# these three numbers are the entire quadratic, y = a x squared + b x + c.D = b ** 2 - 4 * a * c# ** means "to the power of". D is the discriminant, our crossing counter.print("discriminant", D)if D > 0: left = (-b - np.sqrt(D)) / (2 * a) right = (-b + np.sqrt(D)) / (2 * a) print("two roots at", left, right)elif D == 0: print("one root at", -b / (2 * a))else: print("no real roots, it never touches the axis")# those three branches are the three pictures above, written out.vx = -b / (2 * a)# the vertex always lives at minus b over two a. Learn this one by heart.vy = a * vx ** 2 + b * vx + c# push that x back through the formula to get the height of the turn.print("vertex at", vx, vy)print("numpy agrees", np.roots([a, b, c]))# np.roots wants the coefficients highest power first, and solves for you.x = sp.symbols("x")# sympy handles symbols instead of numbers, so it does actual algebra.expr = sp.Rational(1, 2) * x ** 2 - x - sp.Rational(3, 2)# Rational(1, 2) is an exact one half, not the float 0.5. Nothing rounds.print("sympy roots", sp.solve(sp.Eq(expr, 0), x))print("sympy vertex", sp.solve(sp.diff(expr, x), x))# diff differentiates. A vertex is where the slope goes flat, so, zero.Discriminant of `4.0`, roots at `-1.0` and `3.0`, vertex at `(1.0, -2.0)`. SymPy returns the same roots as exact integers with no floating point dust on them.Worth knowing where you will meet this again. Squared error is a parabola. When a model minimises the sum of squared residuals, it is sliding down the inside of a bowl looking for the vertex. That is not a metaphor, it is literally the same shape.Counting bendsAdd more powers, get more wobbles. There is a hard ceiling on how many, and it is the most useful polynomial fact there is.A polynomial of degree `n` bends at most `n − 1` times.Degree one is straight, degree two turns once, degree four turns three times. Count the bends and you have guessed the degree.Degree two turns once, and that turn is the vertex. Degree three makes an S. Degree four gives you the classic W. It works backwards too, which is the useful direction. See three bends in a scatter plot and you know a quadratic is never going to cut it.Out at the far edges, only one thing matters. The highest power, and its sign. Everything else gets swamped.Four cases, total. Even degree sends both tails the same way, odd degree sends them opposite ways, and the sign flips the whole picture.Even degree, both tails go the same way. Odd degree, they go opposite ways. Positive leading coefficient lifts the right tail, negative drops it. Four combinations and you are done.import numpy as npp = np.polynomial.Polynomial([5, 0, -6, 0, 1])# careful, this list runs LOWEST power first, which trips up everyone once.# it reads 5 + 0x - 6x squared + 0x cubed + 1x to the fourth.print("degree", p.degree())dp = p.deriv()# deriv gives the derivative, which is the slope at every point.crit = dp.roots()# a bend is exactly where the slope hits zero, so we solve dp = 0.real = crit[np.isclose(crit.imag, 0)].real# roots can come back complex. isclose keeps only the ones sitting on the# real line, and .real strips the leftover zero imaginary part off them.real = np.sort(real)print("bends at x =", np.round(real, 3))print("heights there", np.round(p(real), 3))print("at most", p.degree() - 1, "allowed, we found", real.size)lead = p.coef[-1]# coef[-1] is the last entry, which belongs to the highest power.even = p.degree() % 2 == 0# % is remainder. Remainder zero after dividing by two means even.print("tails go", "the same way" if even else "opposite ways")print("right tail points", "up" if lead > 0 else "down")Bends at `-1.732`, `0` and `1.732`. Three bends on a degree four polynomial, which is the maximum allowed. Tails the same way, right one up.The 1901 problem that machine learning rediscoveredHere is a story worth knowing, because the instinct behind it is one you will have.Carl Runge was trying to approximate a curve using a polynomial through evenly spaced points. The fit was not good enough. So he did the responsible, hardworking, obviously correct thing. He used more points and a higher degree.It got worse. Not slightly worse. Spectacularly worse, and worse the harder he tried.Every wrinkle perfectly tailored, and the sleeves now end somewhere near the ceiling. This is what a perfect fit looks like.The polynomial passed through every single data point exactly. In between them, and especially near the edges, it swung wildly off in both directions.Animation of polynomial interpolation degree rising from 2 to 10 through fixed data points showing Runge phenomenon oscillation growing at the edgesThe same eleven dots, fitted at degree 2, 4, 6, 8 and 10. Every extra degree fits the dots better and behaves worse.Look at the left panel. Eleven black dots, all of them hit perfectly. And near the edges the curve rockets up past 2.0 and plunges below zero, when the thing it is approximating never once leaves the range 0 to 1.The right panel misses every dot by a little. It is wrong everywhere, and it is wrong in a small, boring, predictable way.The second one is the better model, and it is not close.Every degree you add buys you one more bend, and bends outside the range of your data go somewhere unhinged very fast. Modern machine learning has a hundred names for wrestling with this. It is the same animal Runge met over a century ago, with better marketing.Quick quiz, and you will probably get it wrongTwo drivers, both doing 10,000 miles a year.Driver A trades a car that does 10 mpg for one that does 15 mpg. A modest five mile per gallon improvement.Driver B trades a car that does 25 mpg for one that does 50 mpg. That is twenty five miles per gallon, five times the improvement.Who saves more fuel?Modern fuel economy labels print gallons per 100 miles alongside mpg, and that second number exists because of exactly this problem.Driver A. Comfortably.A saves 333 gallons a year. B saves 200. The person with the tiny improvement on the terrible car beats the person with the huge improvement on the good car, and it is not remotely close.Fuel burned per 10,000 miles against mpg. The curve is steep on the left and nearly flat on the right, which is the entire explanation.This was written up properly by two researchers at Duke in 2008, and it has a name. The MPG illusion. The problem is that miles per gallon is upside down. You care about fuel burned, but the label measures distance per fuel, and flipping a quantity over turns a straight line into a curve.It mattered enough that fuel economy labels were redesigned. New car stickers now print gallons per 100 miles next to the mpg figure, precisely so people stop making this mistake.And the shape doing all that damage has a name too.Rational functions, and the walls they buildA rational function is one polynomial sitting on top of another. That single fraction bar changes everything, because division has one thing it point blank refuses to do.Closer forever, arrived never. Mathematicians named this after the Greek for "not falling together", which is the politest possible way to put it.One wall where the bottom hits zero, one ceiling out at the far ends, and a genuine crossing where the top hits zero.Take `f(x) = (x + 1) / (x − 2)`.At `x = 2` the bottom becomes zero, and the whole thing detonates. Come at 2 from the left and the value dives toward minus infinity. Come at it from the right and it rockets the other way. The graph splits clean into two branches that never meet.That is a vertical asymptote, and you find it by setting the bottom to zero and solving. One caution though. If the top is also zero at that same x, you have a hole rather than a wall. `(x² − 1) / (x − 1)` looks alarming at x = 1, but it simplifies to `x + 1` everywhere except that one missing point. A pinprick in an otherwise unremarkable line.Then there is the horizontal asymptote. Way out in both directions, `(x + 1) / (x − 2)` starts behaving like `x / x`, which is 1. So the graph drifts toward the height `y = 1` and settles there without ever landing.Four rules cover every case, and all four come from one comparison.Compare the top degree with the bottom degree. That single comparison picks which of the four endings you get.Top degree lower than the bottom, the bottom grows faster and squeezes everything toward zero. Degrees equal, both halves grow at the same rate and it settles at the ratio of the leading coefficients. Top exactly one degree taller, there is no flat ceiling at all, and long division hands you a slanted line instead. That last one is the oblique asymptote, and it is the one people forget exists.import sympy as spx = sp.symbols("x")f = (x ** 2 + 1) / (x - 1)top, bottom = sp.fraction(sp.together(f))# together forces it into one fraction, fraction splits that into two parts.walls = sp.solve(sp.Eq(bottom, 0), x)print("bottom hits zero at", walls)print("and the top there is", [top.subs(x, w) for w in walls])# subs plugs a value in. If the top is zero too, it is a hole, not a wall.dt, db = sp.degree(top, x), sp.degree(bottom, x)print("degrees", dt, "over", db)if dt print("ceiling at y = 0")elif dt == db: print("ceiling at y =", sp.LC(sp.Poly(top, x)) / sp.LC(sp.Poly(bottom, x)))elif dt == db + 1: print("slanted ceiling y =", sp.div(top, bottom)[0])else: print("no straight ceiling, it escapes along a curve")# LC means leading coefficient, the number in front of the biggest power.# div does polynomial long division and returns quotient then remainder.print("cross check with a limit", sp.limit(f, x, sp.oo))# oo is sympy for infinity, spelled with two letter o because it looks right.A wall at `x = 1`, the top is `2` there so it is a genuine wall, and a slanted ceiling at `y = x + 1`.That vertical line your software drew is a lieYour plot draws a near vertical stroke straight through the asymptote. It is not part of the function.Matplotlib sampled a point just left of the wall at minus four hundred, sampled the next one just right at plus four hundred, and joined them up like a good little dot-connector. Graphing calculators have done this since the 1980s and there is a menu setting to stop it. Your library does not know a wall is there. You have to tell it.import numpy as npwalls = np.array([1.0])x = np.linspace(-5, 6, 1600)gap = np.min(np.abs(x[:, None] - walls[None, :]), axis=1)# x[:, None] turns a row of values into a column, so this subtraction# compares every x against every wall at once. That is broadcasting.x = x[gap > 0.02]# bin any sample sitting practically on top of a wall.y = (x ** 2 + 1) / (x - 1)jump = np.abs(np.diff(y)) > 20# diff is the change from one sample to the next. A giant change means we# just teleported across a wall, which is not a real line segment.y[:-1][jump] = np.nan# nan breaks the line. Two honest branches now, instead of one fake join.A horizontal asymptote you can actually spendAsymptotes feel abstract until one shows up on an invoice.A small print shop has 60,000 a year in costs that do not care how busy it is. Rent, the press, insurance, the accountant. Then every book costs another 20 in paper and ink.Cost per book is `60,000 / n + 20`.The curve collapses fast and then stops caring. That flat line at 20 is a horizontal asymptote, and in business it has a job title. The price floor.Five hundred books and each one costs 140. A thousand and it halves to 80. Five thousand and you are down to 32.Then the curve gives up. Ten thousand books gets you 26. A hundred thousand gets you 20.60. You could print every book on Earth and never reach 20, because paper is not free and no amount of scale makes it free.Scale is brilliant right up until the moment it is finished being brilliant, and the shape tells you exactly where that moment is. Fixed costs are the part you can spread. Variable costs are the floor underneath.The square root, and a police officer with a tape measureCrash investigators can estimate how fast a car was going from the length of its skid marks. It is not guesswork. There is a formula, it holds up in court, and it is a square root.Thirty metres of skid marks on dry asphalt puts the car at roughly 45 mph before the brakes went on. Sixty metres does not mean 90 mph.Speed comes out as the square root of the skid length times a constant that depends on the road surface. On dry asphalt, thirty metres of skid puts you at about 45 mph.Now double it. Sixty metres of skid. Ninety mph?No. About 64 mph. Doubling the length only multiplies the speed by the square root of two, which is roughly 1.41. That is the square root doing its thing, and it works in the opposite direction to the squaring we saw in braking distance, because it is the same relationship read backwards.Which is exactly what a square root is.Squaring, seen in a diagonal mirror. The shaded region on the left is where the square root simply has no answer to give you.Squaring takes 3 and gives you 9. Square root takes 9 and gives you 3. Undo each other, and on paper that undoing is a reflection across the diagonal line `y = x`. That is what an inverse function is.There is a catch, and it is the reason half that picture is shaded out. Squaring sends both 3 and minus 3 to 9. When you try to walk back from 9, which one do you hand over? A function is only allowed one answer, so squaring has no inverse at all until you saw off the left half of its domain first.Three things break a domain, and they are worth learning as a set. Nothing on the bottom of a fraction can be zero. Nothing under an even root can be negative. Nothing inside a logarithm can be zero or below. Polynomials accept literally anything, which is a large part of why everyone likes them.import numpy as npimport mathdef safe(fn, v): # try the input, and report nan if the function refuses to answer. try: out = float(fn(v)) except (ValueError, ZeroDivisionError): return np.nan return out if math.isfinite(out) else np.nandef domain_gaps(fn, lo, hi, n=2001): grid = np.linspace(lo, hi, n) vals = np.array([safe(fn, g) for g in grid]) return grid[np.isnan(vals)] # hands back every x where the function had nothing to say.bad = domain_gaps(lambda v: math.sqrt(v - 2), -1, 5)# lambda is a one line function with no name, fine for throwaway rules.print("root of x minus 2 is blank from", bad.min(), "to", round(bad.max(), 2))print("round trip test", np.sqrt(np.square(-4.0)))# squaring minus four gives sixteen, and the root of sixteen gives four.# The minus sign did not survive. That is the whole problem in one line.Standard error, by the way, shrinks like one over the square root of your sample size. That root is why quadrupling your data only halves your uncertainty, and why the last stretch of any survey costs so much more than the first.Why has nobody ever been made poorer by a pay rise?Genuinely, think about it. Income tax has bands. Cross a threshold and the rate on the next slice goes up. So why does nobody ever end up worse off for earning a little more?Because somebody made a design decision, and the shape shows it.Three separate rules stitched into one creature. Where the seams line up you get a corner. Where they do not, you get a jump.A piecewise function uses different rules in different regions. Tax is piecewise linear, one straight line per band, and the bands are deliberately glued together so the ends match. No gaps, no jumps. If the pieces did not line up, earning one extra unit could genuinely cut your take home pay, and there would be riots.Absolute value is the smallest possible piecewise function. `|x|` means “the size of x, ignore the sign”, which is two rules in one coat. Negative, flip it. Otherwise, leave it alone. Weierstrass gave us those two vertical bars in 1841 and they have outlived most of that decade’s notation.A filled dot owns the point, a hollow dot does not. That single convention tells you exactly where a jump lands.The right panel has both cases. At the first boundary the pieces disagree, so the graph jumps, and the filled circle marks which value the function actually takes. At the second boundary they happen to agree, so it joins up and nobody notices anything happened. Tax brackets are the second kind, on purpose.import numpy as npx = np.linspace(-4, 6, 11)cond = [x = -1) & (x = 2]# & is elementwise and. Plain "and" does not work on arrays at all.# the brackets matter, because & binds tighter than >= does.outs = [2.0, -x, x - 4]f = np.select(cond, outs)# select walks the conditions in order and takes the first True one,# so the order you list them in is the order they win. Be deliberate.print(np.round(f, 2))Prints `[2, 2, 2, 1, 0, -1, -2, -1, 0, 1, 2]`, which is the picture exactly. Flat, then down, then up.Absolute error loss is a hinge, not a bowl, and that corner is precisely why it shrugs off outliers where squared error panics. The kink inside a ReLU in a neural network is the same shape, sawn in half.A parking meter, and then a small surprisePay and display machines do not charge by the minute. Under an hour is one price. Cross the hour and it jumps. Then nothing happens for a while, then it jumps again.Every pricing machine like this is drawing a step function, whether or not anyone involved knows the term.Six observations dropping in one at a time, each adding a jump of one sixth. The staircase builds itself.Left, a car park price list. Right, an empirical distribution function built from six data points. Structurally identical, completely different jobs.Now the surprise. That right hand panel is the empirical cumulative distribution function of six numbers, and it is the same staircase.For any value x, it answers one question. What fraction of my sample is at or below x? Six data points, so every observation contributes a jump of one sixth. Flat between them, because nothing new has arrived yet. A jump exactly where each one sits.import numpy as npsample = np.array([2, 3, 5, 6, 8, 11])srt = np.sort(sample)heights = np.arange(1, srt.size + 1) / srt.size# arange counts 1 up to 6, divided by 6 gives the six step heights.print(srt, np.round(heights, 3))def F(v): return np.mean(srt # srt # So this literally reads "the share of the sample at or below v".print("F(5) =", F(5), "and F(7) =", F(7))# F(7) equals F(6), because nothing arrived between six and eight.`F(5) = 0.5` and `F(7) = 0.667`. The staircase is flat across that stretch because there is no data there. Every discrete distribution you meet is one of these, which makes the humble parking meter better preparation for probability than most textbooks.The mistake I kept making for yearsI would look at `f(x − 2)`, decide the minus meant left, be wrong, correct myself, and then make the identical mistake three weeks later.Everything you do outside the bracket behaves. Everything you do inside it does the exact opposite of what you expect.Grey is the original every single time. Six edits, six clearly different animals, one underlying shape.Grey is the original every time. Shift up, shift right, stretch, flip. Four edits, four visibly different animals.WHAT YOU WRITE WHAT THE GRAPH DOES WHERE PEOPLE TRIP -------------------- ------------------------- ---------------------- f(x) + k slides up by k nothing, this one is kind f(x) - k slides down by k nothing f(x - h) slides RIGHT by h the sign feels backwards f(x + h) slides LEFT by h same trap, other side a * f(x), a > 1 stretches taller heights change, x does not a * f(x), 0 f(a * x), a > 1 squeezes toward the y axis also feels backwards f(a * x), 0 -f(x) flips over the x axis up becomes down f(-x) flips over the y axis left becomes rightHere is the fix that finally stuck, and it takes ten seconds instead of intuition.For `f(x − 2)` to spit out the value that `f` gives at 3, you have to feed in 5. The output that used to show up at 3 now shows up at 5. It moved right.Stop trying to feel whether the sign is correct. Test one input. The minus is not lying, it is describing a change to what goes in, and the graph is drawn in terms of what comes out.You have been doing this since your first week of statistics, incidentally. Standardising a variable, `(x − mean) / sd`, is a shift followed by a stretch.Reading the formula before you plot itThis is the actual skill, and it takes an afternoon to build.Five clues, five verdicts. Run them in order and you can sketch most formulas before your plotting library has finished importing.CLUE IN THE FORMULA WHAT THE GRAPH IS GOING TO DO --------------------------- ---------------------------------------- x on the bottom a vertical wall where the bottom is zero even root over x the domain gets cut, half the line dies bars around x a sharp corner, never a smooth bend a brace with conditions possible jumps at the boundaries highest power is n at most n - 1 bends minus on the highest power the right tail points down top degree top degree = bottom degree flattens toward the ratio of the leaders top is one degree taller hugs a slanted line instead of a flat oneTry `y = −2(x − 3)² + 7` without scrolling. Squared, so a parabola. Minus out front, so it opens downward. The bracket shifts it right by 3, the plus 7 lifts it by 7. Peak at (3, 7), opening down.You just drew a graph without drawing anything.Here is a machine that does the same checks, so you can drill against it.import sympy as spx = sp.symbols("x")def read_shape(text): e = sp.sympify(text) # sympify parses a plain string into a real symbolic expression. top, bottom = sp.fraction(sp.together(e)) notes = [] walls = sp.solve(sp.Eq(bottom, 0), x) if walls: notes.append(f"wall at x = {walls}") if e.has(sp.Abs) or e.has(sp.floor): notes.append("corner or jump, not a smooth bend") fracpow = [q for q in e.atoms(sp.Pow) if q.exp.is_Rational and 0 # atoms(Pow) collects every power in there. An exponent strictly # between zero and one is a root sign wearing a disguise. if fracpow: notes.append("root sign, so half the line is gone") if top.is_polynomial(x) and bottom.is_polynomial(x): dt, db = sp.degree(top, x), sp.degree(bottom, x) if db == 0: n = dt - 1 notes.append(f"degree {dt}, at most {n} bend" + ("s" if n != 1 else "")) notes.append("right tail up" if sp.LC(sp.Poly(top, x)) > 0 else "right tail down") elif dt notes.append("ceiling at y = 0") elif dt == db: notes.append(f"ceiling at y = {sp.LC(sp.Poly(top, x)) / sp.LC(sp.Poly(bottom, x))}") elif dt == db + 1: notes.append(f"slanted ceiling y = {sp.div(top, bottom)[0]}") else: notes.append("no straight ceiling, it escapes") return notesfor t in ["3*x - 4", "x**2 - 5*x + 6", "-x**3 + 3*x", "1/(x - 4)", "(2*x)/(1 + x)", "(x**2 + 1)/(x - 1)", "sqrt(x + 3)", "Abs(x - 2)", "floor(x)", "(x**3 + 1)/(x - 1)"]: print(f"{t:20s}", read_shape(t))Real output, nothing edited.3*x - 4 ['degree 1, at most 0 bends', 'right tail up']x**2 - 5*x + 6 ['degree 2, at most 1 bend', 'right tail up']-x**3 + 3*x ['degree 3, at most 2 bends', 'right tail down']1/(x - 4) ['wall at x = [4]', 'ceiling at y = 0'](2*x)/(1 + x) ['wall at x = [-1]', 'ceiling at y = 2'](x**2 + 1)/(x - 1) ['wall at x = [1]', 'slanted ceiling y = x + 1']sqrt(x + 3) ['root sign, so half the line is gone']Abs(x - 2) ['corner or jump, not a smooth bend']floor(x) ['corner or jump, not a smooth bend'](x**3 + 1)/(x - 1) ['wall at x = [1]', 'no straight ceiling, it escapes']Cover the output. Read a formula. Say your answer out loud. Check. Twenty of those and the habit is yours.What each animal does for a livingA shape sticks better once you know where it works.Every silhouette owns a corner of statistics. This is the map from shape to job description.Lines are regression fits and null models. Parabolas are squared error. Cubics and up are polynomial regression and the segments inside a spline. Hyperbolas are rates, odds, and average fixed costs. Saturating ratios are diminishing returns, dose response, and the Michaelis and Menten equation from 1913 that describes how a reaction speeds up with more substrate and then flatly refuses to go any faster. Roots are standard errors. Hinges are absolute error. Staircases are discrete distributions.The last skill, and the trap underneath itYou have a cloud of points and no formula. Which family do you reach for?Squinting is a completely legitimate first step. It is just a spectacularly bad last one.Squint. Actually squint. Blur out the noise and ask what the trend is doing.Four clouds, four families. Straight, one bend, rises then flattens, falls then levels off.Straight cloud, fit a line. One clear bend, fit a quadratic. Rises fast then flattens toward a ceiling, that is a saturating ratio. Falls off a cliff then levels out near zero, that is a reciprocal.And now the trap, which is the best argument for plotting that anyone has ever made.In 1973 Francis Anscombe published four small datasets. Same mean. Same variance. Same correlation. Same fitted regression line, to two decimal places.Four datasets, identical summary statistics, four completely different animals. Only the picture can tell them apart.One is a clean linear relationship. One is an obvious curve that a straight line has no business describing. One is a line with a single outlier hauling it off course. And one is a vertical stack of points where a lone stray point invents the entire slope.Every number in that black bar is the same for all four.In 2017 two researchers at Autodesk took the idea further and built an algorithm that morphs any dataset into any target shape while holding the mean, variance and correlation fixed to two decimal places throughout. They produced thirteen of them. One is a star. One is a set of vertical lines. One is a dinosaur.Thirteen datasets, matching means, matching variance, matching correlation. One of them is a dinosaur, which is difficult to spot in a summary table.Dino GIFSo squint at the shape first. Then fit. Then plot the residuals and squint again, because the residual plot is where a wrong shape finally confesses.What you actually walked out withEight silhouettes. A vertex that always sits at `−b / 2a`. A discriminant that counts crossings with one subtraction. A degree that caps the bends at `n − 1`. Two tails decided by one coefficient. Walls where the bottom dies and ceilings decided by comparing two degrees. A domain that gets cut by fractions, even roots and logs. Corners from bars and jumps from braces. A staircase that turns out to be a probability distribution. Six edits that move any of it anywhere. And a healthy suspicion of any summary statistic that has not been plotted.That is a good afternoon.Go back to those two numbers from the very start. Twenty three metres at 30 mph, seventy three at 60. You do not need to memorise that any more. A straight line plus a squared term grows faster than either one alone, and you can now see that in the table without drawing it.That is the kestrel thing. It stops feeling like calculation and starts feeling like recognition.The two animals I left in their enclosures, the exponential and the logarithm, get the next article to themselves. They earn it. Between them they run compound interest, radioactive decay, the normal curve, and every likelihood anyone has ever tried to maximise.Plot something. Guess first.Polynomial Degree And Turning Points, Made Simple, Really Simple!! was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.