>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Phrases

9E. Quadrature & Simpson’s Rule

m0=: W=: integ p. +: >. 1: Weights for 1+2*y points; try m0 3x
m1=: integ=: pint"1@%.@vm Integral of inverse of Vandermonde
m2=: vm=: ^~/~@i.@>:@+: Transposed Vm of order 1+2*y
m3=: pint=: 0: , ] % >:@i.@# Polynomial integral of coefficients y
m4=: pder=: 1: }. ] * i.@# Polynomial derivative of coefficients y
d5=: EW=: +/@(-@take {."0 1 ]) Extended weights (x groups of #y points)
d6=: take=:i.@[ (] + <:@] * [) #@] Amounts of overtake

The integral of a function f from a to b is called its quadrature. Quadrature can be approximated by a weighted sum of the values of the function on a uniform grid from a to b . Use of the weights (1 4 1)%3 on a grid of three points is equivalent to integrating the parabola (polynomial of order 2) fitted to the function at the points. Use of these weights is referred to as an application of Simpson’s Rule.

The foregoing phrases (based on the development in Calculus [6]) provide the weights for Simpson’s Rule and for higher-order polynomial approximations as illustrated below:

   ,.(W 1x);(W 2x);(W 3x)
+---------------------------------------------+
|1r3 4r3 1r3                                  |
+---------------------------------------------|
|14r45 64r45 8r15 64r45 14r45                 |
+---------------------------------------------|
|41r140 54r35 27r140 68r35 27r140 54r35 41r140|
+---------------------------------------------+

   ,.(3*W 1x);(45*W 2x);(140*W 3x)
+-----------------------+
|1 4 1                  |
+-----------------------|
|14 64 24 64 14         |
+-----------------------|
|41 216 27 272 27 216 41|
+-----------------------+

If weights for n points are applied by dividing the grid into groups of n points, the weights are applied as illustrated below for four groups of Simpson’s Rule:

   (-3 5 7 9) {."0 1 w=: 1 4 1
1 4 1 0 0 0 0 0 0
0 0 1 4 1 0 0 0 0
0 0 0 0 1 4 1 0 0
0 0 0 0 0 0 1 4 1

   +/(-3 5 7 9) {."0 1 w
1 4 2 4 2 4 2 4 1

The function EW provides such extended weights as illustrated below:

   3 * 5 EW W 1
1 4 2 4 2 4 2 4 2 4 1

   45 * 4 EW W 2
14 64 24 64 28 64 24 64 28 64 24 64 28 64 24 64 14


>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Phrases