Langevin Function: Accurate Evaluation

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


Updated 28 Sep 2012

View License

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 (2023). Langevin Function: Accurate Evaluation (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes