Module 1 · Mathematical Language and Quantitative Reasoning Lesson 7 of 120

Linear Equations and Systems

Reconciling transaction counts and fee totals.

2:34 clip23:54–26:29 in the full courseWatch on YouTube

Transcript

27 sentences · select one to jump there

Check your understanding

What if both equations are identical?

Choose one answer

Code lab

Run it yourself

The lesson source in 7 languages. Edit it, run TypeScript and Python right here, and compare with the expected output.

007-linear-equations-and-systems.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 007 of 120
 * Linear Equations and Systems
 * Module 01: Mathematical Language and Quantitative Reasoning
 *
 * Scenario: Reconciling transaction counts and fee totals
 * Rule:     x + y = 10; 2x + 3y = 26
 *
 * Try it:   What if both equations are identical?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/linear-equations-and-systems/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson007() {
  const lowFee = 2, highFee = 3, totalCount = 10, totalFees = 26;
  const det = highFee - lowFee; // determinant of [[1, 1], [lowFee, highFee]]
  if (det === 0) throw new Error("Equations are not independent");
  const highFeeCount = (totalFees - lowFee * totalCount) / det;
  const lowFeeCount = totalCount - highFeeCount;
  if (lowFee * lowFeeCount + highFee * highFeeCount !== totalFees)
    throw new Error("Solution fails verification");
  const result = {lowFeeCount, highFeeCount};
  return result;
}

export const checkedResult = {"lowFeeCount":4,"highFeeCount":6};

// Run this file directly: npx tsx lessons/01-mathematical-language-and-quantitative-reasoning/007-linear-equations-and-systems.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson007(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

{
  "lowFeeCount": 4,
  "highFeeCount": 6
}

Prefer your own machine? Every file is in the course repository · open it in Codespaces.

Lesson notes

The rule

x + y = 10; 2x + 3y = 26