Writing an eigenvalue solver in Rust for WebAssembly

https://news.ycombinator.com/rss Hits: 3
Summary

2025.12.31Writing an eigenvalue solver in Rust for WebAssemblyI recently stumbled across the Gershgorin Circle Theorem and thought it was perfectly suited to an interactive visualisation:The problem is I鈥檓 no web developer, and I don鈥檛 really like JavaScript. So, the eigenvalue computation in the interactive component above is written in Rust, compiled to WebAssembly, and wrapped up with some HTML and JavaScript. As the old mathematics adage goes: if you can鈥檛 solve the base problem, turn it into multiple problems.Since I鈥檝e been looking for a project to start learning Rust with, I figured this鈥檇 make for a great learning opportunity. In the spirit of learning in the open we鈥檙e going to step through how to put this together, and what I learned along the way. There鈥檒l be lots of open questions on my end - I nearly didn鈥檛 publish this post as I was distracted by chasing up the answers to all my questions. But I figured it鈥檚 equally important to pause and compile everything together for posterity.Disclaimer: This post and the Rust code was written by myself, in consultation with lecture notes and reference implementations from other languages. References are linked inline. An LLM was used to produce the HTML, CSS, and JavaScript code for the component. All mistakes are, as always, my own.First, let鈥檚 set ourselves up with some maths.# The Gershgorin Circle TheoremThe Gershgorin Circle Theorem is a neat little theorem that allows you to bound the region of the complex plane that matrix eigenvalues live in, essentially just by inspection.Let $A$ be a square matrix with complex entries. We define the Gershgorin circles as follows:For each row $i$ of the matrix, let the centre $c_i$ be the diagonal element $a_{ii}$. The radius $r_i = \sum_{j \neq i} |a_{ij}|$ is the sum of the norms of the off-diagonal elements in that row.The Gershgorin circle $D(c_i, r_i)$ is the set of complex numbers $z$ such that $|z - c_i| \leq r_i$.Gershgorin Circle Theorem: every eigenvalue of $A$ ...

First seen: 2026-01-06 22:39

Last seen: 2026-01-07 00:40