Skip to main content
Ctrl+K

XlCalcNet Documentation

  • Preface

Getting started

  • Setup and general usage
    • Setting up XlCalcNet
    • General and user interface functions
    • Calling Python from C#
    • Using XlCalcNet with spreadsheet formulas
    • Mathematical functions based on Mpmath, Gmpy2 and Python-Flint (only Python)
    • Mathematical functions in fixed precision
    • Mathematical functions based on XlCalcNet2
    • A quick look at Numpy
    • A quick look at Matplotlib and related libraries
    • A quick look at Pandas and Xlxswriter
    • A quick look at Scipy
    • A quick look at R, RStudio and Rpy2
  • Basic floating point functions
    • Operator overloading, general real functions
    • Machine constants, general
    • Properties of numbers
    • Integer related functions
    • Floating point functions for real numbers
    • Fraction and remainder related functions
    • Functions related to mantissa width and exponent range
    • Mathematical Constants
  • Elementary scalar functions (real and complex)
    • Complex components
    • Roots and quadratic, cubic, and quartic equations
    • Exponential and related functions
    • Logarithms and related functions
    • Power functions
    • Trigonometric functions, in radians
    • Trigonometric functions, in multiples of \(\pi\)
    • Hyperbolic functions
    • Inverse trigonometric functions, in radians
    • Inverse hyperbolic functions
    • Factorials, Gamma and related functions
    • Miscellaneous functions
  • Statistical Distributions
    • Introduction to random variables and distributions
    • Base class for univariate distributions
    • Base class for continuous univariate distributions
    • Base class for discrete univariate distributions
    • Closed form distributions, based on elementary functions
      • Boost: Arcsine Distribution
      • Boost: Cauchy distribution
      • Boost: Exponential distribution
      • Boost: Gumbel (Generalized Extreme Value distribution Type-I) distribution
      • Boost: Hyperexponential Distribution
      • !!!Boost: Kumaraswamy distribution
      • Boost: Laplace distribution
      • Boost: Logistic distribution
      • Boost: Pareto distribution
      • Boost: Rayleigh distribution
      • Boost: Triangular Distribution
      • Boost: Uniform distribution
      • Boost: Weibull (Minimum-Type-III) distribution
      • Dagum (Burr Type III) distribution
      • Fisk (log-logistic) distribution
      • Fréchet (Maximum/Minimum-Type-II or Inverse Weibull) distribution
      • Generalized Extreme Value (Maximum) or GEV distribution
      • Generalized Pareto distribution
      • Gompertz-Makeham distribution
      • Lomax distribution
      • Shifted Gompertz distribution
      • Singh-Maddala (Burr Type XII) distribution
    • Closed form distributions, based on the error function
      • !!!Boost: Lévy distribution
      • Boost: Lognormal (Johnson \(S_L\)) distribution
      • !!!Boost: Moyal Distribution
      • Boost: Normal (Johnson \(S_N\)) distribution
      • Boost: Skew normal Distribution
      • Boost: Wald (or Inverse Gaussian) distribution
      • Birnbaum-Saunders Distribution
      • Exponentially Modified Gaussian (EMG) distribution
      • Folded normal distribution
      • Half-normal distribution
      • Johnson \(S_B\) distribution
      • Johnson \(S_U\) distribution
      • Normal maximum distribution, \(\rho_{ij, i \ne j} = 0\)
      • Normal maximum modulus distribution, \(\rho_{ij, i \ne j} = 0\)
      • Sinh-arcsinh normal distribution
      • Truncated normal distribution
    • Closed form distributions, based on the incomplete gamma function
      • !!!Boost: Chi Distribution
      • Boost: Chi-Squared distribution
      • Boost: Gamma (Pearson Type III, Erlang) distribution
      • Boost: Inverse chisquared distribution
      • Boost: Inverse Gamma (Pearson Type V) distribution
      • !!!Boost: Maxwell Distribution
      • !!!Boost: Nakagami distribution
      • Amoroso distribution
      • Distribution of the logarithm of a \(\chi^2\) random variable
      • Hypoexponential (Generalized Erlang) Distribution
      • Lindley distribution (generalized)
      • Skew exponential power distribution
      • Stacy (generalized gamma) distribution
    • Closed form distributions, based on the incomplete beta function
      • Boost: Beta (Pearson Type I and II) distribution
      • Boost: Central Fisher F distribution
      • Boost: Student \(t\) (Pearson Type VII) distribution
      • Distribution of the negative logarithm of a beta variable
      • Beta-prime (Pearson Type VI) distribution
      • Generalized Beta (Type 1) distribution
      • Generalized Beta (Type 2) distribution
      • Generalized logistic distribution (JKB Types I - IV)
      • Generalized beta-exponential distribution
      • Feller-Pareto distribution
      • Fisher \(z\) distribution
      • Skew t-distribution (Jones)
      • Pearson’s rho distribution (under \(H_0\))
    • Noncentral distributions
      • Boost: Noncentral \(\chi^2\) distribution
      • Boost: Noncentral Student \(t\) distribution
      • Boost: Noncentral Fisher \(F\) distribution
      • Boost: Noncentral Beta Type I distribution
      • Noncentral Chi distribution
      • Rice (Nakagami-n) distribution
      • Noncentral distribution of the sample correlation coefficient
      • Distribution of the logarithm of a noncentral Beta Type II variable
      • Noncentral distribution (Type I) of Fisher’s \(R^2\)
      • Distribution of the logarithm of a noncentral Fisher \(1-R^2\) variable
      • Doubly non-central Student \(t\) distribution
      • Doubly non-central Fisher \(F\) distribution
    • Distributions related to multiple comparisons of means
      • Overview and literature
      • Normal maximum distribution, \(\rho_{ij, i \ne j} = \rho\)
      • Normal maximum modulus distribution, \(\rho_{ij, i \ne j} = \rho\)
      • Normal maximum distribution, \(\rho_{ij, i \ne j} = \lambda_i \lambda_j\)
      • Normal maximum modulus distribution, \(\rho_{ij, i \ne j} = \lambda_i \lambda_j\)
      • Normal range distribution
      • Studentized maximum distribution
      • Studentized maximum modulus distribution
      • Distribution of Dunnett’s \(t\), one-sided
      • Distribution of Dunnett’s \(t\), two-sided
      • Nair’s \(t\)-distribution
      • Halperin’s \(t\)-distribution
      • Nelson’s \(h\)-distribution
      • Studentized range distribution
    • Distributions related to multivariate statistical analysis
      • Distribution of the sum of the negative logarithms of independent beta variables
      • Distribution of the product of independent beta variables
      • Distribution of Wilks’ \(\Lambda\)
      • Distribution of Wilks’ \(L_{vc}\)
      • Distribution of Wilks’ \(L_{vcm}\)
      • Distribution of Wilks’ test of independence of \(p\) variates
      • Distribution of Wilks’ test of independence of \(k\) groups of variates
      • Distribution of Mauchly’s test of sphericity vs general structure
      • Distribution of Box’s test of equality of covariance matrices, equal sample sizes
      • Distribution of Box’s test of equality of k covariance matrices, unequal sample sizes
      • Distribution of Box’s test for same multivariate normal distributions, unequal sample sizes
      • Distribution of the modified likelihood ratio test (LRT) for a given covariance matrix
      • Distribution of the modified likelihood ratio test (LRT) for a given covariance matrix and mean vector
      • Central distribution of Roy’s largest root
      • Central distribution of Pillai’s \(V\)
      • Central distribution of Hotelling’s \(T^2\)
      • Noncentral Distribution of Wilks’ \(\Lambda\): MANOVA
      • Noncentral Distribution of Wilks’ \(\Lambda\): Canonical Correlation
    • Miscellaneous continuous distributions
      • Boost: Kolmogorov-Smirnov distribution (limiting form)
      • Boost: Landau Distribution
      • Boost: Holtsmark distribution
      • Boost: Map-Airy distribution
      • Boost: Saspoint5 distribution
      • Lévy alpha-stable distribution
      • Pearson Type IV distribution
      • Meixner distribution
      • Voigt Profile Distribution
      • Wrapped Cauchy distribution
      • Wrapped normal distribution
      • Von Mises distribution
      • Generalized inverse Gaussian distribution
      • Harmonic distribution
      • Halphen A distribution
      • Halphen B distribution
      • Halphen IB distribution
      • Generalized hyperbolic distribution
      • Hyperbolic distribution
      • Variance-gamma distribution
    • Elementary discrete (lattice) distributions
      • Boost: Bernoulli distribution
      • Boost: Geometric distribution
      • Boost: Poisson distribution
      • Boost: Binomial distribution
      • Boost: Negative binomial distribution
      • Boost: Classical hypergeometric distribution
      • Log-series distribution
      • Zeta distribution
      • Skellam distribution
      • Delaporte distribution
      • Beta-Poisson distribution (Quinkert)
      • Beta-binomial distribution
      • Beta-negative binomial distribution (Waring)
      • Negative hypergeometric distribution
      • Pólya-Eggenberger distribution
      • General hypergeometric distribution
      • Noncentral hypergeometric distribution, Fisher alternatives
    • Discrete (lattice) distributions related to (stratified) rank tests
      • Wilcoxon signed rank T distribution, continuous data
      • Noncentral Wilcoxon signed rank T distribution, Bennett alternatives
      • Mann-Whitney U distribution, continuous data
      • Noncentral Mann-Whitney U distribution, Lehmann alternatives
      • Noncentral Mann-Whitney U distribution, Milton alternatives
      • Kendall’s tau distribution, continuous data
      • Jonckheere-Terpsta \(T\) distribution, continuous data
      • Generalized Page \(L\) distribution, continuous data
      • Noncentral generalized Page \(L\) distribution, Milton alternatives
    • Discrete (non-lattice) distributions related to rank tests
      • Cochran-Friedman-Quade distribution
      • Kruskal-Wallis distribution
  • Numerical calculus
    • Introduction
    • DAMath: Numerical Rootfinding and Minimization
    • Boost/Math: Root Finding and Minimization Algorithms
    • Mpmath: Rootfinding and optimization
    • DAMath: Numerical Quadrature
    • Boost/Math: Numerical integration
    • Mpmath: Numerical integration
    • Mpmath: Numerical inverse Laplace transform
    • Boost/Odeint: Ordinary differential equations
    • Mpmath: Numerical differentiation
    • Mpmath: Asymptotic expansions
    • Mpmath: Function approximation
    • Mpmath: Sums, products, limits and extrapolation
    • Mpmath: Number identification
    • Mpmath: Polynomials
    • Eigen: Polynomials
    • Eigen/MinPack: non linear optimization
    • Eigen/CppOptLib: multidimensional optimization
    • Flint/Functions for polynomials
    • Flint/Power series and Taylor arithmetic
    • Flint/Verified numerical differentiation
    • Flint/Verified numerical integration
  • Eigen: Dense and Sparse Matrices
    • Creating scalars and matrices
    • Read-only properties: information about a matrix
    • Accessing and setting parts of a matrix
    • Changing the shape of a matrix and/or the order of coefficients
    • Basic arithmetic operations
    • Descriptive Statistics
    • Standard decompositions and linear solving
    • Singular Value and Eigen (selfadjoint) decompositions
    • Eigen decompositions of general square matrices
    • Eigen: Functions of matrix argument
    • Eigen: Fast Fourier Transform
  • Numpy: use with multiprecision data types
    • Numpy array creation from shape or value
    • Numpy array creation from existing data
    • Building special arrays for numerical work
    • Numpy indexing
    • Numpy basic array manipulation routines
    • Numpy array manipulation: Transpose-like operations
    • Numpy array manipulation: Changing number of dimensions
    • Numpy array manipulation: Joining arrays
    • Numpy array manipulation: Splitting and tiling arrays
    • Numpy array manipulation: Adding and removing elements
    • Numpy array manipulation: Rearranging elements
    • Numpy array manipulation: Sorting
    • Numpy array manipulation: Searching
    • Numpy mathematical functions: Sums, products, differences
    • Numpy mathematical functions: Extrema Finding
    • Numpy mathematical functions: Arithmetic operations, elementwise
    • Numpy mathematical functions: Averages and variances
    • Numpy mathematical functions: Matrix and vector products
    • Numpy logical functions: Truth value testing
    • Numpy mathematical functions: Integer and fractional
    • Numpy mathematical functions: Miscellaneous
    • Summary and examples: Numpy utility functions
    • Arithmetic operations with scalars and iterables
    • Numerical transformations and descriptive statistics
    • Standard decompositions and linear solving
    • Singular Value and Eigen decompositions
    • Analytic functions of a matrix
    • Discrete Fourier transform (DFT)
    • Flint/Functions for matrices

Special Functions

  • Elliptic functions and related
    • Carlson symmetric elliptic integrals
    • Legendre elliptic integrals (elliptic parameter \(m\))
    • Legendre elliptic integrals (elliptic modulus \(k\)), and related functions
    • Jacobi elliptic functions
    • Jacobi theta functions and related functions
    • Conversions of parameters of Weierstrass \(\wp\)
    • Weierstrass elliptic functions, in terms of elliptic period ratio \(\tau\)
    • Modular forms, in terms of half-period \(\omega_1\) and elliptic period ratio \(\tau\)
  • Lerch’s phi and related
    • Lerch’s transcendent and Lerch’s zeta
    • Polygamma and related functions
    • Polylogarithm and related functions
    • Hurwitz zeta and related functions
    • Riemann zeta function, and related functions
  • Hypergeometric function \(\,_0F_1\) and related
    • Hypergeometric Limit Function \(\,_0F_1\)
    • Bessel functions
    • Modified Bessel functions
    • Spherical Bessel functions
    • Modified spherical Bessel functions
    • Hankel functions
    • Airy functions
    • Kelvin functions
  • Hypergeometric function \(\,_1F_1\) and related
    • Hypergeometric Functions \(\,_1F_1\) (Kummer) and \(U\) (Tricomi)
    • Incomplete gamma functions
    • Coulomb, Whittaker and parabolic cylinder function
    • Error function and related functions
    • Exponential integrals, and related functions
  • Hypergeometric functions \(\,_2F_1\) and \(\,_1F_2\) (and related functions)
    • Gauss Hypergeometric Function \(\,_2F_1\)
    • Chebyshev, Gegenbauer and Jacobi polynomials
    • Legendre polynomials and related
    • Incomplete beta functions
    • Hypergeometric function \({}_1F_2\)
    • Scorer functions
    • Struve functions
    • Anger, Weber and Lommel functions

Supporting Functions

  • Algebra with random variables
    • Probability density function (pdf)
    • Probability mass function (pmf)
    • Cumulative distribution function (cdf)
    • Quantile function
    • Characteristic function
    • Moment generating function
    • Cumulant generating function
    • Probability generating function
    • Factorial Moments
    • Raw Moments
    • Central Moments
    • Cumulants
  • Series and integrals
    • Finite series algorithms for selected distributions
    • Infinite series algorithms for selected functions and distributions
    • Finite series for lattice distributions, based on factorial moments
    • Efficient integration of bell-shaped functions
    • Verified numerical integration
  • Pmf vectors
    • Basic discrete (lattice) distribution functions
    • Discrete (lattice) distribution functions related to (stratified) rank tests
    • Discrete (non-lattice) distribution functions related to rank tests
  • Fast approximations
    • Approximations based on the normal distribution
    • Approximations based on the chi-squared distribution
    • Approximations based on the central \(t\), \(F\) or beta distribution
    • Approximations based on the noncentral chi-squared distribution
    • Approximations based on the noncentral F or beta distribution
    • Approximations based on hypergeometric functions of scalar argument

Gallery of Plots

  • Visualisation of datasets
    • Bar Charts
    • Line and lollipop charts
    • Area Plots
    • Boxplot, Violinplot and Raincloud plot
    • Correlation and regression
    • Financial plots (requires mplfinance)
    • Geographic data (requires cartopy)
    • Geographic data (requires geopandas)
    • Parts of a whole
    • Arcplots, dendrograms, heatmaps and clustermaps
    • PlotTable
    • Flow and connections
    • Circular plots and flows
    • Network data (requires networkx)
  • Visualisation of functions and curves (2D)
    • Introduction to 2D functions and curves
    • Basic curves
    • Spirals
    • Decorative curves
    • General curve families
    • Field lines
    • Contours
    • Complex functions rendered as contours
    • Streams, barbs and quivers (some require cartopy)
  • Bitmaps
    • Fractals: introduction
    • Fractals related to the Mandelbrot set
    • Fractals related to the Julia set
    • Newton Fractals
    • Domain coloring options
    • Domain coloring: Examples part 1
  • Matplotlib 3D Graphics
    • Introduction
    • Matplotlib: 3D Graphics, part 2
    • S3dlib: Basic geometric figures
    • S3dlib: Real functions
    • S3dlib: Parametric Surfaces
    • S3dlib: Image mapping and clipping
    • S3dlib: Edge-to-edge surface coloring
    • S3dlib: Decorative parametric surfaces
    • S3dlib: Geometric and color datagrid mapping (requires scipy)
    • S3dlib: Implicit surfaces (requires scikit-image)
  • Plotly
    • General surface plots in 3D
    • Geographical plots
    • Sankey plots

Interactive 3D Wpf Plots

  • Wpf: Altitude surfaces in 3D, real and complex functions
    • Special techniques for height surfaces, real and complex functions
    • Scatterplots and building 3D scenes
    • Height plots of general bivariate real functions
  • Wpf: Parametric surfaces
    • Surfaces of translation
    • Surfaces of revolution: spheres and related
    • Generalisations of common surfaces
    • Minimal surfaces
    • Nonorientable (one-sided) Surfaces
    • Decorative parametric surfaces
  • Wpf: Path surfaces in 3D
    • Introduction to path surfaces
    • Functions with real input and complex results
    • Characteristic functions of statistical distributions
    • Helices and related curves traced on cylinders, cones and spheres
    • Coil springs
    • General knots
    • Torus knots
    • Lissajous knots
    • Polynomial knots
  • Wpf: Built-in 3D objects
    • Builtin solids with support for textures
    • Builtin solids without support for textures
    • Platonic solids, and related solids

User library: numerical

  • Additional Classes
    • User defined functions based on multiple precision arithmetic (Python)
    • User defined functions based on fixed precision arithmetic (C#)
    • User defined functions based on arbitrary precision arithmetic (C#)
    • Scalar functions
  • Distribution functions
    • Distributions related to multiple comparisons of means
    • Discrete (lattice) distribution functions related to (stratified) rank tests
    • Discrete (non-lattice) distribution functions related to rank tests
  • Inferential statistics
    • Basic classical statistical tests (stratified)
    • Basic classical statistical tests for 2 independent samples (stratified)
    • Basic classical statistical tests for 2 correlated samples (stratified)
    • Analysis of variance (ANOVA), orthogonal polynomials, and analysis of means (AOM)
    • Multiple comparisons of means
    • Nonparametric statistical tests, 1 or 2 samples
    • Nonparametric statistical tests, k samples
    • Multivariate statistical tests
  • Addditional elementary functions (real arguments, double precision)
    • Additional root, exponential, logarithmic and power functions
    • Additional Trigonometric functions (real arguments only)
    • Additional real error functions (real arguments only)
    • Additional real gamma functions (real arguments only)
    • Additional real incomplete gamma functions (real arguments only)
  • Addditional special functions (real arguments, double precision)
    • Conversions of parameters of elliptic functions
    • Additional elliptic integrals
    • Bulirsch elliptic integrals
    • Maple style elliptic integrals
    • Jacobi theta functions at \(x=0\) for \(0 \le q <1\)
    • Inverse Jacobi elliptic functions
    • Lemniscate functions
    • Neville theta functions
    • Polygamma, and related functions
    • Polylogarithm, and related functions
    • Riemann zeta, and related functions
    • Bessel functions of integer order
    • Modified Bessel functions of integer order
    • Integrals of zero-order Bessel functions
    • Kelvin functions of order 0
    • Synchrotron functions
    • Error function, and related functions
    • Exponential integrals, and related functions
    • Coulomb, Whittaker and parabolic cylinder function
    • Hypergeometric pFq, and related functions
    • Miscellaneous functions
  • Addditional special functions (complex arguments, double precision)
    • Conversions of parameters of Weierstrass \(\wp\)
    • Weierstrass elliptic functions, in terms of (real) lattice invariants \(g_2, g_3\)
    • Weierstrass elliptic functions, in terms of (real) lattice roots \(e_1, e_2\)
    • Weierstrass elliptic functions, in terms of lattice half-periods \(\omega_1\) and \(\omega_2\)
  • Addditional special functions (Mpmath)
    • Mpmath: Conversions of parameters of elliptic functions
    • Related to Lerch’s phi
    • Additional numbertheoretic functions
    • Generalized hypergeometric functions
    • Appell Functions
    • Q Functions
    • Further generalizations of gamma and hypergeometric functions

Back matter

  • License and History
    • Mozilla Public License Version 2.0
    • History

Indices

  • General Index
  • .rst

Logarithms and related functions

Contents

  • Natural logarithm \(\log(x)\)
    • ctx.log()
  • Logarithm with base \(10\), \(\mathrm{log10}(x) = \log_{10}(x)\)
    • ctx.log10()
  • Logarithm with base \(2\), \(\mathrm{log2}(x) = \log_{2}(x)\)
    • ctx.log2()
  • Logarithm with base \(b\), \(\mathrm{logbase}(x, b) = \log_{b}(x)\)
    • ctx.logbase()
  • Auxiliary function \(\mathrm{log1p}(x) = \log(x+1)\)
    • ctx.log1p()
  • Auxiliary function \(\mathrm{log10p1}(x) = \log_{10}(1+x)\)
    • ctx.log10p1()
  • Auxiliary function \(\mathrm{log2p1}(x) = \log_2(1+x)\)
    • ctx.log2p1()

Logarithms and related functions#

Natural logarithm \(\log(x)\)#

ctx.log(x)#

where ctx is math53, mathc53, ctxcpp, ctxflint.

Returns the natural logarithm of \(x\), \(\log(x) = \log(x)\). See also Wikipedia [1338], MathWorld [925], NIST [516], Ehrhardt [309] (4.2.41), Flint [804], Flint [794], Mpmath [581].

\[\log(x) = \int_1^x \frac{1}{t} \, \mathrm{d}t.\]

If \(x\) is less than 1, then this area is considered to be negative.

The principal branch of the complex logarithm is used, meaning that \(\Im(\log(z)) = -\pi < \arg(z) \le \pi\).

05a_TestLog_re \(\quad\) 05b_TestLog_im \(\quad\) 05c_TestLog_abs

Left figure: real part of the Log function. Camera angles are \(\theta=135^\circ\) and \(\phi = -12^\circ\), camera radius is -2.

Middle figure: imaginary part of the Log function. Camera angles are \(\theta=135^\circ\) and \(\phi = -12^\circ\), camera radius is -2.

Right figure: absolute value of the Log function, with color-coded phase. Camera angles are \(\theta=135^\circ\) and \(\phi = -12^\circ\), camera radius is -2.

An example in Python

>>> from xlcalcnet import xreal
>>> xreal.Log(0.5)
xreal('5.2359877559829887307E-1')
>>> xreal.Log('0.51')
xreal('5.3518479027559984754E-1')

An example in Visual Basic

>>> from xlcalcnet import Gpr
>>> Gpr.Log(0.5)
Gpr('5.2359877559829887307E-1')
>>> Gpr.Log('0.51')
Gpr('5.3518479027559984754E-1')

An example with real input:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 40; x = '1.0E-100'
>>> \mathrm{d}x = dec.Log(x); mx = mpm.Log(x); ix = ipm.Log(x)
>>> mpm.show([\mathrm{d}x, mx, ix])
dec:  -2.302585092994045684017991454684364207601E+2
mpm:  -2.302585092994045684017991454684364207601e+2
ipm:  -2.302585092994045684017991454684364207601e+2 (-6.381e-40%)

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 40; x = '1.0E-100'
>>> fx = fpm.Log(x); gx = gmp.Log(x); ax = apm.Log(x)
>>> mpm.show([fx, gx, ax])
fpm:  -2.30258509299405E+02
gmp:  -2.302585092994045684017991454684364207601E+02
apm:  -2.302585092994045684017991454684364207601e+2 (-1.276e-39%)

The following example with complex input shows that the relative error can be high in double precision:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 20; z = '1.0E-100 + 1.57079632679489j'
>>> \mathrm{d}z = dec.Log(z); mz = mpm.Log(z); iz = ipm.Log(z)
>>> mpm.show([\mathrm{d}z, mz, iz], aligned=True)
dec: 4.5158270528945065079E-1              + 1.5707963267948966192E+0j
mpm: 4.5158270528945065079e-1              + 1.5707963267948966192e+0j
ipm: 4.5158270528945065079e-1 (1.876e-19%) + 1.5707963267948966192e+0 (5.392e-20%)j

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 20; z = '1.0E-100 + 1.57079632679489j'
>>> fz = fpm.Log(z); gz = gmp.Log(z); az = apm.Log(z)
>>> mpm.show([fz, gz, az], aligned=True)
fpm: 4.51582705289451E-01                  + 1.57079632679490E+00j
gmp: 4.5158270528945065079E-01             + 1.5707963267948966192E+00j
apm: 4.5158270528945065079e-1 (1.407e-19%) + 1.5707963267948966192e+0 (1.078e-19%)j

Logarithm with base \(10\), \(\mathrm{log10}(x) = \log_{10}(x)\)#

ctx.log10(x)#

where ctx is math53, mathc53, ctxcpp or ctxflint.

Returns the base-10 logarithm of \(x\), \(\log_{10}(x) = \log(x)/\log(10)\). See also. Wikipedia [1336], MathWorld [914], NIST [516], Ehrhardt [309] (4.2.44), Mpmath [579].

An example in Python

>>> from xlcalcnet import xreal
>>> xreal.Log10(0.5)
xreal('5.2359877559829887307E-1')
>>> xreal.Log10('0.51')
xreal('5.3518479027559984754E-1')

An example in Visual Basic

>>> from xlcalcnet import Gpr
>>> Gpr.Log10(0.5)
Gpr('5.2359877559829887307E-1')
>>> Gpr.Log10('0.51')
Gpr('5.3518479027559984754E-1')

An example with real input:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 40; x = '1.0E-100'
>>> \mathrm{d}x = dec.log10(x); mx = mpm.log10(x); ix = ipm.log10(x)
>>> mpm.show([\mathrm{d}x, mx, ix])
dec:  -1.000000000000000000000000000000000000000E+2
mpm:  -1.000000000000000000000000000000000000000e+2
ipm:  -1.000000000000000000000000000000000000000e+2 (-1.469e-39%)

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 40; x = '1.0E-100'
>>> fx = fpm.log10(x); gx = gmp.log10(x); ax = apm.log10(x)
>>> mpm.show([fx, gx, ax])
fpm:  -1.00000000000000E+02
gmp:  -1.000000000000000000000000000000000000000E+02
apm:  -1.000000000000000000000000000000000000000e+2 (-1.469e-39%)

The following example with complex input shows that the relative error can be high in double precision:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 20; z = '1.0E-100 + 1.57079632679489j'
>>> \mathrm{d}z = dec.log10(z); mz = mpm.log10(z); iz = ipm.log10(z)
>>> mpm.show([\mathrm{d}z, mz, iz], aligned=True)
dec: 1.9611987703015082905E-1             + 6.8218817692092067374E-1j
mpm: 1.9611987703015082905e-1             + 6.8218817692092067374e-1j
ipm: 1.9611987703015082905e-1 (1.62e-19%) + 6.8218817692092067374e-1 (6.208e-20%)j

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 20; z = '1.0E-100 + 1.57079632679489j'
>>> fz = fpm.log10(z); gz = gmp.log10(z); az = apm.log10(z)
>>> mpm.show([fz, gz, az], aligned=True)
fpm: 1.96119877030151E-01                  + 6.82188176920921E-01j
gmp: 1.9611987703015082905E-01             + 6.8218817692092067374E-01j
apm: 1.9611987703015082905e-1 (2.159e-19%) + 6.8218817692092067374e-1 (6.208e-20%)j

Logarithm with base \(2\), \(\mathrm{log2}(x) = \log_{2}(x)\)#

ctx.log2(x)#

where ctx is math53, mathc53, ctxcpp or ctxflint.

Returns the base-2 logarithm of \(x\), \(\log_{2}(x) = \log(x)/\log(2)\). See also Wikipedia :cite:p: \(WikipediaFun19\), MathWorld [913], NIST [516].

An example in Python

>>> from xlcalcnet import xreal
>>> xreal.Log2(0.5)
xreal('5.2359877559829887307E-1')
>>> xreal.Log2('0.51')
xreal('5.3518479027559984754E-1')

An example in Visual Basic

>>> from xlcalcnet import Gpr
>>> Gpr.Log2(0.5)
Gpr('5.2359877559829887307E-1')
>>> Gpr.Log2('0.51')
Gpr('5.3518479027559984754E-1')

An example with real input:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 40; x = '1.0E-100'
>>> \mathrm{d}x = dec.log2(x); mx = mpm.log2(x); ix = ipm.log2(x)
>>> mpm.show([\mathrm{d}x, mx, ix])
dec:  -3.321928094887362347870319429489390175865E+2
mpm:  -3.321928094887362347870319429489390175865e+2
ipm:  -3.321928094887362347870319429489390175865e+2 (-8.846e-40%)

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 40; x = '1.0E-100'
>>> fx = fpm.log2(x); gx = gmp.log2(x); ax = apm.log2(x)
>>> mpm.show([fx, gx, ax])
fpm:  -3.32192809488736E+02
gmp:  -3.321928094887362347870319429489390175865E+02
apm:  -3.321928094887362347870319429489390175865e+2 (-8.846e-40%)

The following example with complex input shows that the relative error can be high in double precision:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 20; z = '1.0E-100 + 1.57079632679489j'
>>> \mathrm{d}z = dec.log2(z); mz = mpm.log2(z); iz = ipm.log2(z)
>>> mpm.show([\mathrm{d}z, mz, iz], aligned=True)
dec: 1.9611987703015082905E-1             + 6.8218817692092067374E-1j
mpm: 1.9611987703015082905e-1             + 6.8218817692092067374e-1j
ipm: 1.9611987703015082905e-1 (1.62e-19%) + 6.8218817692092067374e-1 (6.208e-20%)j

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 20; z = '1.0E-100 + 1.57079632679489j'
>>> fz = fpm.log2(z); gz = gmp.log2(z); az = apm.log2(z)
>>> mpm.show([fz, gz, az], aligned=True)
fpm: 1.96119877030151E-01                  + 6.82188176920921E-01j
gmp: 1.9611987703015082905E-01             + 6.8218817692092067374E-01j
apm: 1.9611987703015082905e-1 (2.159e-19%) + 6.8218817692092067374e-1 (6.208e-20%)j

Logarithm with base \(b\), \(\mathrm{logbase}(x, b) = \log_{b}(x)\)#

ctx.logbase(x, b)#

where ctx is math53, mathc53, ctxcpp or ctxflint.

Returns the base-\(b\) logarithm of \(x\), \(\log_{b}(x) = \log(x)/\log(b)\). See also Wikipedia [1347], Wikipedia [1338], MathWorld [924], NIST [516], Ehrhardt [309] (4.2.45), Flint [804], Flint [794], Mpmath [580].

The principal branch of the complex logarithm is used, meaning that \(\Im(\log(z)) = -\pi < \arg(z) \le \pi\).

An example in Python

>>> from xlcalcnet import xreal
>>> xreal.Logb(0.5, 2)
xreal('5.2359877559829887307E-1')
>>> xreal.Logb('0.51', 2)
xreal('5.3518479027559984754E-1')

An example in Visual Basic

>>> from xlcalcnet import Gpr
>>> Gpr.Logb(0.5, 2)
Gpr('5.2359877559829887307E-1')
>>> Gpr.Logb('0.51', 2)
Gpr('5.3518479027559984754E-1')

An example with real input:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 40; x = '3'; b = 2
>>> \mathrm{d}x = dec.logb(x, b); mx = mpm.logb(x, b); ix = ipm.logb(x, b)
>>> mpm.show([\mathrm{d}x, mx, ix])
dec:  1.584962500721156181453738943947816508760E+0
mpm:  1.584962500721156181453738943947816508760e+0
ipm:  1.584962500721156181453738943947816508760e+0 (7.243e-40%)

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 40; x = '3'
>>> fx = fpm.logb(x, b); gx = gmp.logb(x, b); ax = apm.logb(x, b)
>>> mpm.show([fx, gx, ax])
fpm:  1.58496250072116E+00
gmp:  1.584962500721156181453738943947816508760E+00
apm:  1.584962500721156181453738943947816508760e+0 (4.346e-39%)

The following example with complex input shows that the relative error can be high in double precision:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 20; z = '3 + 1.57079632679489j'; b = 2
>>> \mathrm{d}z = dec.logb(z, b); mz = mpm.logb(z, b); iz = ipm.logb(z, b)
>>> mpm.show([\mathrm{d}z, mz, iz], aligned=True)
dec: 1.7597332799736771780E+0              + 6.9588093355781665181E-1j
mpm: 1.7597332799736771780e+0              + 6.9588093355781665181e-1j
ipm: 1.7597332799736771780e+0 (4.813e-20%) + 6.9588093355781665181e-1 (1.217e-19%)j

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 20; z = '3 + 1.57079632679489j'; b = 2
>>> fz = fpm.logb(z, b); gz = gmp.logb(z, b); az = apm.logb(z, b)
>>> mpm.show([fz, gz, az], aligned=True)
fpm: 1.75973327997368E+00                  + 6.95880933557817E-01j
gmp: 1.7597332799736771780E+00             + 6.9588093355781665181E-01j
apm: 1.7597332799736771780e+0 (4.813e-19%) + 6.9588093355781665181e-1 (5.477e-19%)j

Auxiliary function \(\mathrm{log1p}(x) = \log(x+1)\)#

ctx.log1p(x)#

where ctx is math53, mathc53, ctxcpp, ctxflint.

Returns \(\log(1+x) = \log(1+x)\), accurately for small \(x\). See also Wikipedia [1347], Wikipedia [1346], MathWorld [924], NIST [516], BoostMath [113], Ehrhardt [309] (4.2.34), Flint [804], Flint [794], Mpmath [578].

An example in Python

>>> from xlcalcnet import xreal
>>> xreal.Log1p(0.5)
xreal('5.2359877559829887307E-1')
>>> xreal.Log1p('0.51')
xreal('5.3518479027559984754E-1')

An example in Visual Basic

>>> from xlcalcnet import Gpr
>>> Gpr.Log1p(0.5)
Gpr('5.2359877559829887307E-1')
>>> Gpr.Log1p('0.51')
Gpr('5.3518479027559984754E-1')

An example with real input:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 40; x = '1.0E-10'
>>> \mathrm{d}x = dec.log1p(x); mx = mpm.log1p(x); ix = ipm.log1p(x)
>>> mpm.show([\mathrm{d}x, mx, ix])
dec:  9.999999999500000000033333333330833333334E-11
mpm:  9.999999999500000000033333333330833333334e-11
ipm:  9.999999999500000000033333333330833779067e-11 (1.121e-32%)

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 40; x = '1.0E-10'
>>> fx = fpm.log1p(x); gx = gmp.log1p(x); ax = apm.log1p(x)
>>> mpm.show([fx, gx, ax])
fpm:  9.99999999950000E-11
gmp:  9.999999999500000000033333333330833333334E-11
apm:  9.999999999500000000033333333330833333333e-11 (1.336e-39%)

The following example with complex input shows that the relative error can be high in double precision:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 20; z = '1.0E-10 + 1.57079632679489j'
>>> \mathrm{d}z = dec.log1p(z); mz = mpm.log1p(z); iz = ipm.log1p(z)
>>> mpm.show([\mathrm{d}z, mz, iz], aligned=True)
dec: 6.2170267547320030388E-1              + 1.0038848218085834701E+0j
mpm: 6.2170267547320030388e-1              + 1.0038848218085834701e+0j
ipm: 6.2170267547320030388e-1 (1.362e-19%) + 1.0038848218085834701e+0 (1.688e-19%)j

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 20; z = '1.0E-10 + 1.57079632679489j'
>>> fz = fpm.log1p(z); gz = gmp.log1p(z); az = apm.log1p(z)
>>> mpm.show([fz, gz, az], aligned=True)
fpm: 6.21702675473200E-01                  + 1.00388482180858E+00j
gmp: 6.2170267547320030388E-01             + 1.0038848218085834701E+00j
apm: 6.2170267547320030388e-1 (1.362e-19%) + 1.0038848218085834701e+0 (1.688e-19%)j

From mpmath:

>>> from xlcalcnet import dec, mpr, ivr, ivc
>>> ivr.dps = 25; ivr.pretty = True
>>> mp.dps = 15; mp.pretty = True
>>> log(1+1e-10); print(mp.log1p(1e-10))
1.00000008269037e-10
9.9999999995e-11
>>> mp.log1p(1e-100j)
(5.0e-201 + 1.0e-100j)
>>> mp.log1p(0)
0.0

Auxiliary function \(\mathrm{log10p1}(x) = \log_{10}(1+x)\)#

ctx.log10p1(x)#

where ctx is math53, mathc53, ctxcpp or ctxflint.

Returns \(\mathrm{log10p1}(x)) = \log_{10}(1+x) = \mathrm{log1p}(x) / \log(10)\). See also log1p().

An example in Python

>>> from xlcalcnet import xreal
>>> xreal.Log10p1(0.5)
xreal('5.2359877559829887307E-1')
>>> xreal.Log10p1('0.51')
xreal('5.3518479027559984754E-1')

An example in Visual Basic

>>> from xlcalcnet import Gpr
>>> Gpr.Log10p1(0.5)
Gpr('5.2359877559829887307E-1')
>>> Gpr.Log10p1('0.51')
Gpr('5.3518479027559984754E-1')

An example with real input:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 40; x = '1.0E-10'
>>> \mathrm{d}x = dec.log10p1(x); mx = mpm.log10p1(x); ix = ipm.log10p1(x)
>>> mpm.show([\mathrm{d}x, mx, ix])
dec:  4.342944818815371035574139758069509021536E-11
mpm:  4.342944818815371035574139758069509021536e-11
ipm:  4.342944818815371035574139758069509215116e-11 (1.121e-32%)

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 40; x = '1.0E-10'
>>> fx = fpm.log10p1(x); gx = gmp.log10p1(x); ax = apm.log10p1(x)
>>> mpm.show([fx, gx, ax])
fpm:  4.34294481881537E-11
gmp:  4.342944818815371035574139758069509021536E-11
apm:  4.342944818815371035574139758069509021536e-11 (3.077e-39%)

The following example with complex input shows that the relative error can be high in double precision:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 20; z = '1.0E-10 + 1.57079632679489j'
>>> \mathrm{d}z = dec.log10p1(z); mz = mpm.log10p1(z); iz = ipm.log10p1(z)
>>> mpm.show([\mathrm{d}z, mz, iz], aligned=True)
dec: 2.7000204134249903326E-1              + 4.3598163857789703955E-1j
mpm: 2.7000204134249903326e-1              + 4.3598163857789703955e-1j
ipm: 2.7000204134249903326e-1 (4.706e-19%) + 4.3598163857789703955e-1 (4.371e-19%)j

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 20; z = '1.0E-10 + 1.57079632679489j'
>>> fz = fpm.log10p1(z); gz = gmp.log10p1(z); az = apm.log10p1(z)
>>> mpm.show([fz, gz, az], aligned=True)
fpm: 2.70002041342499E-01                  + 4.35981638577897E-01j
gmp: 2.7000204134249903326E-01             + 4.3598163857789703955E-01j
apm: 2.7000204134249903326e-1 (6.274e-19%) + 4.3598163857789703955e-1 (6.8e-19%)j

Auxiliary function \(\mathrm{log2p1}(x) = \log_2(1+x)\)#

ctx.log2p1(x)#

where ctx is math53, mathc53, ctxcpp or ctxflint.

Returns \(\mathrm{log2p1}(x)) = \log_{2}(1+x) = \mathrm{log1p}(x) / \log(2)\). See also log1p().

An example in Python

>>> from xlcalcnet import xreal
>>> xreal.Log2p1(0.5)
xreal('5.2359877559829887307E-1')
>>> xreal.Log2p1('0.51')
xreal('5.3518479027559984754E-1')

An example in Visual Basic

>>> from xlcalcnet import Gpr
>>> Gpr.Log2p1(0.5)
Gpr('5.2359877559829887307E-1')
>>> Gpr.Log2p1('0.51')
Gpr('5.3518479027559984754E-1')

An example with real input:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 40; x = '1.0E-10'
>>> \mathrm{d}x = dec.log2p1(x); mx = mpm.log2p1(x); ix = ipm.log2p1(x)
>>> mpm.show([\mathrm{d}x, mx, ix])
dec:  1.442695040816828655320285494103165107641E-10
mpm:  1.442695040816828655320285494103165107641e-10
ipm:  1.442695040816828655320285494103165171947e-10 (1.121e-32%)

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 40; x = '1.0E-10'
>>> fx = fpm.log2p1(x); gx = gmp.log2p1(x); ax = apm.log2p1(x)
>>> mpm.show([fx, gx, ax])
fpm:  1.44269504081683E-10
gmp:  1.442695040816828655320285494103165107641E-10
apm:  1.442695040816828655320285494103165107641e-10 (3.705e-39%)

The following example with complex input shows that the relative error can be high in double precision:

>>> from xlcalcnet import dec, mpm, ipm
>>> mpm.dps = 20; z = '1.0E-10 + 1.57079632679489j'
>>> \mathrm{d}z = dec.log2p1(z); mz = mpm.log2p1(z); iz = ipm.log2p1(z)
>>> mpm.show([\mathrm{d}z, mz, iz], aligned=True)
dec: 8.9692736681258666009E-1              + 1.4482996540469440736E+0j
mpm: 8.9692736681258666009e-1              + 1.4482996540469440736e+0j
ipm: 8.9692736681258666009e-1 (3.305e-19%) + 1.4482996540469440736e+0 (4.679e-19%)j

>>> from xlcalcnet import mpm, fpm, gmp, apm
>>> mpm.dps = 20; z = '1.0E-10 + 1.57079632679489j'
>>> fz = fpm.log2p1(z); gz = gmp.log2p1(z); az = apm.log2p1(z)
>>> mpm.show([fz, gz, az], aligned=True)
fpm: 8.96927366812587E-01                  + 1.44829965404694E+00j
gmp: 8.9692736681258666009E-01             + 1.4482996540469440736E+00j
apm: 8.9692736681258666009e-1 (5.666e-19%) + 1.4482996540469440736e+0 (6.433e-19%)j

previous

Exponential and related functions

next

Power functions

Contents
  • Natural logarithm \(\log(x)\)
    • ctx.log()
  • Logarithm with base \(10\), \(\mathrm{log10}(x) = \log_{10}(x)\)
    • ctx.log10()
  • Logarithm with base \(2\), \(\mathrm{log2}(x) = \log_{2}(x)\)
    • ctx.log2()
  • Logarithm with base \(b\), \(\mathrm{logbase}(x, b) = \log_{b}(x)\)
    • ctx.logbase()
  • Auxiliary function \(\mathrm{log1p}(x) = \log(x+1)\)
    • ctx.log1p()
  • Auxiliary function \(\mathrm{log10p1}(x) = \log_{10}(1+x)\)
    • ctx.log10p1()
  • Auxiliary function \(\mathrm{log2p1}(x) = \log_2(1+x)\)
    • ctx.log2p1()

By Dietrich Hadler

© Copyright 2026, Dietrich Hadler. .

Last updated on Aug 19, 2026.