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

Summation, Products, and Index Notation

A ledger sum and a return product are different loops.

2:33 clip21:21–23:54 in the full courseWatch on YouTube

Transcript

24 sentences · select one to jump there

Check your understanding

Why does a product accumulator start at one?

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.

006-summation-products-and-index-notation.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 006 of 120
 * Summation, Products, and Index Notation
 * Module 01: Mathematical Language and Quantitative Reasoning
 *
 * Scenario: A ledger sum and a return product are different loops
 * Rule:     Σ cash flows; Π growth factors
 *
 * Try it:   Why does a product accumulator start at one?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/mathematical-language-and-quantitative-reasoning/summation-products-and-index-notation/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson006() {
  const flows = [100, -30, 20];
  const returns = [0.10, -0.10];
  const cash = flows.reduce((a, x) => a + x, 0);
  const growth = returns.reduce((a, r) => a * (1 + r), 1);
  const result = {cash, cumulativeReturn: growth - 1};
  return result;
}

export const checkedResult = {"cash":90,"cumulativeReturn":-0.009999999999999898};

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

Your output

Press Run to execute the code in your browser.

Expected output

{
  "cash": 90,
  "cumulativeReturn": -0.009999999999999898
}

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

Lesson notes

The rule

Σ cash flows; Π growth factors