Skip to content

Language Shootout

A user-supported site Fastest, Shortest, Simplest

Benchmarks

Spectral Norm

Background

MathWorld: "Hundred-Dollar, Hundred-Digit Challenge Problems", Challenge #3.

Thanks to Sebastien Loisel for suggesting this task.

How to implement

We ask that contributed programs not only give the correct result, but also use the same algorithm to calculate that result.

Each program should:

  • Calculate the spectral norm of an infinite matrix A, with entries a₁₁=1, a₁₂=1/2, a₂₁=1/3, a₁₃=1/4, a₂₂=1/5, a₃₁=1/6, etc
  • Implement 4 separate functions / procedures / methods like the C# program

Verification: Use diff to compare program output N=100 with the reference output.

Use a larger command line argument (5500) to check program performance.

Times are wall-clock milliseconds, with this implementation’s hello-world startup time subtracted. gz is the source in bytes with comments removed and gzipped. style is the idiomatic-code score. Click a heading to sort.

# source ms cpu ms mem KB gz style by
1 Swift #1 1,521.6 1,512.8 17,384 431 ★★★★☆ sysop-
2 Kotlin JVM #1 1,043.4 1,082.7 46,600 519 ★★☆☆☆ sysop-