ncc_abscissas Subroutine

subroutine ncc_abscissas(n, x)

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

! NCC_ABSCISSAS computes the Newton Cotes Closed abscissas.

Discussion:

The interval is [ -1, 1 ].

The abscissas are the equally spaced points between -1 and 1,
including the endpoints.

If N is 1, however, the single abscissas is X = 0.

Licensing:

This code is distributed under the GNU LGPL license.

Modified:

29 December 2007

Author:

John Burkardt

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 ncc_abscissas ( n, x )

  !*****************************************************************************80
  !
  !! NCC_ABSCISSAS computes the Newton Cotes Closed abscissas.
  !
  !  Discussion:
  !
  !    The interval is [ -1, 1 ].
  !
  !    The abscissas are the equally spaced points between -1 and 1,
  !    including the endpoints.
  !
  !    If N is 1, however, the single abscissas is X = 0.
  !
  !  Licensing:
  !
  !    This code is distributed under the GNU LGPL license. 
  !
  !  Modified:
  !
  !    29 December 2007
  !
  !  Author:
  !
  !    John Burkardt
  !
  !  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 ) x(n)

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

  if ( n == 1 ) then
     x(1) = 0.0D+00
     return
  end if

  do i = 1, n
     x(i) = ( real ( n - i,     kind = 8 ) * ( -1.0D+00 )   &
          + real (     i - 1, kind = 8 ) * ( +1.0D+00 ) ) &
          / real ( n     - 1, kind = 8 )
  end do

  return
end subroutine ncc_abscissas