
public class MyMath
{






    public static double
    expm1(double x)
    {
        double u = Math.exp(x);
        if (u == 1.)
            return x;
        if (u-1. == -1.)
            return -1;
        return (u-1.)*x/Math.log(u);
    }






    public static double
    log1p(double x)
    {
        double u = 1.+x;
        return Math.log(u) - ((u-1.)-x)/u;
    }

    public static double
    sinh(double x)
    {



        double u = expm1(x);
        return .5 * u / (u+1) * (u+2);
    }

    public static double
    cosh(double x)
    {



        double e_x = Math.exp(x);
        return (e_x + 1./e_x) * .5;
    }


    public static double
    coshm1(double x)
    {





        double u = expm1(x);
        return .5 * u / (u+1) * u;
    }

    public static double
    tanh(double x)
    {

        double u = expm1(x);
        return u / (u*(u+2.)+2.) * (u+2.);


    }


    public static double
    asinh(double x)
    {






        return log1p(x * (1. + x / (Math.sqrt(x*x+1.)+1.)));
    }

    public static double
    acosh(double x)
    {







        return 2 * Math.log(Math.sqrt((x+1)*.5) + Math.sqrt((x-1)*.5));
    }

    public static double
    atanh(double x)
    {






        return .5 * log1p(2.*x/(1.-x));
    }


    public static double
    cosf1(double x)
    {
        double sinHalfX = Math.sin(.5*x);
        return 2.*sinHalfX*sinHalfX;
    }

    public static double
    acos1m(double x)
    {
        return 2.*Math.asin(Math.sqrt(.5*x));
    }


    public static double
    sin_over_x(double x)
    {





        if (1. - x*x*(1/6.) == 1.)
        {

            return 1.;
        }
        else
            return Math.sin(x)/x;
    }


    public static double
    asin_over_x(double x)
    {

        if (1. + x*x*(1/3.) == 1.)
            return 1.;
        else
            return Math.asin(x)/x;
    }



    public static double
    cosf1_over_x(double x)
    {

        if (1. - x*x*(1/6.) == 1.)
        {

            return .5*x;
        }
        else
            return cosf1(x) / x;
    }

    public static double hypot(double x, double y)
    {
        x = Math.abs(x);
        y = Math.abs(y);
        double min, max;
        if (x < y)
        {
            min = x;
            max = y;
        }
        else
        {
            min = y;
            max = x;
        }
        if (min == 0.)
            return max;
        double min_max = min/max;
        return max * Math.sqrt(1. + min_max * min_max);
    }
}
