I'm trying to write an array of this kind
phi(m,r) and dphi(m,r) are functions, where cheby and dcheby are Chebyshev polynomials and its derivates respectively,
Real(kind=8) FUNCTION phi(m,r)
implicit none
integer m
real(kind=8) r
real(kind=8) cheby
if(mod(m,2).eq.0) then
phi = cheby(m+2,r)-cheby(0,r)
else if (mod(m,2).eq.1) then
phi = cheby(m+2,r) - cheby(1,r)
end if
end FUNCTION phi
Real(kind=8) FUNCTION dphi(m,r)
implicit none
integer m
real(kind=8) r
real(kind=8) dcheby
if(mod(m,2).eq.0) then
dphi = dcheby(m+2,r) - dcheby(0,r)
else if (mod(m,2).eq.1) then
dphi = dcheby(m+2,r) - dcheby(1,r)
end if
end FUNCTION dphi
so first i define g and then i used 2nd order- simpson's rule to integrate
Real(kind=8) FUNCTION g(j,i,r)
implicit none
integer i,j
real(kind=8) r
real(kind=8) dphi, phi
real(kind=8) lambda
g = -dphi(j,r)*dphi(i,r) + lambda*phi(j,r)*phi(i,r)
end FUNCTION g
Real(kind=8) FUNCTION integrate(j,i)
implicit none
integer i, j
real(kind=8) g
Real(kind=8) xmax, xmin
xmax = 1.0d0
xmin = -1.0d0
integrate =(( xmax - xmin)/6)*(g(j,i,xmin) +4*g(j,i,0.0d0) + g(j,i,xmax))
end FUNCTION integrate
However i don't know how write the matrix, i wrote that
do i=0,N
do l=0,N
A(i,l) = integrate(j,i)
end do
end do
but, when I compiled A= NaN