Mathematical Constants (cspex)

Module: utils_cspex

Overview

Provides fundamental mathematical constants and precision definitions used throughout SPEX.

Key Features

  • Double precision arithmetic (15-digit accuracy)

  • Common mathematical constants (π, √2, etc.)

  • Useful numeric constants (zero, one, two, etc.)

  • Consistent precision across all SPEX modules

API Reference

Constants

Mathematical Constants

Constant

Value

Description

pi

3.14159265358979323846

Mathematical constant π

twopi

6.28318530717958647692

2 × π

fourpi

12.56637061435917295385

4 × π

sqrtpi

1.7724538509055159

√π

Common Values

Constant

Value

Description

zero

0.0

Double precision zero

half

0.5

Double precision 0.5

one

1.0

Double precision one

two

2.0

Double precision two

Usage Examples

Basic Usage

use utils_cspex, only: dp, pi, twopi, zero, one

real(dp) :: radius, circumference
radius = 5.0_dp
circumference = twopi * radius

Precision Calculations

use utils_cspex, only: dp, sqrtpi

real(dp) :: result
result = sqrtpi * some_value

Type Definitions

use utils_cspex, only: dp

real(dp) :: high_precision_value
integer :: precision_bits

precision_bits = selected_real_kind(15, 307)  ! Same as dp

Notes

  • All constants are defined with dp (double precision) type

  • Constants use _dp suffix for literal values

  • Module has no dependencies - safe to use anywhere

  • Designed for maximum numerical stability

See Also