DEV Community

Lucian (LKB)
Lucian (LKB)

Posted on Originally published at lkforge.com

Three Hard Problems, One Method: Chaining Small Calculators

Originally published at lkforge.com.

A single calculator gives you one answer. But a real problem — where a ball lands, whether a score is an outlier, what solves a system — is never one answer. It's a chain of them.

That's the oldest trick in mathematics: you don't solve the whole thing at once. You decompose it into sub-problems, hand each piece to a method that already solves it, and recombine the pieces into the final result. If you have a set of small, single-purpose calculators, they are those methods. Here are three genuinely multi-step problems solved end to end, passing the output of one calculator straight into the next.

Problem 1 — a ball thrown off a ledge

You throw a ball straight up from a 5 ft ledge at 40 ft/s. Its height after t seconds is h(t) = 5 + 40t − 16t². When does it land, how high does it get, how fast is it moving at impact, and how far does it travel in all?

  1. Standard form. Tidy 5 + 40t − 16t² into −16t² + 40t + 5, so a = −16, b = 40, c = 5.
  2. Landing time — quadratic formula. Solve −16t² + 40t + 5 = 0. The discriminant is 1600 − 4(−16)(5) = 1920, and √1920 ≈ 43.82, giving t ≈ −0.12 (discard) or t ≈ 2.62 s.
  3. Velocity — derivative. h′(t) = 40 − 32t. Zero at t = 1.25 s (the peak), where h(1.25) = 30 ft. Impact speed is h′(2.62) ≈ −43.82 ft/s — and that's exactly √1920 from step 2, so the chain checks itself.
  4. Total distance — integral. ∫|h′(t)| dt, split at the peak: 25 ft up + 30 ft down = 55 ft of total path.

Chain: Polynomial → Quadratic Formula → Derivative → Integral.

Problem 2 — is that top score an outlier?

Ten quiz scores: 80, 95, 70, 85, 80, 100, 75, 90, 80, 85.

  1. Center. Sum 840 → mean 84, median 82.5, mode 80.
  2. Spread — variance. Squared deviations from 84 total 740 → population variance 74 (sample variance ≈ 82.2 if you divide by n−1).
  3. Standard deviation. √74 ≈ 8.60 — a typical score sits ~8.6 points from the mean.
  4. Judge the 100 — z-score. z = (100 − 84) / 8.60 ≈ 1.86. The usual outlier threshold is |z| = 2, so the top score is high but not a statistical outlier.

Chain: Mean/Median/Mode → Variance → Standard Deviation → Z-Score.

Problem 3 — solve a system of three equations

2x + y − z = 8, −3x − y + 2z = −11, −2x + y + 2z = −3. Write it as A·x = b.

  1. Is it solvable? — determinant. det(A) = −1 (non-zero) → a unique solution exists. Worth knowing before you solve.
  2. Inverse. Since x = A⁻¹·b, compute A⁻¹ (clean integers because det = −1).
  3. Verify — matrix multiply. A · A⁻¹ = the identity matrix, confirming the inverse before you trust it.
  4. Solve. x = A⁻¹·b = (2, 3, −1). Spot check: 2(2) + 3 − (−1) = 8 ✓.
  5. Rank. rank(A) = 3 = the number of unknowns → the three equations are independent and the solution is unique.

Chain: Determinant → Inverse → Multiply (verify) → Solve → Rank.

The point

None of the three needed a new, bigger calculator — each needed the small ones wired together in the right order. A suite of focused, single-purpose tools isn't a lesser thing than one giant solver: compose them and you can walk a projectile from a raw physics model to a landing speed, raw scores to a defensible "not an outlier," or three lines of algebra to a verified unique solution.

Check every number yourself

No figure above is on faith — this dependency-free script reproduces all of them (node reproduce.mjs):

// Problem 1 — h(t) = -16t^2 + 40t + 5
const a = -16, b = 40, c = 5
const disc = b*b - 4*a*c                       // 1920
const root = (-b - Math.sqrt(disc)) / (2*a)    // landing time
const tPeak = -b / (2*a)                        // 1.25 s
const hPeak = a*tPeak**2 + b*tPeak + c          // 30 ft
const vLand = 2*a*root + b                       // impact velocity
console.log({ disc, land: root.toFixed(2), tPeak, hPeak, vLand: vLand.toFixed(2) })
// { disc: 1920, land: '2.62', tPeak: 1.25, hPeak: 30, vLand: '-43.82' }

// Problem 2 — ten quiz scores
const d = [80,95,70,85,80,100,75,90,80,85]
const mean = d.reduce((x,y)=>x+y,0) / d.length      // 84
const ssd  = d.reduce((s,v)=>s+(v-mean)**2, 0)      // 740
const popSD = Math.sqrt(ssd / d.length)             // 8.60
console.log({ mean, popVar: ssd/d.length, popSD: popSD.toFixed(2), z100: ((100-mean)/popSD).toFixed(2) })
// { mean: 84, popVar: 74, popSD: '8.60', z100: '1.86' }

// Problem 3 — system A x = b
const A = [[2,1,-1],[-3,-1,2],[-2,1,2]], bv = [8,-11,-3]
const det = A[0][0]*(A[1][1]*A[2][2]-A[1][2]*A[2][1])
          - A[0][1]*(A[1][0]*A[2][2]-A[1][2]*A[2][0])
          + A[0][2]*(A[1][0]*A[2][1]-A[1][1]*A[2][0])   // -1
const Ai = [[4,3,-1],[-2,-2,1],[5,4,-1]]
const x = Ai.map(r => r[0]*bv[0] + r[1]*bv[1] + r[2]*bv[2])
console.log({ det, solution: x })   // { det: -1, solution: [ 2, 3, -1 ] }
Enter fullscreen mode Exit fullscreen mode

The full worked version, with every sub-step linked to the calculator that does it, is on lkforge.com.

Top comments (0)