Software Archive
Read-only legacy content
17061 Discussions

Zeros of a Polynomial problem

Intel_C_Intel
Employee
335 Views
I use the same set of coeff. but ZPORC and DZPORC give me two quiet different answers! Why?

The program is:

INTEGER NDEG
PARAMETER (NDEG=3)
!C
REAL*8 COEFF(NDEG+1)
COMPLEX*16 ROOTS(NDEG),ROOT(NDEG)
EXTERNAL WRCRN, ZPLRC
!C Set values of COEFF
!C
DATA COEFF/-9.77E-3, 0.1870, -0.9562, 1.0/
!C
CALL DZPORC (NDEG, COEFF, ROOTS)
CALL ZPORC (NDEG, COEFF, ROOT)
!C
CALL WRCRN ('The ROOTSs found are', 1, NDEG, ROOTS, 1, 0)
CALL WRCRN ('The ROOTSs found are', 1, NDEG, ROOT, 1, 0)
!C
END
0 Kudos
1 Reply
Intel_C_Intel
Employee
335 Views
I think your problem lies in ignoring the kind type parameters required for the arguments to the IMSL subroutines used. At least when I modified your code to call the appropriate subroutines with the right kinds of arguments I got identical results for both ZPORC and DZPORC:

 
! File: polynomial.f90 
program polynomial 
   INTEGER NDEG 
   PARAMETER (NDEG=3) 
!C 
   REAL*4 COEFF(NDEG+1) 
   REAL*8 DCOEFF(NDEG+1) 
   COMPLEX*16 ROOTS(NDEG) 
   COMPLEX*8 ROOT(NDEG) 
   EXTERNAL WRCRN, ZPORC, DZPORC, DWRCRN 
!C Set values of COEFF 
!C 
   DATA DCOEFF/-9.77E-3, 0.1870, -0.9562, 1.0/ 
!C 
   COEFF = DCOEFF 
   CALL DZPORC (NDEG, DCOEFF, ROOTS) 
   CALL ZPORC (NDEG, COEFF, ROOT) 
!C 
   CALL DWRCRN ('The ROOTSs found are', 1, NDEG, ROOTS, 1, 0) 
   CALL WRCRN ('The ROOTSs found are', 1, NDEG, ROOT, 1, 0) 
!C 
END program polynomial 
0 Kudos
Reply