Dieses Beispiel ist ziemlich voraussetzungsvoll. Es implementiert einen Algorithmus zur näherungsweisen Berechnung des Werts einer Reihe. Zur Konvergenzbeschreunigung wird eine Folgentransformation, nämlich die Eulersche Reihentransformation, verwendet.
BEGIN COMMENT * Beispiel 11.5 des Revised Report: * Euler summation COMMENT PROC euler = (PROC (INT) REAL f, REAL eps, INT tim) REAL : COMMENT * the sum for 'i' from 1 to infinity of 'f(i)', computed * by means of a suitable refined Euler transformation. * The summation is terminated when the absolute values of * the terms of the transformed series are found to be * less than 'eps' 'tim' times in succession. This * transformation is particularly efficient in the case of * a slowly convergent or divergent alternating series. COMMENT BEGIN INT n := 1, t; REAL mn, ds := eps; [1:16] REAL m; REAL sum := (m[1] := f(1))/2; FOR i FROM 2 WHILE (t := (ABS ds < eps | t + 1 | 1)) <= tim DO mn := f(i); FOR k TO n DO mn := ((ds := mn) + m[k])/2; m[k] := ds OD; sum +:= (ds := (ABS mn < ABS m[n] AND n < 16 | n +:= 1; m[n] := mn; mn/2 | mn ) ) OD; sum END; COMMENT * calls using euler: COMMENT print((euler((INT i) REAL : (ODD i | -1/i | 1/i), 1.0e-5, 2) , newline)); SKIP END
...