❌

Normal view

There are new articles available, click to refresh the page.
Today β€” 14 September 2026Cryptocurrency

Programming Math for Vibe Coders.

14 September 2026 at 06:54

Programming Math for Vibe Coders MojoΒ Edition

Introduction

Leslie Lamport has long argued that programming is not simplyΒ coding.

Before writing code, we first need to think precisely about what the program should do and how it shouldΒ behave.

That distinction matters even more in the age of AI-assisted programming.

A coding agent can generate Mojo, Python, Rust, Solidity, JavaScript, or almost any other language inΒ seconds.

But it still needs a precise description of the problem it shouldΒ solve.

This is where mathematics becomes incredibly useful.

Mathematics gives us a compact language for expressing relationships, constraints, quantities, state, and behaviour without committing ourselves to a particular programming language.

For many learnersβ€Šβ€”β€Šand yes, vibe coders, I’m calling you out hereβ€Šβ€”β€Šthe difficult part isn’t necessarily understanding code.

It’s learning how to moveΒ between:

Idea β†’ Mathematical Model β†’ Algorithm β†’Β Code

In this article, we’ll explore that process using Mojo πŸ”₯, a statically typed systems programming language with Python-like syntax.

The mathematical ideas themselves are independent ofΒ Mojo.

You can translate them into almost any programming language.

That is one of the beautiful things about approaching software mathematically:

The model survives even when the implementation languageΒ changes.

Knowledge TransferΒ Guide

Translating Math to Mojo: CheatΒ Sheet

Summation

βˆ‘ β†’ accumulation using a loop andΒ +=

Product

∏ β†’ repeated multiplication using a loop andΒ *=

Mathematical bounds

i = 1 … n β†’ range(1, n +Β 1)

Indexed values

xα΅’ β†’ values[i]

Functions

f(x) β†’ def f(x: Type) ->Β Type:

Real numbers

ℝ β†’Β Float64

Integers

β„€ β†’Β Int

Sequences

x₁, xβ‚‚, …, xβ‚™ β†’Β List[T]

Infinite sums

∞ β†’ approximate using a finite number ofΒ terms

One important detail:

Mathematical ranges are commonly inclusive.

For example:

1 ≀ k ≀ n

In Mojo, range() follows Python-style half-open ranges.

So:

range(1, n + 1)

represents:

1, 2, 3, …,Β n

This small difference is exactly the kind of bug mathematical thinking can help usΒ catch.

Factorial: From ∏ to a Loop

Mathematical Definition

n! = ∏ from k = 1 to n of k

In expandedΒ form:

n! = 1 Γ— 2 Γ— 3 × … Γ—Β n

Mojo Implementation

def factorial(n: Int) raises -> Int:
if n < 0:
raise Error("Factorial is not defined for negative numbers.")
var result: Int = 1
for k in range(1, n + 1):
result *= k
return result

Explanation

The mathematical expression:

∏ from k = 1 to n of k

contains three pieces of information.

The variable:

k

becomes our loop variable.

The bounds:

1 ≀ k ≀ n

become:

range(1, n + 1)

And theΒ product:

∏

becomes:

result *= k

Something subtle is also happening here.

We initialise:

var result: Int = 1

Why 1?

Because 1 is the identity element for multiplication:

1 Γ— x =Β x

For addition, the identity element isΒ 0:

0 + x =Β x

So a summation accumulator normally starts atΒ 0.

For multiplication:

1 Γ— x =Β x

So a product accumulator starts atΒ 1.

Our implementation also correctly handles:

0! =Β 1

When n = 0, the loop executes zero times and result remainsΒ 1.

This gives us a useful programming principle:

The initial value of an accumulator often comes directly from the mathematics of the operation.

A Mojo-Specific Observation

Unlike Python integers, Mojo’s standard Int integers represent a finite machineΒ integer.

That means sufficiently large factorials will eventually exceed what the type can represent.

The mathematics hasn’tΒ changed.

The representation has.

This gives us another important rule:

Mathematical correctness and representation correctness are not always the sameΒ thing.

Approximating e Using an InfiniteΒ Series

Mathematical Definition

Euler’s number can be definedΒ as:

e = βˆ‘ from n = 0 to ∞ of 1 /Β n!

Expanded:

e = 1 + 1 + 1/2! + 1/3! + 1/4! + …

A computer cannot normally execute an infinite number of operations.

So instead we calculate a finite approximation:

e β‰ˆ βˆ‘ from n = 0 to N βˆ’ 1 of 1 /Β n!

Mojo Implementation

def approximate_e(terms: Int = 12) raises -> Float64:
if terms < 1:
raise Error("terms must be at least 1")
var total: Float64 = 1.0
var term: Float64 = 1.0
for n in range(1, terms):
term /= Float64(n)
total += term
return total

Explanation

We could calculate every factorial independently.

But the mathematics gives us a better algorithm.

We know:

n! = n Γ— (n βˆ’Β 1)!

Therefore:

1 / n! = (1 / n) Γ— (1 / (n βˆ’Β 1)!)

This means you can calculate each new term from the previousΒ one.

Instead of repeatedly calculating:

1!, 2!, 3!, 4!, …

we simplyΒ write:

term /= Float64(n)

Then accumulate it:

total += term

This is an important lesson:

Mathematics does not merely describe the answer. It can reveal a better algorithm.

Calculating anΒ Average

Mathematical Definition

For values:

x₁, xβ‚‚, …,Β xβ‚™

the arithmetic meanΒ is:

xΜ„ = (1 / n) Γ— βˆ‘ from i = 1 to n ofΒ xα΅’

In plain language:

average = sum of all values/number ofΒ values

Mojo Implementation

def average(values: List[Float64]) raises -> Float64:
if len(values) == 0:
raise Error("Average is undefined for an empty collection.")
var total: Float64 = 0.0
for i in range(len(values)):
total += values[i]
return total / Float64(len(values))

Explanation

The mathematical summation:

βˆ‘ xα΅’

becomes an accumulator:

var total: Float64 = 0.0

followed by:

for i in range(len(values)):
total += values[i]

Then:

1 /Β n

becomes:

total / Float64(len(values))

Notice the explicit conversion:

Float64(len(values))

len(values) gives us anΒ integer.

Our calculation produces a floating-point result.

The code therefore states the numerical representation explicitly.

This is one place where Mojo’s type system makes mathematical intent moreΒ visible.

The Empty Collection Problem

Suppose:

n =Β 0

Our formula would require division byΒ zero.

So the average of an empty collection is undefined.

This would therefore be misleading:

if len(values) == 0:
return 0.0

Zero is not the average of an empty collection.

There simply is noΒ average.

So instead weΒ use:

raise Error("Average is undefined for an empty collection.")

Another useful ruleΒ follows:

Edge cases should follow the mathematical definition, not whatever value is convenient for the implementation.

Computing Variance

Variance measures how far values tend to spread from theirΒ mean.

First calculate theΒ mean:

ΞΌ = (1 / n) Γ— βˆ‘ from i = 1 to n ofΒ xα΅’

Then calculate the population variance:

σ² = (1 / n) Γ— βˆ‘ from i = 1 to n of (xα΅’ βˆ’Β ΞΌ)Β²

Mojo Implementation

def variance(values: List[Float64]) raises -> Float64:
if len(values) == 0:
raise Error("Variance is undefined for an empty collection.")
var total: Float64 = 0.0
for i in range(len(values)):
total += values[i]
var mean = total / Float64(len(values))
var squared_difference_sum: Float64 = 0.0
for i in range(len(values)):
var difference = values[i] - mean
squared_difference_sum += difference * difference
return squared_difference_sum / Float64(len(values))

Translating theΒ Equation

Take thisΒ part:

(xα΅’ βˆ’Β ΞΌ)Β²

The currentΒ value:

xα΅’

becomes:

values[i]

Subtract theΒ mean:

xα΅’ βˆ’Β ΞΌ

becomes:

var difference = values[i] - mean

Square the difference:

(xα΅’ βˆ’Β ΞΌ)Β²

becomes:

difference * difference

The summation:

βˆ‘ (xα΅’ βˆ’Β ΞΌ)Β²

becomes:

squared_difference_sum += difference * difference

And finally divide byΒ n:

squared_difference_sum / Float64(len(values))

Population Variance vs SampleΒ Variance

Small mathematical differences matter.

Population varianceΒ uses:

σ² = (1 / n) Γ— βˆ‘(xα΅’ βˆ’Β ΞΌ)Β²

Sample variance usuallyΒ uses:

sΒ² = (1 / (n βˆ’ 1)) Γ— βˆ‘(xα΅’ βˆ’Β xΜ„)Β²

The implementation difference may appearΒ tiny.

Population:

Float64(len(values))

Sample:

Float64(len(values) - 1)

But mathematically these represent different quantities.

This is exactly why specification matters.

A coding agentΒ told:

Calculate variance.

has to make assumptions.

A coding agentΒ given:

σ² = (1 / n) Γ— βˆ‘(xα΅’ βˆ’Β ΞΌ)Β²

has much less room toΒ guess.

The BiggerΒ Lesson

At first these examples may lookΒ simple.

∏ becomes multiplication inside a loop.

βˆ‘ becomes accumulation.

xα΅’ becomes an indexedΒ value.

f(x) becomes a function.

But a more important idea underlies all ofΒ this.

We are learning to move through fourΒ layers:

Problem β†’ Mathematical Model β†’ Algorithm β†’Β Code

Most vibe coding jumps directlyΒ from:

Problem β†’ AI-Generated Code

That works surprisingly often.

Until itΒ doesn’t.

The problem is ambiguity.

Natural language mightΒ say:

Execute when everyoneΒ agrees.

We can express that more precisely.

Let:

P = {p₁, pβ‚‚, …,Β pβ‚™}

represent all participants.

Let:

A βŠ†Β P

represent the participants who have accepted.

Then we canΒ define:

Ready(I) ⇔ A =Β P

In plain language:

The intent is ready exactly when the set of accepting participants equals the set of required participants.

Now addΒ time:

Ready(I) ⇔ A = P AND t < expiry(I)

Now we have expressed two requirements:

  1. Everyone mustΒ accept.
  2. The intent must not haveΒ expired.

An AI coding agent can translate that into Mojo, Solidity, Rust, Python, TypeScript, or another language.

The implementation language canΒ change.

The specification remains.

From Vibe Coding to Specification

This suggests a different way of thinking about AI-assisted software development.

Instead of:

Natural Language β†’ Generated Code

we canΒ use:

Natural Language β†’ Mathematical Intent β†’ Specification β†’ Generated Code β†’Β Tests

The goal isn’t necessarily for every programmer to become a mathematician.

The goal is to understand enough mathematical language to describe software behaviour precisely.

Because the future skill may not be memorising every programming language’s syntax.

It may be something more fundamental:

Learning to express intent precisely enough that humans, machines, and proofs agree on what the program is supposed toΒ do.


Programming Math for Vibe Coders. was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.

Margrethe Vestager calls for balanced EU AI funding model to close compute gap with US and China

14 September 2026 at 06:51

Europe's AI funding strategy aims to boost competitiveness and sovereignty, reducing reliance on US and China by enhancing infrastructure.

The post Margrethe Vestager calls for balanced EU AI funding model to close compute gap with US and China appeared first on Crypto Briefing.

Yesterday β€” 13 September 2026Cryptocurrency

Zhipu AI raises $4B in follow-on share placement, then announces another $5B round weeks later

13 September 2026 at 20:19

Zhipu AI's aggressive capital raising highlights the growing investor confidence in AI, despite geopolitical tensions and market volatility.

The post Zhipu AI raises $4B in follow-on share placement, then announces another $5B round weeks later appeared first on Crypto Briefing.

Artificial Analysis becomes official evaluation partner for South Korea’s sovereign AI project

13 September 2026 at 19:16

South Korea's partnership with Artificial Analysis enhances transparency and credibility in its AI strategy, potentially boosting global competitiveness.

The post Artificial Analysis becomes official evaluation partner for South Korea’s sovereign AI project appeared first on Crypto Briefing.

AI agents are quietly dropping compliance rules, and bigger context windows won’t fix it

13 September 2026 at 14:05

AI's compliance dilution in complex tasks necessitates external enforcement, reshaping competitive advantages toward robust governance solutions.

The post AI agents are quietly dropping compliance rules, and bigger context windows won’t fix it appeared first on Crypto Briefing.

Blackstone builds dedicated AI investment unit in San Francisco with $150B already deployed

13 September 2026 at 10:06

Blackstone's AI focus in San Francisco signals a shift towards large-scale, collaborative investments, reshaping tech infrastructure financing.

The post Blackstone builds dedicated AI investment unit in San Francisco with $150B already deployed appeared first on Crypto Briefing.

❌
❌