NuMFor 9f2ab49 (2024-04-08)
Numerical (Modern) Fortran. Library for Simple Numerical computing
polyval Interface Reference

Computes the value of the polynomial when applied to a number or list of numbers. More...

Public Member Functions

pure real(dp) function polyval_1 (p, x)
 Evaluation of a polynomial in a number.
 
pure real(dp) function, dimension(size(x)) polyval_v (p, x)
 Evaluation of a polynomial in an array of numbers.
 

Detailed Description

Computes the value of the polynomial when applied to a number or list of numbers.

Examples:

p1 = arange(5, 1, -1)
print "(A)", "P(-1)= "//str(polyval(p1, -1._dp)) ! P(-1)= 3
print "(A)", "P(0) = "//str(polyval(p1, 0._dp)) ! P(0) = 1
print "(A)", "P(1) = "//str(polyval(p1, 1._dp)) ! P(1) = 15
! Polynomial evaluated in an array:
print "(A)", "P([-1,0,1]) = "//str(polyval(p1, [-1._dp, 0._dp, 1._dp]))
! P([-1,0,1]) = [ 3, 1, 15]

Member Function/Subroutine Documentation

◆ polyval_1()

pure real(dp) function polyval_1 ( real(dp), dimension(:), intent(in) p,
real(dp), intent(in) x )

Evaluation of a polynomial in a number.

Returns
Value of polynomial evaluated in x
Parameters
[in]pArray of coefficients, from highest degree to constant term
[in]xA number at which to evaluate the polynomial

◆ polyval_v()

pure real(dp) function, dimension(size(x)) polyval_v ( real(dp), dimension(:), intent(in) p,
real(dp), dimension(:), intent(in) x )

Evaluation of a polynomial in an array of numbers.

Parameters
[in]pArray of coefficients, from highest degree to constant term
[in]xA number at which to evaluate the polynomial
Returns
Polynomial evaluated in x

Examples:

print "(A)", "Coefficients of P^(1)(x) = "//str(polyder(p1, 1))
! Coefficients of P^(1)(x) = [ 20, 12, 6, 2]
print "(A)", "Coefficients of P^(2)(x) = "//str(polyder(p1, 2))
! Coefficients of P^(2)(x) = [ 60, 24, 6]
print "(A)", "Coefficients of P^(3)(x) = "//str(polyder(p1, 3))
! Coefficients of P^(3)(x) = [120, 24]
print "(A)", "P'([-1,0,1]) = "//str(polyval(polyder(p1, 1), [-1._dp, 0._dp, 1._dp]))
! P'([-1,0,1]) = [-12, 2, 40]

The documentation for this interface was generated from the following file: