 A framework is presented to compute approximations of an integral I(f)=∫_a^b f(x) dx from a pair of companion rules and its associate rule. We show that an associate rule is a weighted mean of two companion rules. In particular, the trapezoidal (T) and Simpson (S) rules are weighted means of the companion pairs (L,R) and (T,M) respectively, with L the left rectangle, R the right rectangle and M the midpoint rules. As L,R,T and M reproduce exactly the number π=∫_0^π 2 sin^2(x) dx, we named them the four "beautiful" rules. For this example the geometrical interpretation of the rules suggest possible applications of the transcendental number π in architectural design, justifying the attribute beautiful given to the mentioned rules. As a complement we consider other appropriate integrand functions f, applying composite rules in order to obtain good approximations of π, as shown in the worked numerical examples.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

From the antiquity to Newton  and Gauss  times, and from Gauss to nowadays a great amount of ingenious work to approximate an integral took place giving rise to a plethora of quadrature rules , , , , , , , . We will restrict the discussion to the simplest quadrature rules, known as left rectangle (L), right rectangle (R), midpoint (M) and trapezoidal (T). We call them the four ‘beautiful’ rules since all exactly reproduce the number , as shown in a worked example (see Section 4 and Figures 1, 2 and 3), and the respective geometrical interpretation suggests an application of this transcendental number in architectural design.

After defining two main types of rules, the Taylor and interpolatory ones, we assign a sign to a rule (Definition 2.2). From a pair of basic rules – with opposite errors and the same degree of precision – hereafter called companion rules, we construct another rule, which will be called as associate rule. In particular, we show that the trapezoidal rule is the associate rule to the pair (L,R), and the famous Simpson’s rule is the associate rule to the pair (M,T).

Similar (elementar) approach can be applied to other well known sets of quadrature rules, namely to certain pairs of closed and open Newton–Cotes rules , but we keep our discussion restricted to a small set of simpler rules.

The consideration of companion rules enables the construction of a nest of intervals where it lies the exact value . Thus, one automatically obtain error bounds for a triple of rules (X,Y,Z) where X and Y are companion rules and is the respective associate rule.

Under mild assumptions, we show that the expression of an associate rule is a weighted mean, with positive weights, of its companion rules. Therefore, the value of an associate rule can be obtained by this mean rather than from the explicit expression of the associate rule. For instance, denoting by the value obtained by a rule , one may compute the value of Simpson’s rule by a certain weighted mean of and , and consequently to be sure that in the interval , or , lies not only but also the value of the integral , whenever is a pair of companion rules.

The main features of our framework are illustrated by some examples given in Section 4.

## 2 Taylor and interpolatory rules

Firtsly, we recall the notion of a quadrature rule. Let be a sufficiently smooth functions on the interval . For , consider the linear space of all polynomials of degree .

###### Definition 2.1.

A quadrature rule is an approximation of the integral obtained using values of (and/or its derivatives) on a discrete set of points in .

For the sake of simplicity we occasionally denote the functional simply by .

The two types of quadrature rules to be considered in this work are Taylor and interpolatory rules, which we briefly review.

### Taylor’s rules

Let be an integer, , and assume that . The function can be written as the sum of the Taylor’s polynomial, centered at , and a remainder function , of the form

 f(x)=qk(x)+r(x),whereqk(x)=f(x0)+f′(x0)(x−x0)+⋯+f(k)k!(x−x0)k,andr(x)=fk+1(θ(x))(k+1)!(x−x0)k+1,θ(x)∈int(x0,x),

where the symbol denotes the open interval Integrating both sides in , we get

 I(f)=∫baqk(x)dx+∫bafk+1(θ(x))(k+1)!(x−x0)k+1dx,θ(x)∈int(x0,x) . (1)

Assuming that the second term of the sum in (1) is not null, we call Taylor’s rule of order to

 Tk(f)=∫baqk(t)dt. (2)

Thus, the error of is

 ETk(f)=I(f)−Tk(f)=∫bafk+1(θ(t))(k+1)!(t−x0)k+1dt. (3)

#### Degree of a rule

By construction, a Taylor’s rule is exact when is a polynomial belonging to , that is the respective error is null. This is the reason why we say that is a rule of degree of precision at least . When a rule of degree at least is not exact for a monomial of we say that the rule has degree (of precision) , according to the following definition.

###### Definition 2.2.

(Degree of a quadrature formula) (, p. 157)

We say that a quadrature rule has degree (of precision) if the rule is exact for any polynomial , but it is not exact for a monomial of degree .

### Interpolatory rules

Given distinct nodes in , say , consider the table of values . It is well known that there exists a unique polynomial interpolating the table. Assuming that , we have

 f(x)=pk(x)+R(x) (4)

and there exists , such that

 R(x)=f(k+1)(θ(x))(k+1)!(x−x0)(x−x1)⋯(x−xk) .

Integrating both sides of (4) we obtain

 I(f)=∫bapk(x)dx+∫baR(x)dx .

Assuming that , we call

 Ak(f)=∫bapk(t)dt (5)

an interpolatory rule of order . The error of is given by

 EAk(f)=I(f)−Ak(f)=∫baf(k+1)(θ(t))(k+1)!(t−x0)(t−x1)⋯(t−xk)dt . (6)

Comparing the error formulas (3) and (6) it is clear that it is easier to deal with the former. This is the reason why it seems more natural to start discussing quadrature rules by the Taylor type ones.

Whenever is a polynomial of degree , both rules in (2) and in (5) are exact. In both cases the expressions of their errors exhibit the -th derivative of , and there exist nonzero constants such that

 ETm(f)=α1f(m+1)(ξ1)(m+1)!,ξ1∈(a,b)EAm(f)=α2f(m+1)(ξ2)(m+1)!,ξ2∈(a,b) . (7)

We are interested in guaranteeing that the derivatives in an error formula do not change sign in , which lead us to consider the following assumptions.

 \bf Assumption A:sign(f(m+1)(x))=1or−1,∀x∈[a,b] (8)

or

 \bf Assumption B:sign(f(m)(x)−f(m)(y))=1% or−1,∀x,y,∈[a,b]. (9)

When a function satisfies Assumption A, the sign of the errors of or depends only on the sign of the constants or in (7). This justifies the following definition of positive or negative rule.

###### Definition 2.3.

Let be a quadrature rule of degree , satisfying Assumption A in (8), such that the respective error is of the form

 EQm(f)=αf(m+1)(ξ),α≠0,ξ∈(a,b) .

The rule is positive (resp. negative) if (resp. ).

A pair of rules of the same degree having errors of opposite signs are particularly interesting. Such rules will be called companion rules.

###### Definition 2.4.

(Companion rules)

Two rules and , of the same degree , having opposite signs are called companion rules.

From the error formulae of two companion rules one can deduce not only a new rule, which we call associate rule, but also its error expression as follows.

Without loss of generality assume that the rule is positive and the companion rule is negative. Concerning Taylor and interpolatory rules, there are positive integers and such that the respective error in (7) can be written as

 EXm(f)=1d1(b−a)m+2f(m+1)(ξ1),ξ1∈(a,b) (10)
 EYm(f)=−1d2(b−a)m+2f(m+1)(ξ2),ξ2∈(a,b) . (11)

Thus, adding (10) and (11) and simplifying we obtain

 I(f)=d1Xm(f)+d2Ym(f)d1+d2++(b−a)m+2d1+d2(f(m+1)(ξ1)−f(m+1)(ξ2)),ξ1,ξ2∈(a,b) . (12)

### Associate rule

The sum in (12) shows that we can define a new rule, say , by

 Mm(f)=d1Xm(f)+d2Ym(f)d1+d2,

and the respective error is given by

 EMm(f)=(b−a)m+2d1+d2(f(m+1)(ξ1)−f(m+1)(ξ2)),ξ1,ξ2∈(a,b) . (13)

Dividing the natural numbers and by its great common divisor, we obtain

 Mm(f)=c1Xm(f)+c2Ym(f)c1+c2, (14)

where

 c1=d1/gcd(d1,d2)andc2=d2/gcd(d1,d2) . (15)

Thus, the rule given by (14) is a weighted mean of the companion rules and . The weights and are irreductible positive rational numbers. We call the associate rule to the pair . Since such a weighted mean of the two real numbers lies between these numbers, the following inequalities holds,

 min{Xm(f),Ym(f)}≤Mm(f)≤max{Xm(f),Ym(f)} .

## 3 Basic companion and associate rules

 “The material equipment essential for a student’s mathematical laboratory is very simple. Each student should have a copy of Barlow’s tables of squares, etc., a copy of Grelle’s “Calculating Tables” and a seven place table of logarithms.” (Whittaker and Robinson , p. vi).

We now show that from the three basic Taylor’s rules (left rectangle, right rectangle and midpoint rule) we can define pairs of companion rules whose associate rules are of interpolatory type, in particular the widely used trapezoidal and Simpson rules. Thus, we automatically obtain error expressions for these associate rules, as in (13), which might be compared to the ones available in the literature. Furthermore, we obtain intervals, containing the exact value of , only taking into account to the properties of the arithmetic and weighted mean of two real numbers.

Denoting by the left rectangle rule, by the right rectangle rule (both Taylor’s rules of order 0) and by the midpoint rule (Taylor’s of order 1), we show that (trapezoidal rule) and (Simpson rule) are associate rules:

 (L, R)⇝T(M, T)⇝S,

where the symbol is used to refer the associate rule to the pair of companion rules.

For the sake of completeness we show that the second order Taylor’s rule is companion to the Simpson’s rule and we obtain its associate as the weighted mean

 (T2,S)⇝Q=(3T2+2S)/5 .

The following table summarizes the main features of the companion and associate rules to be discussed in the next paragraphs.

### The associate rule of (L,r) is the trapezoidal rule T

Let and consider the node or . The zero order Taylor expansion of at gives, respectively,

 f(x)=f(a)+f′(θ1(x))(x−a),θ1(x)∈int(a,x)f(x)=f(b)+f′(θ2(x))(x−b),θ2(x)∈int(a,x) .

Integrating both sides in the above equations we obtain,

 I(f)=(b−a)f(a)+(b−a)22f′(ξ1),ξ1∈(a,b) . (16)
 I(f)=(b−a)f(b)−(b−a)22f′(ξ2),ξ2∈(a,b) . (17)

The left and right rectangle rules are implicitly defined in (16) and (17). Namely the respective expressions and errors are:

 ⎧⎪⎨⎪⎩L(f)=(b−a)f(a)EL(f)=(b−a)22f′(ξ1),ξ1∈(a,b) . (18)
 ⎧⎪⎨⎪⎩R(f)=(b−a)f(b)ER(f)=−(b−a)22f′(ξ2),ξ2∈(a,b) . (19)

The above two rules are both of degree (see Def. 2.2). Under Assumption A, the rule is positive while is negative. The constants in (10)-(11) are and then . Thus, from (14) the associate rule to the pair is the rule

 T(f)=L(f)+R(f)2=b−a2(f(a)+f(b)) . (20)

We denoted this associate rule by (instead of as in (14)) since it coincides with the well-known trapezoidal rule. This is a rule of interpolatory type with two nodes and . Using (13), the respective error formula is

 ET(f)=(b−a)24(f′(ξ1)−f′(ξ2)),ξ1,ξ2∈(a,b) . (21)

### The associate rule to (M,t) is the Simpson’s rule S

Let , and . The second order Taylor’s rule is obtained from

 f(x)=f(x0)+f+(x0)(x−x0)+f(2)(θ(x)2(x−x0)2,θ(x)∈int(x0,x) .

Integrating both sides of the above equality, we get

 I(f)=(b−a)f(a+b2)+(b−a)324f(2)(ξ1),ξ1∈(a,b) . (22)

From (22) we recover the midpoint rule ,

 M(f)=(b−a)f(a+b2), (23)

whose error is given by the expression

 EM(f)=+(b−a)324f(2)(ξ1),ξ1∈(a,b) . (24)

Recall that the error of the trapezoidal rule (, Ch. 7) can be written as

 ET(f)=−(b−a)312f(2)(ξ2),ξ1∈(a,b) . (25)

Under Assumption A, from (22) and (24), we conclude that and are respectively positive and negative and have the same degree . So, they are companion rules. The corresponding values and in (12) are , , and . Therefore the values (see (15)) are and . Thus, the associate rule to the pair is Simpson rule

 S(f)=2M(f)+T(f)3=b−a6[f(a)+f(b)+4f(a+b2)], (26)

whose error formula is (see (13))

 ES(f)=(b−a)336(f(2)(ξ1)−f(2)(ξ2)),ξ1,ξ2∈(a,b) . (27)

Since is positive, by (27) and (26), Simpson’s rule is a weighted mean of (M,T), the exact value belongs to the interval defined by the inequalities

 M(f)≤S(f)≤T(f)orT(f)≤S(f)≤M(f) .

Recall that the second expression in (26) coincides with the famous Simpson’s rule. It is worth mentioning that once computed by (22) and by (20), it is more efficient to obtain the value using the first formula in (26) rather than the second one.

In the following paragraph we need to consider the well-known error formula for Simpson’s rule. Let . We have

 ES(f)=−b−a180h4f(4)(ξ2),ξ2∈(a,b)=−(b−a)5180×24f(4)(ξ2),ξ2∈(a,b) . (28)

Thus, under Assumption A in (8), this rule in negative, and the respective degree is .

### The associate rule to (T2,s) is a corrected midpoint rule

Let and be the midpoint of the interval, i.e., . Since

 f(x)=f(x0)+f′(x0)(x−x0)+f′′(x0)/2(x−x0)2++1/6f′′′(x0)(x−x0)3+f(4)(θ(x))/4!(x−x0)4,θ(x)∈int(x0,x),

and taking into account that for any odd, the integration of both sides of the above equation, gives

 I(f)=(b−a)f(x0)+(b−a)224f′′(x0)+(b−a)51920f(4)(ξ1),ξ1∈(a,b) .

We denote by the Taylor’s rule

 T2(f)=(b−a)f(x0)+(b−a)224f′′(a+b2)=M(f)+(b−a)224f′′(a+b2) .

whose error expression is

 ET2(f)=(b−a)51920f(4)(ξ1),ξ1∈(a,b) .

Recall from (28) that the error for the Simpson rule is

 ES(f)=−(b−a)52880f(4)(ξ2),ξ2∈(a,b) .

Under Assumption A in (8), the rule is positive while is negative. The constants in (10)-(11) are , , , and . So , , and by (14) the associate rule to is the rule

 Q(f)=2T2(f)+3S(f)5, (29)

whose error expression has the form

 EQ(f)=(b−a)54800(f(4)(ξ1)−f(4)(ξ1))ξ1,ξ2∈(a,b) . (30)

Therefore, under Assumption B in (9), the rule is positive. It has the same degree as and . However, as the rule is the weighted mean (29) of and , the exact value lies in the interval defined by the inequalities

 T2(f)≤Q(f)≤S(f)orS(f)≤Q(f)≤T2(f) . (31)

#### Composite rules

To obtain a composite version of a given simple rule , one divides the interval in parts with uniform length , and we apply to each subinterval and finally add the values obtained. We denote by the composite rule corresponding to the application of a simple rule to the subintervals , such that , , with .

## 4 Examples

The main features of our companion rules and associate ones can be illustrated by taking as models the following integrals:

 ∫π02sin2(x)dx=∫1/206√1−x2dx=∫1−121+x2dx=π .

The first integral is particularly interesting since the four composite rules and , with subintervals, are exact as shown in Example 1. Thus, the number can be materialized in 2D and 3D pictures as in Figures 1 and 3, suggesting potential architectural applications.

The numerical experiments in Examples 2 and 3 were carried out using Mathematica . Commands like , e are useful to define composite rules (see code given in Example 2).

###### Example 1.

Let

 I(f)=∫π02sin2(x)dx=π . (32)

In Figure 1 the graph of , passing through the points A,D,C,E, and B is displayed in bold. The simple rules and are useless as approximations of the transcendental number , since

 L(f)=R(f)=0andM(f)=(π−0)f(π/2)=2π .

As and , we have

 T(f)=0andS(f)=2π3 .

Taking into account that , the Taylor’s rule is

 T2(f)=M+π324f′′(π/2)=M−π3/6=π(2−π3/6) .

Recall that denotes a composite rule with subintervals of . The symmetry of the function with respect to the axis leads to the remarkable property that all the composite rules with subintervals, and the trapezoidal rule , produce the exact value of (32), that is, . The subintervals to be considered are and . Thus,

 L2(f)=0+π2×2=π(left),R2(f)=π2×2+0=π(right),T2(f)=π+π2=π(trapezoidal),M2(f)=π2×f(π4)+π2×f(π4)=π(midpoint) .

The simple Simpson’s rule ( subintervals) is not exact, as suggested by Figure 1 where the graphic of the interpolating polynomial passing trough the points A, C, B is displayed using a dashed line. It is obvious that the area delimited by the graph of the interpolating polynomial and the -axis is not the same as the area under the graph of . However, since the composite rule and are exact, the composite Simpson’s rule , with subintervals, should be exact because this rule is a weighted mean of and given by (26). In fact,

 S2(f)=2T(f)+M(f)3=M(f)3=2π3≠π,

while

 S4(f)=2T2(f)+M2(f)3=3π3=π .

As shown previously that the simple Taylor’s rule is not exact. However, the composite rule with subintervals is. Let us consider first the subinterval . represents the area delimited by the -axis and the line segment (passing through the point D in Fig.1), whose cartesian equation is

 y=f(π/4)+f′(π/4)(x−π/4)=1+2(x−π/4),0≤x≤π/2,

Noting that , we have

 T2(f)=π/2f(π/4)=π2 .

Analogously, in the subinterval , the value of represents the area delimited by the -axis and the line segment (passing through the point E in Fig.1), whose cartesian equation is

 y=f(3π/4)+f′(3π/4)(x−3π/4)=1−2(x−3π/4),π/2≤x≤π .

As , we obtain

 T2(f)=π/2f(3π/4)=π2 .

Thus, the composite rule, with , subintervals gives

 T22(f)=π2+π2=π .

So, all the above six composite rules, , with , are exact for the integral (32). In Figure 2 four plane regions whose area is are shown, giving a geometrical interpretation of the rules , , and respectively.

In Figure 3 we show (partial) surfaces generated by the revolution of the graphic around the -axis together with the line segments (cf. Figure 1). This suggests interesting architectural applications of our companion and associate rules.

###### Example 2.

Let

 I(f)=∫1/206√1−x2dx=π .

As the function is positive and its derivative is nonnegative derivative in , the function is an increasing function. Therefore, for each , the rules and have errors of opposite signs and

 Ln(f)≤I(f)≤Rn(f),∀n≥1 . (33)

As

 Rn(f)−Ln(f)=(b−a)n(f(b)−f(a))=12n(4√3−6),

we have,

 limn→∞|Rn(f)−Ln(f)|=0 .

Thus, from (33) it follows

 limn→∞Rn(f)=limn→∞Ln(f)=limn→∞=I(f)=π .

As the composite rule is the weighted mean (20) of and , one concludes that . Moreover, as is an increasing function, we also have for the midpoint rule

 Ln(f)≤Mn(f)≤Rn(f),∀n≥1 .

Consequently, all the rules have as common limit. The same is true for the Simpson rule since this is the weighted mean (26) between the composite companion rules (midpoint) and (trapezoidal).

In Figure 4 we compare the errors for each of the previous rules, including the Taylor’ s rule . For we firstly compute the 6-uple using the following Mathematica code

L[f_, a_, b_] := (b - a) f[a];
R[f_, a_, b_] := (b - a) f[b];
M[f_, a_, b_] := (b - a) f[(a + b)/2];
T[f_, a_, b_] := (b - a)/2 (f[a] + f[b]);
S[f_, a_, b_] := (2 M[f, a, b] + T[f, a, b])/3;
T2[f_, a_, b_] := M[f, a, b] + (b - a)^2/24 f’’[(a + b)/2];
composite[rule_String, a_, b_, n_] := Block[{h},
h = (b - a)/n // N;
Total[Map[ToExpression[rule][f, #[], #[] ] &,
Partition[Range[a, b, h], 2, 1]]    ] ];



The numerical values obtained from the 6 rules are sorted in increasing order. For each , the second column of Figure 4 displays a string reflecting the names of the rule with respect to the order of the computed values. For instance the string LMSTT2R means that the smaller computed value is given by the (composite) left rectangle rule and the greatest one corresponds to the right rectangle rule . The values in the columns Error Xi refer to the error of the rule in the -th position of the respective string of rules names.

All the error columns in Fig. 4 show that the respective rule produce monotone sequences. Also, it is clear that and are pairs of companion rules. As the absolute error of is less than the one of , Simpson’s rule performs better than Taylor’s and all the other rules.

###### Example 3.

Let

 I(f)=∫1−121+x2dx=π .

In this case is a positive function, symmetric with respect to the -axis. The function increases from to and decreases from to . Both the function and its derivatives are bounded in . As shown in Figure 5, for the composite rules and (midpoint) have errors of opposite sign, whilst for the rules and enjoy the same property. For all 6 rules their absolute errors seem to approach zero, as expected.

One can verify that for the Simpson’s rule gives , where all digits are correct.

## References

•  M. Abramowitz, I. A. Stegun, Handbook of Mathematical Functions with Formulas, Graphs and Mathematical Tables, Dover, 1972.
•  H. Engels, Numerical quadrature and cubature, Academic Press, London, 1980.
•  P. J. Davis, P. Rabinowitz, Methods of Numerical Integration, Academic Press, Orlando, 1984.
•  C. F. Gauss, Methodus nova integralium valores per approximationem inveniendi, Commentationes Societatis Regiae Scientarium Gottingensis Recentiones 2, [Werke III], 123-162, 1812.
•  W. Gautschi, Numerical Analysis, An Introduction, Birkhauser, Boston, 1997.
•  M. M. Graça, Regras companheiras de Simpson-Milne, Boletim da Sociedade Portuguesa de Matemática, (in portuguese, to appear).
•  V. I. Krylov, Approximate Calculation of Integrals, Dover Pub., New York, 2005.
•  A. R. Krommer, C. W. Ueberhuber, Computational Integration, SIAM, Philadelphia, 1998.
•  I. Newton, Treatise of the Quadrature of Curves, in Sir Isaac Newton’s Two Treatises of The Quadrature of Curves, and Analysis by Equations of an infinite Number of Terms, by John Stewart, James Bettenham, London, 1745.
•  S. Nikolski, Fórmulas de Cuadratura, Editorial MIR, Moscú, 1990 (spanish version).
•  A. H. Stroud, D. Secrest Gaussian Quadrature Formulas, Prentice-Hall, Englewood Cliffs, N. J., 1966.
•  E. Suli, D. Mayers, An Introduction to Numerical Analysis, Cambridge University Press, New York, 2003.
•  E. T. Whittaker, G. Robinson, The Calculus of Observations, 3rd. ed., Blackie and Son, London, 1942.
•  S. Wolfram, The Mathematica Book, Wolfram Media, fifth ed., 2003.