Langevin Function: Accurate Evaluation

Compute accurate values of the Langevin function (coth(x)-1/x) over its entire domain (-inf<x<inf).

You are now following this Submission

The Langevin function arises frequently in the mathematical physics of electromagnetism. It is an entire function, defined by a simple formula:

L(x) = coth(x) - 1/x ,

with a limiting value of 0 at x=0.

The function is mathematically well conditioned, but the defining formula is not well suited for numerical evaluation for 'x' close to 0. A rapidly converging, and numerically stable, continued-fraction approximation is utlized instead for 0<|x|<1.

Numerical benchmarking suggests that the double-precision relative accuracy is roughly 15 decimal digits over all of -inf<x<inf.

Cite As

Chuck Gartland (2026). Langevin Function: Accurate Evaluation (https://www.mathworks.com/matlabcentral/fileexchange/38405-langevin-function-accurate-evaluation), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0