f2_abscissas Subroutine

subroutine f2_abscissas(n, x)

************80

! F2_ABSCISSAS computes Fejer Type 2 abscissas.

Discussion:

The interval is [-1,+1].

The abscissas are the cosines of equally spaced angles.
The angles are computed as N+2 equally spaced values between 0 and PI,
but with the first and last angle omitted.

Licensing:

This code is distributed under the GNU LGPL license.

Modified:

29 December 2007

Author:

John Burkardt

Reference:

Philip Davis, Philip Rabinowitz,
Methods of Numerical Integration,
Second Edition,
Dover, 2007,
ISBN: 0486453391,
LC: QA299.3.D28.

Walter Gautschi,
Numerical Quadrature in the Presence of a Singularity,
SIAM Journal on Numerical Analysis,
Volume 4, Number 3, 1967, pages 357-362.

Joerg Waldvogel,
Fast Construction of the Fejer and Clenshaw-Curtis Quadrature Rules,
BIT Numerical Mathematics,
Volume 43, Number 1, 2003, pages 1-18.

Parameters:

Input, integer ( kind = 4 ) N, the order of the rule.

Output, real ( kind = 8 ) X(N), the abscissas.

Arguments

Type IntentOptional Attributes Name
integer(kind=4) :: n
real(kind=8) :: x(n)

Source Code

subroutine f2_abscissas ( n, x )

  !*****************************************************************************80
  !
  !! F2_ABSCISSAS computes Fejer Type 2 abscissas.
  !
  !  Discussion:
  !
  !    The interval is [-1,+1].
  !
  !    The abscissas are the cosines of equally spaced angles.
  !    The angles are computed as N+2 equally spaced values between 0 and PI,
  !    but with the first and last angle omitted.
  !
  !  Licensing:
  !
  !    This code is distributed under the GNU LGPL license. 
  !
  !  Modified:
  !
  !    29 December 2007
  !
  !  Author:
  !
  !    John Burkardt
  !
  !  Reference:
  !
  !    Philip Davis, Philip Rabinowitz,
  !    Methods of Numerical Integration,
  !    Second Edition,
  !    Dover, 2007,
  !    ISBN: 0486453391,
  !    LC: QA299.3.D28.
  !
  !    Walter Gautschi,
  !    Numerical Quadrature in the Presence of a Singularity,
  !    SIAM Journal on Numerical Analysis,
  !    Volume 4, Number 3, 1967, pages 357-362.
  !
  !    Joerg Waldvogel,
  !    Fast Construction of the Fejer and Clenshaw-Curtis Quadrature Rules,
  !    BIT Numerical Mathematics,
  !    Volume 43, Number 1, 2003, pages 1-18.
  !
  !  Parameters:
  !
  !    Input, integer ( kind = 4 ) N, the order of the rule.
  !
  !    Output, real ( kind = 8 ) X(N), the abscissas.
  !
  implicit none

  integer ( kind = 4 ) n

  integer ( kind = 4 ) i
  real    ( kind = 8 ) :: pi = 3.141592653589793D+00
  real    ( kind = 8 ) theta(n)
  real    ( kind = 8 ) x(n)

  if ( n < 1 ) then
     write ( *, '(a)' ) ' '
     write ( *, '(a)' ) 'F2_ABSCISSAS - Fatal error!'
     write ( *, '(a)' ) '  N < 1.'
     stop
  end if

  if ( n == 1 ) then
     x(1) = 0.0D+00
     return
  else if ( n == 2 ) then
     x(1) = -0.5D+00
     x(2) =  0.5D+00
     return
  end if

  do i = 1, n
     theta(i) = real ( n + 1 - i, kind = 8 ) * pi &
          / real ( n + 1,     kind = 8 )
  end do

  x(1:n) = cos ( theta(1:n) )

  return
end subroutine f2_abscissas