Mathematica Benchmarktest 
(Version 2)
created 15th of March 1998 by Stefan Steinhaus

Note 1 : Version 2 of this benchmark test became necessary since the old version was old-fashioned and the timings were too low to be used seriously. Also this benchmark test doesn't only test more time intensive functions but also more different types of functions.
Please use this benchmark test only in connection with Mathematica 3.0 or higher.
Note 2 : Due to a lack of memory it could be possible that on some machines the notebook couldn't be evaluated at once, it might be necessary to evaluate some test functions manually afterwards.

$HistoryLength = 3;

Integer Computations

Simple mathematics

Timing[50001!; ]

Number Theory

Computation of the first 100000 prime numbers

The following function computes a table with the first 100000 prime numbers and displays the timing for it.

Timing[Table[Prime[i], {i, 100000}]; ]

Computation of the first 5000 Fibonacci numbers

The following function computes a table with the first 5000 Fibonaci numbers by using the golden ratio method and displays only the timing.

Timing[Table[Fibonacci[j], {j, 1, 5000}]; ]

Linear Algebra

Computation of a 600x600 Toeplitz matrix

The following function computes a 600x600 Toeplitz matrix, a special diagonal form of an integer matrix. Afterward the timing of this computation will be displayed.

Timing[Table[Abs[x - i] + 1, {i, 1, 600}, {x, 1, 600}]; ]

Floating Point Computations

Simple mathematics

The following functions calculates Pi on 50000 digits behind the comma and displays the timing for it.

Timing[N[Pi, 50000]; ]

Linear Algebra

Computation of the inverse of a 400x400 matrix

The following function creates a 400x400 random matrix, computes the inverse of it and displays the timing of the whole computation.

Timing[Inverse[Table[Random[Real], {400}, {400}]]; ]

Computation of Eigenvalues of 400x400 matrix

The following function computes a 400x400 random matrix, computes the Eigenvalues and prints out the time for it.

First[Timing[Eigenvalues[Table[Random[], {400}, {400}]]]]

Analysis

Numerical computation of a double integral

Timing[
      N[Integrate[
          Sin[x^2  +  y^2], {x, -2 Pi, 2  Pi}, {y, -2 Pi, 2  Pi}]]]

Symbolic Computations

Computation of a Laplace transformation

<< Calculus`LaplaceTransform`

\(Timing[
      LaplaceTransform[Cos[d\ Sqrt[a\ t]^5], \ t, \ s, 
\ 
        DefiniteIntegral -> True]; ]\)

Solving of the Euler-McLaurin summation formula

The following function computes the symbolic integral of the summation formula after Euler-McLaurin.

f[s_] := 
      (((2 p - 1) (p^h))/((p^(h + 1)) - 
          (1 - 2 p) (((1 - p))^s)))

Timing[
      (∫_0^(h - 1))f[s] \[DifferentialD]s + 
        0.5 (f[0] + f[h - 1]) + 
        (∫_0^(h - 1))(s - s - 0.5) (∂_s) f[s] 
            \[DifferentialD]s]

Graphics

2D Graphics

Computation of a Koch Snowflake

The boundary of the Koch Snowflake constructed by Helge Von Koch in 1904 is the union of three congruent self-similar fractals.  Each third of the snowflake is constructed by starting with one side of an equilateral triangle and performing an iterative process.  The following cell defines a function called Snowflake that illustrates the stages in this iterative process.

Programmcode

(*  \(Given\ a\ non - negative\ integer\ n, \ the\ function\ 

          \ \ \ \ Snowflake\ generates\ the\ nth\ level\ approximation\ 

          \ \ \ \ 
          to\ the\ Koch\ Snowflake.\ Code\ from\ the\ Notices\ of\ 

          \ \ \ \ the\ AMS\ Vol .39\ #7\ Sept\ 92, \ page\ 709\)              *)
    
Clear[n, Snowflake, start, finish, doline]\(Snowflake[n_Integer?NonNegative] := 
\ \ 
        Show[Graphics[
\ \ \ \ 
            Nest[\ \((#1 /. 
                    Line[{start_, finish_}]\  :> 
                      doline[start, 
\ \ \ \ \ \ \ \ \ \ \ \ \ finish])
                  \)\ &, 

              \ \ \ \ \ \ \ \ \ \ {Line[{{0, 0}, {1/2, Sqrt[3]/2}}], 

                \ \ \ \ \ \ \ \ \ \ \ Line[{{1/2, Sqrt[3]/2}, {1, 0}}], 

                \ \ \ \ \ \ \ \ \ \ \ Line[{{1, 0}, {0, 0}}]}, 

              \ \ \ \ \ \ \ \ \ \ n]], 
\ \ \ AspectRatio -> Automatic, 
          PlotRange -> All]\)
\(doline[start_, finish_] := 
\ \ 
      Module[{vec, normal}, 
\ \ vec = finish - start; 
\ \ 
        normal = Reverse[vec]\ {\(-1\), 1}\ Sqrt[3]/6; 

        \ \ {Line[{start, start\  + \ vec/3}], 
\ \ 
          Line[{start\  + \ vec/3, start\  + \ vec/2\  + \ normal}], 
\ \ 
          Line[{start\  + \ vec/2\  + \ normal, \ start\  + \ 2\ vec/3}], 

          \ \ Line[{start\  + \ 2\ vec/3, \ finish}]
\ \ }
\ \ ]; \)

Computation for 5 flakes

Timing[Snowflake[5]]

3D Graphics

Klein Bottle

Displays the time for a high resolution Klein Bottle.

\(bx = 6\ Cos[u]\ \((1 + Sin[u])\); 
by = 16\ Sin[u]; 

    rad = 4\ \((1 - Cos[u]\/2)\); 

    X = If[π < u ≤ 2\ π, bx + rad\ Cos[v + π], 
        bx + rad\ Cos[u]\ Cos[v]]; 

    Y = If[π < u ≤ 2\ π, by, by + rad\ Sin[u]\ Cos[v]]; 

    Z = rad\ Sin[v]; \)

Timing[
      ParametricPlot3D[{X, Y, Z}, {u, 0, 2 π}, {v, 0, 2 π}, 
        PlotPoints -> {60, 60}, Axes -> False, Boxed -> False, 
        ViewPoint -> {1.4, -2.6, -1.7}]; ]

Parametric plot of 3 pipes

Timing[
      ParametricPlot3D[{{Sin[t], u, Cos[t]}, {Sin[t], Cos[t], u}, {u, Sin[t], 
            Cos[t]}}, {t, -Pi, Pi}, {u, -Pi, Pi}, PlotPoints -> 40]]

Animations

3D Mountain in heatcolors

<< Graphics`Animation`<< Graphics`Graphics3D`

\(Timing[
      Animate[ShadowPlot3D[\ Exp[\(-z\)*\((x^2\  + \ y^2)\)], 

          \ \ \ \ \ \ \ \ \ \ \ \ \ {x, \ \(-2\), \ 2}, \ {y, \ \(-2\), \ 2}, 
          
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ShadowPosition\  -> \ 1], {z, 0.1, 
          1, 0.01}]]\)