SPEED
FIND_ROOT_POL.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

real *8 function find_root_pol (x1, x2, xacc, n)
 Find a root of a polynomial of degree n.
 

Function/Subroutine Documentation

◆ find_root_pol()

real*8 function find_root_pol (   x1,
  x2,
  xacc,
  n 
)

Find a root of a polynomial of degree n.

Author
Ilario Mazzieri
Date
September, 2013 - Creation
Version
1.0
Parameters
[in]x1left bound of the interval [x1,x2]
[in]x2right bound of the interval [x1,x2]
[in]xaccacceleration parameter
[in]npolynomial degree
[out]FIND_ROOT_POLzero of the polynomial function of order n

Definition at line 30 of file FIND_ROOT_POL.f90.

31
33
34 implicit real*8(a-h,o-z)
35
36 parameter(jmax=1000)
37
38 call get_legendre_value(p2,fmid,p1,p1der,n,x2)
39 call get_legendre_value(p2,f,p1,p1der,n,x1)
40
41 if (f*fmid .ge. 0.d0) then
42 write(*,*) 'root non-bracketed !'
43 call exit(exit_root)
44 endif
45
46 if (f .lt. 0.d0) then
47 find_root_pol = x1
48 dx = x2 - x1
49 else
50 find_root_pol = x2
51 dx = x1 - x2
52 endif
53
54 do j = 1,jmax
55 dx = 0.5d0*dx
56 xmid = find_root_pol + dx
57 call get_legendre_value(p2,fmid,p1,p1der,n,xmid)
58 if (fmid .le. 0.d0) find_root_pol = xmid
59
60 if (dabs(dx) .lt. xacc .and. dabs(fmid) .le. xacc) then
61 find_root_pol = xmid
62 return
63 endif
64
65 enddo
66
real *8 function find_root_pol(x1, x2, xacc, n)
Find a root of a polynomial of degree n.
subroutine get_legendre_value(p2, p2der, p1, p1der, n, x)
Computes Legendre polynomial and its derivative on a given point x.
SPEED exit codes.
Definition MODULES.f90:25
integer, parameter exit_root
Definition MODULES.f90:39

References speed_exit_codes::exit_root, find_root_pol(), and get_legendre_value().

Referenced by find_root_pol(), make_lgl_nodes(), and make_lgl_nw().

Here is the call graph for this function:
Here is the caller graph for this function: