← All topics

algorithms

2 captures, most recent first.

@thomasahle

— saved image

Thomas Ahle @thomasahle · Sep 11
Compute Polynomials Twice as Fast -
Here's a fun result, done entirely without AI.

That because we proved it years ago, but it ran a hundred pages and we weren't quite sure enough to publish. Now AI verified it in Lean.

A fun fact about polynomials is that
P(x) = x⁴ + a₃x³ + a₂x² + a₁x + a₀
can be evaluated in just two(!) multiplications!

The trick is to write
y = (x + b₀)x + b₁
P(x) = (y + x + b₂)y + b₃
where b₀...b₃ are easy to calculate from a₀...a₃.

Polynomials are everywhere from computing exp/sin, to cryptographic hashes and codes. Over finite fields multiplications are particularly expensive, so a 2x speedup matters.

Donald Knuth and others showed ~n/2 multiplications suffice for any degree n, but their preprocessing needs complex roots: numerically unstable and useless over finite fields. Rabin & Winograd fixed that with rational preprocessing, but 2logn extra multiplications, which hurts at the small n we most care about.

Our new method solves this. It uses ⌈(n+1)/2⌉ multiplications, and we prove this is optimal.

You can try it out on your own polynomials at
thomashale.com/fast-polynomia… [cut off]
Note from Claude Sonnet 5

Long X post by Thomas Ahle announcing a result on evaluating polynomials with roughly half as many multiplications (ceil((n+1)/2), proven optimal), with a worked quartic example; says the proof was long and was only now verified in Lean by AI.

polynomial evaluationalgorithmsleanformal verificationai in mathematicsknuth

Sauers @Sauers_

Sauers @Sauers_ · 1h Claude communicating with Codex. Both AIs understand each other, but I don't [Embedded screenshot of dense technical text — an algorithmic/genomics-style plan:] 1. ELIMINATE the forward replay loop (the 'while m < block_end' loop that calls forward_update_impl + store_fwd_history for each marker). This is no longer needed. 2. ELIMINATE the fwd_history storage for non-checkpoint markers. 3. For each block between checkpoints L and R: a. Load fwd_L from checkpoint (already done) b. bwd_R is the current backward state (already available) c. Pre-compute backward affine coefficients for each marker position in the block by iterating from R-1 to L+1: - Use f64 for stability (like batched_transition_forward does) - a_bwd[m] and b_coeff_bwd[m] composed from transition params, same formula as batched_transition_backward - Store these in small scratch vectors (block_len is typically ~200) d. Walk forward through untyped markers in the block, maintaining (a_fwd: f64, b_fwd: f64) incrementally: - a_fwd *= stay; b_fwd = stay * b_fwd + shift (same as batched_transition_forward) e. At each untyped marker m, compute the posterior dosage in a SINGLE O(K) loop: - refresh_ref_alleles (unavoidable - need to know each state's allele) - Accumulate per-allele sums: for each state i, compute contribution using: gamma_i = (a_fwd * fwd_L[i] + b_fwd) * (a_bwd * bwd_R[i] + b_bwd_coeff * bwd_sum_R) Add gamma_i to the appropriate allele bucket - Normalize to get allele posteriors - Handle multiallelic, missing alleles (255), and prior smoothing the same way as current code f. At checkpoint markers (non-uniform), keep the existing full emission-based posterior computation using the stored checkpoint forward state and current backward state.
Note from Claude Sonnet 5

A tweet joking about two AI coding assistants (Claude and OpenAI Codex) exchanging highly technical, jargon-dense algorithmic instructions (appears to be genotype imputation / HMM forward-backward algorithm code) that the human observer can't follow. Illustrates AI-to-AI technical communication and the growing opacity of AI-generated engineering discussion to humans.

twitterclaudecodexai codingmulti-agenttechnical opacitygenomicsalgorithms