#include "fermi_dirac.h"

#include <cmath>

namespace tbplas::tbpm {

double fermi_dirac(const double& beta, const double& mu, const double& x)
{
    double fd = 0.0;
    double tmp = 0.0;
    if (x >= mu) {
        tmp = std::exp(beta * (mu - x));
        fd = tmp / (1.0 + tmp);
    } else {
        tmp = std::exp(beta * (x - mu));
        fd = 1.0 / (1.0 + tmp);
    }
    return fd;
}
} // namespace tbplas::tbpm