module MathFuns

export Eb, deltafun, deltadxfun, dabs

"""
    Eb(x,m)

compute ``\\sqrt{(x^2+m)}``
"""
function Eb(x, m2)
    sqrt(x^2 + m2)
end


"""
    deltafun(x,dϵ=0.02)
compute ``\\delta`` function with the approximation ``\\frac{\\epsilon}{\\pi(\\epsilon^2+x^2)}``
and ``\\epsilon`` is set to be ``0.02`` by default
"""
deltafun(x, dϵ = 1.0) = dϵ / (pi * (dϵ^2 + x^2))


function deltadxfun(x, ϵ = 1.0)
    (-2 * x * ϵ) / (pi * (x^2 + ϵ^2)^2)
end

function dabs(x)
    if x > 0.0
        return 1.0
    elseif x < 0.0
        return -1.0
    elseif x == 0.0
        return 0.0
    end
end


end