Skip to content

Instantly share code, notes, and snippets.

@joewagner
Created October 10, 2022 15:05
Show Gist options
  • Save joewagner/85d12f6df995111c672f0c868408af9a to your computer and use it in GitHub Desktop.
Save joewagner/85d12f6df995111c672f0c868408af9a to your computer and use it in GitHub Desktop.
Javascript Muller Kahan
// This is a test designed by muller and kahan that demonstrates how
// the calculation of a known convergence returns incorrectly because
// of the mathematics of floating point numbers
const max = 21
let u = 2.0;
let v = -4.0;
let w;
for (let i = 3; i < max; i++) {
w = 111.0 - 1130.0/v + 3000.0/(v*u);
u = v;
v = w;
}
console.log(v);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment