Skip to content

Inconsistent value of Pi in the source #428

Closed
@serguei-patchkovskii

Description

@serguei-patchkovskii

Hi,

I am trying to track down a numerical inconsistency in a real16 (quadruple-precision) build of LAPACK, and I noticed that 2Pi and Pi/2 is hard-coded in multiple locations throughout the source. The two values I see are:

PIOVER2, which is set to 1.57079632679489662 (either D0 or E0, depending on the precision) and

TWOPI, which is set to 6.2831853071795864769252867663 (again either D0 or E0). Parenthetically, this value is off in the last decimal digit - it should have been ...7666 if properly rounded.

These values are sufficiently accurate and consistent for real4 and real8 math. The value of PIOVER2 is already not quite accurate enough for real10 math, and neither value is sufficiently accurate for real16, which requires about 34 decimal digits.

The fix is to set

PIOVER2 = 1.570796326794896619231321691639751442099

TWOPI = 6.283185307179586476925286766559005768394

These values are given to 40 significant digits, which should be more than adequate for real16 and complex32 use.

The PIOVER2 value is found in:

./SRC/cbbcsd.f: $ ONE = 1.0E0, PIOVER2 = 1.57079632679489662E0,
./SRC/dbbcsd.f: $ ONE = 1.0D0, PIOVER2 = 1.57079632679489662D0,
./SRC/sbbcsd.f: $ ONE = 1.0E0, PIOVER2 = 1.57079632679489662E0,
./SRC/zbbcsd.f: $ ONE = 1.0D0, PIOVER2 = 1.57079632679489662D0,
./TESTING/EIG/cckcsd.f: $ PIOVER2 = 1.57079632679489662E0,
./TESTING/EIG/ccsdts.f: PARAMETER ( PIOVER2 = 1.57079632679489662E0,
./TESTING/EIG/dckcsd.f: $ PIOVER2 = 1.57079632679489662D0,
./TESTING/EIG/dcsdts.f: PARAMETER ( PIOVER2 = 1.57079632679489662D0,
./TESTING/EIG/sckcsd.f: $ PIOVER2 = 1.57079632679489662E0,
./TESTING/EIG/scsdts.f: PARAMETER ( PIOVER2 = 1.57079632679489662E0,
./TESTING/EIG/zckcsd.f: $ PIOVER2 = 1.57079632679489662D0,
./TESTING/EIG/zcsdts.f: PARAMETER ( PIOVER2 = 1.57079632679489662D0,

The TWOPI value is found in:

./SRC/clarnv.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663E+0 )
./SRC/dlarnv.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663D+0 )
./SRC/slarnv.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663E+0 )
./SRC/zlarnv.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663D+0 )
./TESTING/MATGEN/clarnd.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663E+0 )
./TESTING/MATGEN/clatms.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663E+0 )
./TESTING/MATGEN/clatmt.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663E+0 )
./TESTING/MATGEN/dlarnd.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663D+0 )
./TESTING/MATGEN/dlatms.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663D+0 )
./TESTING/MATGEN/dlatmt.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663D+0 )
./TESTING/MATGEN/slarnd.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663E+0 )
./TESTING/MATGEN/slatms.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663E+0 )
./TESTING/MATGEN/slatmt.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663E+0 )
./TESTING/MATGEN/zlarnd.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663D+0 )
./TESTING/MATGEN/zlatms.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663D+0 )
./TESTING/MATGEN/zlatmt.f: PARAMETER ( TWOPI = 6.2831853071795864769252867663D+0 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions