Example #1
0
def z_am(u, m):
    """Jacobi amplitude function (eq 16.1.5, [Abramowitz]_)."""
    snM = ellipfun('sn', u=u, m=m)
    cnM = ellipfun('cn', u=u, m=m)
    if (0 <= cnM <= 1):
        phi = mp.asin(snM)
    elif (-1 <= cnM < 0):
        if (snM >= 0):
            phi = mp.pi - mp.asin(snM)
        else:
            phi = mp.asin(snM) - mp.pi
    else:
        print("This function only handles real 'phi' values.")
    return phi
Example #2
0
def z_am(u, m):
    """Jacobi amplitude function (eq 16.1.5, [Abramowitz]_)."""
    snM = ellipfun('sn', u=u, m=m)
    cnM = ellipfun('cn', u=u, m=m)
    if (0 <= cnM <= 1):
        phi = mp.asin(snM)
    elif (-1 <= cnM < 0):
        if (snM >= 0):
            phi = mp.pi - mp.asin(snM)
        else:
            phi = mp.asin(snM) - mp.pi
    else:
        print "This function only handles real 'phi' values."
    return phi
Example #3
0
def z_Zolotarev(N, x, m):
    r"""
    Function to evaluate the Zolotarev polynomial (eq 1, [McNamara93]_).
    
    :param N:    Order of the Zolotarev polynomial
    :param x:    The argument at which one would like to evaluate the Zolotarev polynomial
    :param m:    m is the elliptic parameter (not the modulus k and not the nome q)
                  
    :rtype:      Returns a float, the value of Zolotarev polynomial at x
    """
    M = -ellipk(m) / N
    x3 = ellipfun('sn', u=-M, m=m)
    xbar = x3 * mp.sqrt(
        (x**2 - 1) / (x**2 - x3**2))  # rearranged eq 21, [Levy70]_
    u = ellipf(mp.asin(xbar),
               m)  # rearranged eq 20, [Levy70]_, asn(x) = F(asin(x)|m)
    f = mp.cosh((N / 2) * mp.log(z_eta(M + u, m) / z_eta(M - u, m)))
    if f.imag / f.real > 1e-10:
        print("imaginary part of the Zolotarev function is not negligible!")
        print("f_imaginary = ", f.imag)
    else:
        if (x > 0):  # no idea why I am doing this ... anyhow, it seems working
            f = -f.real
        else:
            f = f.real
    return f
Example #4
0
def z_am(u, m):
    r"""
    A function evaluate Jacobi amplitude function (eq 16.1.5, [Abramowitz]_).
    
    :param u:    Argument u
    :param m:    m is the elliptic parameter (not the modulus k and not the nome q)
                  
    :rtype:      Returns a float,  Jacobi amplitude function evaluated for the argument `u` and parameter `m`
    """
    snM = ellipfun('sn', u=u, m=m)
    cnM = ellipfun('cn', u=u, m=m)
    if (0 <= cnM <= 1):
        phi = mp.asin(snM)
    elif (-1 <= cnM < 0):
        if (snM >= 0):
            phi = mp.pi - mp.asin(snM)
        else:
            phi = mp.asin(snM) - mp.pi
    else:
        print("This function only handles real 'phi' values.")
    return phi
Example #5
0
def z_am(u, m):
    r"""
    A function evaluate Jacobi amplitude function (eq 16.1.5, [Abramowitz]_).
    
    :param u:    Argument u
    :param m:    m is the elliptic parameter (not the modulus k and not the nome q)
                  
    :rtype:      Returns a float,  Jacobi amplitude function evaluated for the argument `u` and parameter `m`
    """
    snM = ellipfun('sn', u=u, m=m)
    cnM = ellipfun('cn', u=u, m=m)
    if (0 <= cnM <= 1):
        phi = mp.asin(snM)
    elif (-1 <= cnM < 0):
        if (snM >= 0):
            phi = mp.pi - mp.asin(snM)
        else:
            phi = mp.asin(snM) - mp.pi
    else:
        print "This function only handles real 'phi' values."
    return phi
Example #6
0
def z_Zolotarev(N, x, m):
    """Function to evaluate the Zolotarev polynomial (eq 1, [McNamara93]_)."""
    M = -ellipk(m) / N
    x3 = ellipfun('sn', u= -M, m=m)  
    xbar = x3 * mp.sqrt((x ** 2 - 1) / (x ** 2 - x3 ** 2)) # rearranged eq 21, [Levy70]_
    u = ellipf(mp.asin(xbar), m) # rearranged eq 20, [Levy70]_, asn(x) = F(asin(x)|m)     
    f = mp.cosh((N / 2) * mp.log(z_eta(M + u, m) / z_eta(M - u, m)))
    if (f.imag / f.real > 1e-10):
        print "imaginary part of the Zolotarev function is not negligible!"
        print "f_imaginary = ", f.imag
    else:
        if (x > 0): # no idea why I am doing this ... anyhow, it seems working
            f = -f.real  
        else:
            f = f.real        
    return f
Example #7
0
def z_Zolotarev(N, x, m):
    """Function to evaluate the Zolotarev polynomial (eq 1, [McNamara93]_)."""
    M = -ellipk(m) / N
    x3 = ellipfun('sn', u=-M, m=m)
    xbar = x3 * mp.sqrt(
        (x**2 - 1) / (x**2 - x3**2))  # rearranged eq 21, [Levy70]_
    u = ellipf(mp.asin(xbar),
               m)  # rearranged eq 20, [Levy70]_, asn(x) = F(asin(x)|m)
    f = mp.cosh((N / 2) * mp.log(z_eta(M + u, m) / z_eta(M - u, m)))
    if (f.imag / f.real > 1e-10):
        print("imaginary part of the Zolotarev function is not negligible!")
        print("f_imaginary = ", f.imag)
    else:
        if (x > 0):  # no idea why I am doing this ... anyhow, it seems working
            f = -f.real
        else:
            f = f.real
    return f
Example #8
0
def z_Zolotarev(N, x, m):
    r"""
    Function to evaluate the Zolotarev polynomial (eq 1, [McNamara93]_).
    
    :param N:    Order of the Zolotarev polynomial
    :param x:    The argument at which one would like to evaluate the Zolotarev polynomial
    :param m:    m is the elliptic parameter (not the modulus k and not the nome q)
                  
    :rtype:      Returns a float, the value of Zolotarev polynomial at x
    """
    M = -ellipk(m) / N
    x3 = ellipfun('sn', u= -M, m=m)  
    xbar = x3 * mp.sqrt((x ** 2 - 1) / (x ** 2 - x3 ** 2)) # rearranged eq 21, [Levy70]_
    u = ellipf(mp.asin(xbar), m) # rearranged eq 20, [Levy70]_, asn(x) = F(asin(x)|m)     
    f = mp.cosh((N / 2) * mp.log(z_eta(M + u, m) / z_eta(M - u, m)))
    if (f.imag / f.real > 1e-10):
        print "imaginary part of the Zolotarev function is not negligible!"
        print "f_imaginary = ", f.imag
    else:
        if (x > 0): # no idea why I am doing this ... anyhow, it seems working
            f = -f.real  
        else:
            f = f.real        
    return f