Fin Maverick
Foundations VocabularyAccounting & ReportingEconomics & MacroQuant Methods & ProgrammingBusiness & Company AnalysisCorporate Finance & ValuationBehavioural Finance
Banking & Market InfrastructureFixed Income & RatesDerivatives & Structured ProductsPublic EquitiesTransactions & DealsPortfolio ConstructionFunds & AMCs
Private Markets & AlternativesRisk, Treasury & ControlAI & Digital FinanceStochastic Calculus & PricingWealth & Personal FinanceIndian Markets & RegulationProfessional Practice
CalculatorComparison
Frameworks
Explore Bootcamps
Equity ResearchPortfolio ManagementMutual Fund MasteryFinancial LiteracyInvestment Banking Analyst
Private Equity AnalystHedge Funds AnalystBreaking Into VCBreaking Into QuantsAI For Finance
Financial Analyst ProgramRisk Management ProgramPrivate Wealth ManagementDebt Capital MarketsDerivatives Foundation
Explore Internships
Equity Research InternMutual Fund Intern
Portfolio Management InternFinancial Literacy Intern
Explore Micro Courses

Equity Research6

Writing an Investment ThesisBuilding a Discounted Cash FlowReading an Annual Report FastReading a Sector Before a CompanySpotting Quality of Earnings Red FlagsBuilding a Revenue Forecast From Drivers

Portfolio Management3

Rebalancing: When, Why and What It CostsStrategic and Tactical Asset AllocationMeasuring Risk in a Portfolio

Mutual Fund Mastery3

Comparing Funds Without Being FooledHow a NAV Is Struck and Which Day You GetReading a Fund Factsheet Properly

Derivatives Unlocked4

Hedging a Real ExposureThe Greeks, PracticallyFutures, the Basis and What Moves ItReading an Option Payoff

AI For Finance2

Retrieval and Grounding for FinanceDocument Extraction in Finance

Breaking Into Quants4

Backtesting a StrategyHypothesis TestingCleaning Financial DataRegression for Finance

Breaking Into VC3

Sizing a MarketReading a Term Sheet as a FounderHow a Venture Round Actually Works

Financial Analyst Program4

Common Size and Trend AnalysisReading a Cash Flow StatementRatio Analysis That Says SomethingBuilding a Working Capital Schedule

Risk Management Program2

Credit Exposure and How It Is ReducedValue at Risk and What It Hides

Investment Banking Analyst3

Precedent Transactions and Why They DifferReading a Term Sheet StructurallyBuilding a Comparable Companies Table

Private Wealth Management3

Tax Aware Portfolio DecisionsBuilding a Client Risk ProfileGoal Based Planning Arithmetic

Debt Capital Markets3

Analysing an Issuer's CreditDuration and What It Does Not Tell YouBond Pricing and Yield Mechanics

Private Equity Analyst2

Fund Waterfalls and CarryThe LBO in Structure

Hedge Funds Analyst2

Short Selling MechanicsLong Short Mechanics
Courses
Explore Career Roadmaps
Investment Banking AnalystEquity Research AnalystVC AnalystPrivate Equity AnalystHedge Funds Analyst
Quant AnalystAI For FinanceFinancial Analyst ProgramPrivate Wealth ManagementDebt Capital Markets
Risk Management ProgramDerivatives FoundationPortfolio ManagementMutual Fund Mastery
PartnershipsShowdown
Log inSign up
Quantitative Methods, Financial Data & Programming
1Probability
Probability in FinanceRandom VariableProbability DistributionsThe Normal DistributionNormal Distribution ProbabilityThe Lognormal DistributionRandomness vs Uncertainty
2Statistics and Inference
Population and SampleMean, Median and ModePrecision and AccuracyVariable TypesVariance, Standard Deviation and…Dispersion MeasuresStatistical BiasEffect SizeHypothesis TestingThe Sampling DistributionSkewnessKurtosisCovarianceConfidence IntervalArithmetic Mean vs Geometric MeanStatistical Significance vs Economic…Confidence Interval vs Prediction IntervalHow to Summarise a…
3Correlation and Regression
RegressionCorrelation and CausationOrdinary Least SquaresInteraction TermsRegression CoefficientsRegression vs ClassificationHow to Build a…Spurious CorrelationRegression, Correlation and FitResidualsMulticollinearityAutocorrelation and Partial Autocorrelation
4Time Series
Time Series in FinanceSimple, Weighted and Exponential…Moving Average CalculatorPrice, Return and Level SeriesHow to Prepare Time-Series…LagFrequencySeasonalityTimestampsTrendStationarity and the Unit RootHeteroskedasticityLeadRolling WindowsDifferencing
5Simulation and Numerical Methods
SimulationMonte Carlo SimulationHow to Run a…Numerical MethodsIterationResampling and the BootstrapPseudorandom Numbers and the SeedConvergence and ToleranceNumerical Stability
6Optimisation
OptimisationLocal and Global OptimaConstraintsConvex OptimisationThe SolverLinear ProgrammingThe Objective FunctionConstraint ViolationThe Feasible SetLagrange MultipliersQuadratic Programming
7Modelling Practice
Linear, Logistic, Ridge and…Training, Validation and Test…The ModelModel ErrorDependent and Independent VariablesThe ROC Curve and AUCWhat a Model HoldsMSE, RMSE, MAE and MAPEPrecision and RecallCross Validation and RegularisationOverfitting and UnderfittingReturn Series MeasuresSimple, Compound and Log Return
8Backtesting and Research Integrity
BacktestingBacktest vs Live PerformanceHow to Document a…How to Prevent Backtest…Out-of-Sample TestingWalk-Forward AnalysisMultiple TestingP-HackingData Snooping
9Data Quality and Structure
Data QualityThe DatasetSelection and Survivorship BiasVersioned DatasetsData Structures in FinanceData CleaningMissing Data and Null ValuesStructured Data vs Unstructured DataMissing Data vs ZeroData Validation vs Data CleaningOutliersDuplicate Records
10Programming for Finance
Data PipelinesAPIs for Financial DataAPI vs CSV FileDatabases in FinancePython for FinanceJoinsSQL for FinanceThe Analysis Workflow
11Quantitative Research
Research DesignThe Data Generating ProcessReproducibilityPeer Review in Analytical WorkThe Research HypothesisRobustness and Sensitivity

Numerical Stability: When Small Errors Grow

Numerical stability asks one thing: does the route taken through the arithmetic grow a small error or shrink it? Two formulas that are the same on paper can part company on a machine. Add 10,000 to every month of the fifty month record, which cannot change its variance at all, and one route still reads 24.250000 while the other, on an eight digit calculator, reads 20.000000.

Every figure below comes out of the arithmetic printed beside it, so a figure is checked by recomputing it and in no other way. An eight digit calculator reproduces every collapse below by hand. A machine nobody can see inside would hide the very step that does the damage.

Two of those numbers are the interesting pair. The 24.250000 is right and the 20.000000 is wrong, they were produced from identical data by two textbook formulas for the same quantity, and neither calculation broke a single rule of arithmetic on the way. Nothing crashed. Nothing warned. One of them just quietly stopped being able to give the answer.

Everything below leans on three things settled elsewhere and used here without being re-explained. First, what a varianceA settled measure of how spread out a set of values is: take each value's distance from the average, square it, and average the squares. The measure and its uses are covered separately. is, and the fact that adding the same amount to every value leaves it exactly where it was. Second, the fifty month record of the Nakshatra unit, an invented traded unit built for teaching, whose fifty monthly changes have a variance of 24.25. Third, the Nakshatra ladder, a stated arithmetic rule which opens at Rs 100/-, grows the balance by a monthly rate, removes Rs 2/-, and repeats that twelve times. All three arrive finished. And one plain fact about machines, used everywhere below and explained nowhere: any calculator, any spreadsheet, any program carries a fixed number of digits and no more.

What is numerical stability, and what is it a property of?

Consider giving somebody directions to a familiar place. There are two ways to get there. One goes along the main road, and a walker who drifts twenty metres off it can see where they are and correct. The other cuts through five turns in a warren of lanes. Twenty metres of drift at the first turn puts the walker on the wrong lane. The wrong lane at the first turn puts them on the wrong lane at the second, and by the fifth they are somewhere else entirely. The destination did not change. The drift did not change. The route decided whether the drift mattered.

A calculation is stable when a small error in what goes in stays small in what comes out, and unstable when that small error grows as the arithmetic runs, and this is a property of the route chosen rather than of the question asked. The route, not the question, is the part that surprises people. Saying that some quantities are simply hard to compute is tempting, and occasionally the claim is true. Far more often the quantity is perfectly well behaved and one particular way of getting to it is not.

Which means instability is usually something picked up rather than something handed over. Nobody chooses it on purpose. An analyst chooses the formula that reads the data once instead of twice because it is faster, or the version they were taught, or the one that fits on a line, and the stability came attached to the choice without ever being mentioned.

Try it out

A quantity has been computed and the answer is badly wrong. No rule of arithmetic was broken anywhere in the working. Where does the instability live?

How can the same rule grow an error one way and forget it the other?

The cleanest demonstration is the Nakshatra ladder. The ladder opens at Rs 100/-, grows the balance by the monthly rate, then removes the standing chargeA flat deduction that lands at the same size each period no matter how large or small the balance underneath it has grown to be. Here it is the Rs 2/- step of the Nakshatra ladder. of Rs 2/-. At a monthly rate of exactly 2.00 per cent the two effects cancel each month and the ladder reads Rs 100.00/- in every one of the twelve months, forever, flat.

Now one tiny mistake at the start. Suppose the opening figure is written as Rs 100.01/- rather than Rs 100.00/-. One paisa. Run forward, the ladder reads Rs 100.010200/- after the first month, so the paisa has become 1.0200 paise. After twelve months it reads Rs 100.012682/-, so the paisa is now 1.2682 paise. Nothing dramatic has happened, and the honest description of that growth is modest. Direction matters here rather than size: the deviationHow far one value sits from the reference it is being measured against, written with its direction attached. Settled elsewhere and used here as it stands. from the flat line is multiplied by 1.02 every single month, and multiplication by anything above one never stops. Over fifty months the factor is 2.691588. The mistake does not fade. It compounds, quietly, alongside everything else.

Now the same rule run the other way. Suppose this month's reading is known and last month's is wanted. The two steps are undone in reverse: add the Rs 2/- back, then divide by 1.02. The rule is the same, the rate is the same, the ladder is the same. Dividing by 1.02 repeatedly drives anything towards nothing. Started one paisa high, the error has fallen to 0.7885 of a paisa after twelve steps, and after another twelve it would be smaller still.

ONE PAISA, TWELVE MONTHS, THE SAME RULE IN TWO DIRECTIONS0.00.40.81.2month 0month 3month 6month 9month 12paise above the flat ladderthe ladder run with no error at all, flat at Rs 100.00/- every month1.26820.7885both start one paisa highrun forwards, the error is multiplied by 1.02 every monthrun backwards, the same rule divides it by 1.02 every monthSame rule, same starting mistake, opposite behaviour. Forwards it grows to 1.2682 paise and keepsgrowing; backwards it shrinks to 0.7885 of a paisa and keeps shrinking.
Run forwards, the one paisa error grows to 1.2682 paise over twelve months and keeps growing; run backwards, the same rule on the same ladder shrinks it to 0.7885 of a paisa.

Same arithmetic. Same starting mistake. Opposite behaviour. One direction of travel remembers every error it has ever been given and multiplies it forever, and the other direction forgets. The pair is the single clearest picture of what stability means and where it lives, and it settles whether instability belongs to the problem. The problem here is one rule, and the rule is stable one way round and unstable the other.

Try it out

The Nakshatra ladder at 2.00 per cent, started one paisa high, reads Rs 100.012682/- after twelve months. What single number turned one paisa into 1.2682 paise, and what would running the rule the other way have done to that same paisa?

How can two formulas for one variance disagree?

The ladder was the gentle case. The variance is not gentle, and every other failure below grew out of it.

There are two standard ways to work out how spread out a set of numbers is. The first reads the data twice: one pass gives the average, and a second pass takes each value away from that average, squares the difference, and averages the fifty squares. The two pass route is so named because it reads the data two times. The one pass route reads it once: each value is squared as it arrives, those squares are averaged, and the square of the average is subtracted. The two are the same thing written differently: expanded algebraically, the first becomes the second, exactly, with nothing approximated and nothing dropped. On paper they are not two methods. The two formulas are one method in two costumes.

On the fifty month record both give 24.25. Now do something that cannot possibly matter. Add the same amount to every one of the fifty months. Adding a constant slides all the values along together without pulling them any further apart, so the spread is untouched and the variance must come out at 24.25 again. Every honest answer below has to read 24.25.

Watch what happens on a calculator that carries eight significant figuresThe digits of a written number that actually carry its size, starting from the leftmost one that is not a zero. How many of them a machine keeps, and why, is covered separately under programming..

Added to every monthThe two pass routeThe one pass route, eight digitsWhat it should say
024.25000024.25000024.25
10024.25000024.25000024.25
1,00024.25000024.30000024.25
10,00024.25000020.00000024.25
1,00,00024.2500000.00000024.25
10,00,00024.2500000.00000024.25

The two pass route reads 24.250000 at every single setting, and the one pass route falls off a cliff. Read the third row again, though. The third row is the frightening one. At an addition of 1,000 the one pass route gives 24.30. Not zero. Not an error message. Not a wild number that anybody would query. The route gives 24.30 against a true 24.25. A person reads a disagreement that small as a rounding difference and moves past. The failure has already started at that row, and there is nothing anywhere on the screen that says so.

ONE SET OF FIFTY NUMBERS, TWO ROUTES, ONE SHIFT OF 1,00,000WHAT GOES IN, THE SAME FOR BOTH COLUMNS1,00,0011,00,00199,9911,00,0011,00,0011,00,006and 44 more, all fiftyTHE TWO PASS ROUTE1Average the fifty. It comes to1,00,000.502Take each month away from thataverage3Square the fifty gaps and averagethemIT REPORTS24.250000correctTHE ONE PASS ROUTE1Square each month, average thefifty: 10,00,01,00,024.502Square the average instead:10,00,01,00,000.253Subtract, with eight digits kept oneachIT REPORTS0.000000no variation at allAdding the same amount to every month cannot change a variance.The true answer is 24.250000 at every one of the six shifts.
At an addition of 1,00,000 the two pass route reads 24.250000 and the one pass route reads 0.000000, from the same fifty numbers.
THE TWO ANSWERS AS THE SHIFT RISES051015202501001,00010,0001,00,00010,00,000the amount added to every monththe two pass answer, 24.250000 throughout0.00000020.000000the one pass answer alreadyreads 24.30 here, and no scalethis wide could show itTHE FIRST THREE, MAGNIFIED24.2024.2524.3001001,000the one pass answeris already wronggreen showing through means both agreeThe green line never moves. The red one is out by 0.05 at a shift of 1,000 and by 4.25 at 10,000,and it reports no variation at all from a shift of 1,00,000 onwards.
The one pass answer reads 24.30 at an addition of 1,000, 20.00 at 10,000 and 0.00 at 1,00,000, while the two pass answer reads 24.25 at every one of them.

The magnified panel on the right of that chart is there because of a real drawing problem, and the problem is itself the lesson. On a scale that runs from zero to twenty six, the gap between 24.25 and 24.30 is about half a pixel wide. The gap cannot be drawn. It cannot be seen. Any chart wide enough to also show the collapse to zero hides it, and a report hides it for exactly the same reason. The failure is well underway before it is large enough for anybody to notice. The third of the three signs set out below is therefore a test that has to be run rather than a thing to look for.

Try it out

At an addition of 1,000 the one pass route reads 24.30 against a true 24.25. What warning does the calculation give at that point?

Try it out

Both halves are worth deciding now, while the panel underneath still gives nothing away. The next step adds 1,00,000 to every month of the fifty month record. What should happen to its variance, and what will the one pass route report?

Play with it

Add the same amount to every month and watch one column hold and the other empty out

One dial, and it moves one thing: how much is added to every one of the fifty months. Nothing else changes. The bars are drawn against the average of whatever setting is in force, so the picture of the record is identical at all six settings. Adding a constant genuinely does nothing to the spread, and an identical picture is the honest one. Underneath, the two answers redraw. The panel opens at an addition of 10,000. The two pass answer there is 24.250000 and the one pass answer is 20.000000, the same two figures printed in the table above. Two extra readouts show the actual pair of eight digit numbers being subtracted, so they can be watched creeping towards each other digit by digit before either answer moves.

Jump straight to a setting worth seeing:
Added to every month
The true variance
Two pass route
One pass, eight digits
Average of the squares
Square of the average
Leading digits they share
Most the answer can be off by
Educational illustration. Adding the same amount to every month cannot change a variance. Every honest reading on this panel therefore has to be 24.25, and the second column moving at all is the fault being demonstrated. The eight digit calculator stands in for any machine carrying a fixed number of digits; a machine carrying more digits shows the same collapse at a larger addition rather than avoiding it.
Breaking Into Quants Bootcamp — Fin Maverick

What happens when two numbers that are nearly the same size are subtracted?

The why is one sentence with a number attached, and the number is worth working through slowly.

At an addition of 1,00,000 the one pass route needs two quantities. The average of the fifty squares comes to 10,00,01,00,024.50. The square of the average comes to 10,00,01,00,000.25. Subtracted exactly, they give 24.25. The right answer came entirely out of the ninth, tenth and eleventh digits. The first eight digits of the two numbers are identical, so they contribute exactly nothing to the answer. Every scrap of the information actually wanted is sitting in the tail.

Now hand those two numbers to a calculator that keeps eight digits. It keeps 10,00,01,00,000 and 10,00,01,00,000. Both of them. The same. Eight digits is all there was room for, so the tail was never kept. The tail was the answer.

WHERE THE ANSWER GOES, DIGIT BY DIGIT, AT A SHIFT OF 1,00,000WHAT THE ANSWER IS ACTUALLY MADE OFAverage of the squares10000100024.50Square of the average10000100000.25The first eight digits agree, sosubtracting wipes all eight out.The whole answer lives in thethree digits after them.024.50 less 000.25 leaves 24.25, the right answerWHAT A CALCULATOR KEEPING EIGHT DIGITS ACTUALLY HASAverage of the squares10000100000.00Square of the average10000100000.00The ninth digit onward wasnever kept, so both rows readthe same number exactly.Nothing is left to subtract.The same subtraction now leaves 0.000000The error in each big number never changed size. What changed is how much answer was left to swallow.
The two big numbers agree in their first eight digits, so subtracting throws every agreeing digit away and what survives is whatever the machine had already rounded.

The error in each of those two big numbers never changed size at all; what changed is that the answer got small enough for the error to swallow it whole. An eight digit machine writing a number of that size is entitled to be out by up to five hundred in either direction. Five hundred against ten thousand crore is nothing, a relative errorA gap measured as a share of the quantity it sits in, rather than in the units the quantity is written in. Five rupees is a large gap on a bus fare and a rounding on a house. of about five parts in a hundred million, and no reasonable person would call it a problem. Five hundred against an answer of 24.25 is a catastrophe.

The ratio has a size, and the size can be computed rather than gestured at. The two big numbers are 41,23,75,258.7423 times as large as the answer they are supposed to produce. The factor is the magnification, and the magnification converts the harmless relative error on each big number into the relative error on the answer. Five parts in a hundred million, multiplied by 41,23,75,258, comes to about twenty. The answer can be out by twenty times its own size. Reporting 0.000000 amounts to being wrong by a hundred per cent, comfortably inside that.

Run the same sum at the other settings and it predicts what the table already showed. At an addition of 1,000 the magnification is 41,279.3608 and the arithmetic says up to about 0.21 per cent of the answer is at risk. The one pass route gave 24.30 against 24.25, out by 0.2062 per cent. At an addition of 10,000 the magnification is 41,24,124.7216, the arithmetic says up to about 20.62 per cent is at risk, and the route gave 20.00 against 24.25, out by 17.5258 per cent. The magnification is not a story about a mysterious machine. The magnification is one multiplication, and it flags the answer as being in trouble before the answer is computed.

Try it out

Two numbers that agree in their first eight digits are subtracted. The error in each one is exactly the same size it was before. Why is the error in the answer so much worse, and what is that magnification ratio actually measuring?

AI For Finance Bootcamp — Fin Maverick

Why does rounding at every step cost so much more than rounding once?

The second case is about a different route to the same trouble, and it needs no large numbers at all.

Try it out

Worth settling before reading on. Rs 100/- compounded through all fifty months of the fifty month record reaches exactly Rs 120.808714/-. Suppose instead the price were rounded to the nearest rupee at the end of every month. How far off would the ending price be?

Rs 100/- compounded through the fifty month record gives the following. The order of the fifty months is the stated one, produced by the arithmetic rule named here from the starting number 4321 rather than chosen by hand, and it rearranges the fifty values without altering any of them. Done exactly, the price finishes at Rs 120.808714/-.

Now do the identical run, but round the price to the nearest rupee at the close of every month, the way a system storing whole rupees would have to. The rounded run finishes at Rs 115.00/-. The gap is Rs 5.808714/-, or 4.8082 per cent of the exact answer, produced by nothing but rounding.

Do it a third time, rounding to the nearest paisa instead. The paisa run finishes at Rs 120.82/-, out by Rs 0.011286/-. No report would carry a gap that small.

ROUNDING TO THE NEAREST RUPEE EVERY MONTH, OVER FIFTY MONTHS90110130150Rs 120.808714/-exactRs 115.00/-roundedthe price of the Nakshatra unit, in rupeesmonth 0month 10month 20month 30month 40month 50THE GAP BETWEEN THEM, IN RUPEES, MONTH BY MONTH0246Rs 5.808714/-it does not only grow: it swingsOne rounding is worth at most fifty paise. Fifty of them, eachcompounded by everything after it, are worth Rs 5.808714/-.
Rounding the price to the nearest rupee at the end of every month brings Rs 100/- to Rs 115.00/- over the fifty months against an exact Rs 120.808714/-, a gap of Rs 5.808714/-.

The rounding is not the error; compounding the rounding is. No single month's rounding is worth more than fifty paise. But each month's rounded price becomes the base the next month's change is applied to, and then that month's answer is rounded and becomes the base after it, and so on for fifty months. A rounding made in month three is not worth fifty paise by month fifty. The month three rounding has been carried through forty seven further multiplications, and it comes out the other end worth whatever those multiplications made of it. The ladder's forwards direction is back again, wearing different clothes: a quantity carried forward and multiplied by more than one, repeatedly.

Notice the lower chart in that figure. The lower chart says something the ending figures alone do not. The gap does not climb steadily. It swings above and below zero for most of the run, reaching Rs 6.7568/- at its widest before settling back to Rs 5.808714/- at the end. Each month's rounding can go up or down, so the errors partly cancel each other. Every one of them is then compounded by everything that follows, so no error can stay the size it started at.

And this is why the same rule at a different precision costs almost five per cent one way and nothing the other. The rupee run rounds coarsely fifty times, and each of those coarse roundings gets compounded. The paisa run rounds finely fifty times, and each of those fine roundings gets compounded too, but a hundredth of nearly nothing, compounded, is still nearly nothing.

Try it out

Rounding to the nearest paisa each month costs Rs 0.011286/- over the fifty months, and rounding to the nearest rupee costs Rs 5.808714/-. The rounding got exactly one hundred times coarser. Why did the cost rise by far more than one hundred times?

What are the three signs, and can they be seen before anything fails?

All of this is much less mysterious than it looks from the outside, and it comes down to three things to look for. Two of them are visible in the arithmetic itself, before anything has been run.

The first is a subtraction of two numbers that are nearly the same size. The one pass variance route is that subtraction in a single line, and so is every calculation that measures a small difference between two large measured quantities. Wherever it appears, the agreeing digits are about to be thrown away and whatever the machine had rounded is about to become the answer.

The second is a quantity carried forward and multiplied by something bigger than one, again and again. The Nakshatra ladder run forwards is exactly that, and so are the fifty months of compounding above. Anything already sitting in that quantity, including any mistake, gets multiplied along with everything else, every single time.

The third is different in kind. It is an answer that changes when the data is shifted, scaled or reordered and should not have. Checking for that third sign is the cheapest test in this whole area of work: add a constant to every value, run the calculation again, and see whether the answer moves. The test costs a single line. It needs no understanding of the code being tested. And unlike the first two it does not require anything to have been spotted in advance. The first two are only visible to someone already looking for them.

THREE THINGS TO LOOK FOR, AND WHERE THEY SIT IN THE ARITHMETICTHE ONE PASS ROUTE, DRAWN AS A CHAINadd 1,00,000 toevery monthsquare each ofthe fiftyaverage thefifty squaressquare theaverage insteadsubtract the two1THE NAKSHATRA LADDER, DRAWN AS A CHAINstart one paisahighmultiply by 1.022take Rs 2/- offand again,twelve timesTHE THREE SIGNS, IN FULL1A subtraction of two numbers that are nearly the same sizeThe agreeing digits vanish and the rounding is all that is left.2A quantity carried forward and multiplied by more than one, again and againEvery earlier mistake gets multiplied along with everything else.3An answer that moves when the data is shifted, scaled or reorderedIt should not move at all, so a move is the route telling on itself.The first two are visible in the arithmetic before it is run.The third is visible in the answer afterwards.
Watch for a subtraction of two nearly equal numbers, for a quantity carried forward and repeatedly multiplied by more than one, and for an answer that moves when the data is shifted.
Try it out

A constant is added to every input of a routine that should not care, and the routine gives a different answer. What has that established, and what has it not?

Risk Management Program Bootcamp — Fin Maverick

What is to be done when the unstable step cannot be avoided?

Sometimes the subtraction is spotted and there is no way around needing it. Four things are available, and they are not equal.

Reorder the arithmetic so that the subtraction happens early. Doing it while the numbers are still small beats doing it at the end once they have grown. Reordering is free. Same data, same operations, different order.

A rough centre can be taken off the data at the outset. Any convenient number near the middle of the values is subtracted from all of them, the work is done, and the answer for a variance comes out unchanged because a shift cannot change a spread. Taking a rough centre off costs one extra read of the fifty values, and it is exactly what the two pass route already does when it takes the average off first. The two pass route never budged from 24.250000 in the table above for precisely that reason.

Carry more digits. Extra digits are the weakest of the four remedies and the one people reach for first. Buying digits feels like buying safety. More digits do not remove the collapse. They move it. The eight digit calculator empties out at an addition of 1,00,000; a full machine carrying about sixteen digits empties out at an addition of 1,00,00,00,000. Same failure, same shape, further along the road, and now much harder to trip over in testing because the setting that triggers it is somewhere nobody thought to look.

And where the route runs in a direction that grows errors, the other direction is available if the question allows. Reversing the direction is different from the other three: it does not change the route, it changes the question being asked. Working out next month from this month and recovering last month from this month are not the same question, and no amount of rearranging turns one into the other. Where they happen to be interchangeable, the direction that shrinks is the one to take.

FOUR THINGS AVAILABLE, AND WHAT EACH ONE ACTUALLY CHANGESTHESE THREE CHANGE THE ROUTE1Reorder the arithmetic so the subtraction happensearly, while the numbers are still smallcosts nothing at all, and it is the only one that does2Take a rough centre off the data at the outset,which is exactly what the two pass route doescosts one extra read of the fifty3Carry more digitsTHE WEAKEST OF THE FOUR, and the one reached for firstNone of the three needs the question to change.THIS CHANGES THE QUESTION4Run the rule in theother direction, wherethe same arithmeticshrinks the errorinstead of growing itOnly open where the questionallows it. Recovering lastmonth from this month is adifferent question fromworking out next month.Not always available.Carrying more digits does not remove the collapse. It moves it to a larger shift, which is whythe eight digit calculator dies at 1,00,000 and a full machine dies at 1,00,00,00,000.
Reordering the arithmetic, taking a rough centre off first and carrying more digits all change the route, while running the rule in the other direction changes the question instead.
Try it out

Of the four remedies above, one changes the question rather than the route. Which is it, and which of the four is the weakest?

Bond Pricing and Yield Mechanics — free micro-course from Fin Maverick

What is the one habit worth keeping?

Everything above collapses into a single working habit, and it belongs to whoever actually has to trust a figure: the analyst signing off a variation number, the lender reading a volatility measure off a spreadsheet somebody else built, the researcher whose model rests on a covariance produced three layers down in a library, the household treasurer reconciling a passbook against a system that stores whole rupees.

Before any figure produced by a chain of arithmetic is trusted, a large constant is added to the data, the chain is run again, and anything that moved without any business moving shows itself. Shift it. Scale it. Reorder it. Any of the three, and the shift is the easiest to write.

THE ONE LINE TEST, AND WHAT IT PRINTSThe same routine, the same fifty readings, the same code. Only the base has changed.RUN 1, READINGS ON A BASE OF 100readings in50first three101, 101, 91routeone pass, eight digits keptstatuscompleted, no warningsVARIATION REPORTED24.250000RUN 2, READINGS ON A BASE OF 1,00,000readings in50first three1,00,001, 1,00,001, 99,991routeone pass, eight digits keptstatuscompleted, no warningsVARIATION REPORTED0.000000Nothing about the readings changed. One number was added to all of them and the reported variationfell to nothing, which is the routine showing where the instability lives.
Shifting the data by a large constant and rerunning costs one line and catches the fault that rereading the code never catches, because the code is correct.

The reason this is worth a habit rather than a note is that it catches the one class of fault no amount of reading the code will ever catch. When a test fails, the usual course is to read the code and find the mistake. There is normally a mistake to find. Here there is not. The formula is right. The formula is in the textbook. Its implementation matches it line for line. Every test anybody wrote was checking whether the code does what the formula says, and it does, so every test passes. The formula and the machine simply disagree about the answer. The only thing that surfaces the disagreement is running the same code on data that should give the same answer and seeing that it does not.

The habit also fails safe. If the answer does not move, nothing has been learned and one line has been spent. If it does move, something has been found that no amount of care in the writing could have prevented, and found before somebody quoted the number.

The failure: a routine that reported no variation at all, and passed every test on the way

A reporting routine works out the variation in a set of month end readings. Reading the data once is faster than reading it twice, so the routine uses the one pass route. On readings in the tens it has run correctly for years. Nobody has any reason to look at it. It is not new, it is not clever, and it has never been wrong.

Then the readings are restated on a base of 1,00,000 rather than 100. The restatement is a presentation change and nothing else. Not one reading moved relative to any other; the same months are still the same distance apart; the underlying record is untouched. Somebody decided the numbers read better that way, and a decision of that sort gets made without a meeting.

The routine now reports zero variation in data that visibly varies, and it reports it without an error, a warning or a single failed test. The chart beside the figure still shows the readings going up and down. The number under it says they do not move at all. The code is correct and always was, so nothing in the system is aware of the contradiction. Every check anybody runs on it will pass, including the ones written specifically to catch this sort of thing.

The cost is a report stating that a quantity is perfectly steady when it is not, produced by a system with a spotless record, read by people with no reason to doubt it. Nobody involved did anything careless. The person who wrote the routine picked a standard formula out of a standard book. The person who restated the base changed nothing about the data. The person reading the report read it correctly.

And the fix is one line rather than a rewrite: a large constant added to the readings, the routine run again, and the two compared. Anything that should be unchanged and is not has just shown where the instability lives. On this routine that test takes seconds and it fails loudly. The entire rest of the system managed nothing of the kind.

Covered elsewhere. The definition of a numerical method and the kinds there are came earlier and are taken as read here. How close is close enough, and how a toleranceA size of gap settled in advance as acceptable, so that the point to stop is known. What one is and how it is chosen are covered separately. is set and what it costs in work, are settled separately and are a different question from whether the arithmetic can be trusted at all. Repeating a rule until an answer settles is covered separately too, and iterationRepeating one rule so that each run starts from whatever the last run produced. Covered separately; used here only as something the ladder already does. appears here purely as something the Nakshatra ladder does rather than as a subject. The consequence of a machine carrying a fixed number of digits is described here; how a number is laid out in storage is covered separately under programming, and the eight digit calculator used above is a stand in chosen because a reader can reproduce it by hand rather than a description of any particular machine.
Two formulas for one variance disagreed. See which habit keeps the figure trustworthy.

Is there anything here resting on somebody else's word?

There is not. Arithmetic has no issuing body, no jurisdiction and no revision date, so no source exists for anybody to confirm a figure against. Instead there is a recipe for every figure, and recomputing is the only kind of checking that applies. The table below gives each one and what reproduces it. Two of them need a calculator that shows eight digits and nothing else; the rest need patience. The loss of digits when nearly equal numbers are subtracted has a standard name in the literature on computation, and it belongs to no single author.

The figureWhat reproduces itWhat is needed to hand
The variance of 24.25 on the fifty month recordThe fifty monthly changes, average them, take each away from the average, square, average the fifty squaresPatience, or a spreadsheet
The one pass readings of 24.30, 20.00 and 0.00Add the stated amount to all fifty, average the squares, square the average, round each to eight digits, subtractA calculator showing eight digits
The magnifications of 41,279.3608, 41,24,124.7216 and 41,23,75,258.7423The average of the fifty squares at that addition, divided by 24.25One division, three times
The ladder readings of Rs 100.010200/- and Rs 100.012682/-Start at Rs 100.01/-, multiply by 1.02, subtract Rs 2/-, twelve times overTwelve multiplications
The reversed ladder error of 0.7885 of a paisaStart at Rs 100.01/-, add Rs 2/-, divide by 1.02, twelve times overTwelve divisions
The ending prices of Rs 120.808714/-, Rs 115.00/- and Rs 120.82/-Rs 100/- compounded through the fifty months in their stated order, once exactly, once rounding to the rupee each month, once to the paisaThe record in its stated order, and a spreadsheet
The stated order of the fifty monthsMultiply by 16,807 and take the remainder on 2,14,74,83,647, from the starting number 4321, walking from the last month back to the second and swapping each position with an earlier one the rule picksA machine that will do whole number arithmetic that large

The Nakshatra unit, the Nakshatra ladder, the fifty month record and the reporting routine in the failure above are invented.
Educational material. Not advice on any investment, tax, budget or market position.

← Previous
Fin Maverick Micro CoursesExplore Micro Courses
Fin Maverick BootcampsExplore Bootcamps
Fin Maverick

Finance education that ends in a job, not a certificate that gathers dust. Built for young India.

LEARN
CalculatorsFrameworksComparisonsCareersShowdown
RESOURCES
All CoursesMicro CoursesBootcampsInternships
COMPANY
AboutJob openingPartnership
LEGAL
Privacy PolicyTerms & ConditionsContent LicenseReturn & Refund Policy
© 2026 FIN MAVERICK / BUILT FOR INDIA.DO FINANCE, DO NOT JUST READ ABOUT IT.