Example #1
0
def z_zn(u, m):
    r"""
    A function evaluate Jacobi Zeta (zn(u,m)) function (eq 16.26.12, [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 Zeta function evaluated for the argument `u` and parameter `m`
    """
    phi = z_am(u, m)
    zn = ellipe(phi, m) - ellipe(m) * u / ellipk(m)
    return zn
Example #2
0
def z_zn(u, m):
    r"""
    A function evaluate Jacobi Zeta (zn(u,m)) function (eq 16.26.12, [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 Zeta function evaluated for the argument `u` and parameter `m`
    """
    phi = z_am(u, m)
    zn = ellipe(phi, m) - ellipe(m) * u / ellipk(m)
    return zn
Example #3
0
def calc_t_r(qr, r1, r2, r3, r4, En, Lz, aa, M=1):
    """
    delta_t_r in Drasco and Hughes (2005)

    Parameters:
        qr (float)
        r1 (float): radial root
        r2 (float): radial root
        r3 (float): radial root
        r4 (float): radial root
        En (float): energy
        Lz (float): angular momentum
        aa (float): spin

    Keyword Args:
        M (float): mass

    Returns:
        t_r (float)
    """
    pi = mp.pi
    psi_r = calc_psi_r(qr, r1, r2, r3, r4)

    kr = ((r1 - r2) * (r3 - r4)) / ((r1 - r3) * (r2 - r4))

    rp = M + sqrt(-(aa**2) + M**2)
    rm = M - sqrt(-(aa**2) + M**2)

    hr = (r1 - r2) / (r1 - r3)
    hp = ((r1 - r2) * (r3 - rp)) / ((r1 - r3) * (r2 - rp))
    hm = ((r1 - r2) * (r3 - rm)) / ((r1 - r3) * (r2 - rm))

    return -((En *
              ((-4 * (r2 - r3) *
                (-(((-2 * aa**2 + (4 - (aa * Lz) / En) * rm) *
                    ((qr * ellippi(hm, kr)) / pi - ellippi(hm, psi_r, kr))) /
                   ((r2 - rm) * (r3 - rm))) +
                 ((-2 * aa**2 + (4 - (aa * Lz) / En) * rp) *
                  ((qr * ellippi(hp, kr)) / pi - ellippi(hp, psi_r, kr))) /
                 ((r2 - rp) * (r3 - rp)))) / (-rm + rp) + 4 * (r2 - r3) *
               ((qr * ellippi(hr, kr)) / pi - ellippi(hr, psi_r, kr)) +
               (r2 - r3) * (r1 + r2 + r3 + r4) *
               ((qr * ellippi(hr, kr)) / pi - ellippi(hr, psi_r, kr)) +
               (r1 - r3) * (r2 - r4) *
               ((qr * ellipe(kr)) / pi - ellipe(psi_r, kr) +
                (hr * cos(psi_r) * sin(psi_r) * sqrt(1 - kr * sin(psi_r)**2)) /
                (1 - hr * sin(psi_r)**2)))) / sqrt(
                    (1 - En**2) * (r1 - r3) * (r2 - r4)))
Example #4
0
def energy_density_at_origin(k):
    K = complex64(ellipk(k**2))
    E = complex64(ellipe(k**2))
    k1 = sqrt(1-k**2)

    A = 32*(k**2 *(-K**2 * k**2 +E**2-4*E*K+3* K**2 + k**2)-2*(E-K)**2)**2/(k**8 * K**4 * k1**2)

    return A.real
Example #5
0
def energy_density_at_origin(k):
    K = complex64(ellipk(k**2))
    E = complex64(ellipe(k**2))
    k1 = sqrt(1-k**2)

    A = 32*(k**2 *(-K**2 * k**2 +E**2-4*E*K+3* K**2 + k**2)-2*(E-K)**2)**2/(k**8 * K**4 * k1**2)

    return A.real
Example #6
0
def testing_components_energy_density(k, x1, x2, x3):

    if (is_awc_multiple_root(k, x1, x2, x3)):
        return 4

    if (is_awc_branch_point(k, x1, x2, x3)):
        return 4

    zeta = calc_zeta(k, x1, x2, x3)
    eta = calc_eta(k, x1, x2, x3)
    abel = calc_abel(k, zeta, eta)
    mu = calc_mu(k, x1, x2, x3, zeta, abel)
    x = [x1, x2, x3]

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm = (2 * E - K) / K

    k1 = sqrt(1 - k**2)

    xp = x[0] + complex(0, 1) * x[1]
    xm = x[0] - complex(0, 1) * x[1]
    S = sqrt(K**2 - 4 * xp * xm)
    SP = sqrt(K**2 - 4 * xp**2)
    SM = sqrt(K**2 - 4 * xm**2)
    SPM = sqrt(-k1**2 * (K**2 * k**2 - 4 * xm * xp) + (xm - xp)**2)
    R = 2 * K**2 * k1**2 - S**2 - 8 * x[2]**2
    RM = complex(0, 1) * SM**2 * (xm * (2 * k1**2 - 1) +
                                  xp) - (16 * complex(0, 1)) * xm * x[2]**2
    RP = complex(0, 1) * SM**2 * (xp * (2 * k1**2 - 1) +
                                  xm) + (16 * complex(0, 1)) * xp * x[2]**2
    RMBAR = -complex(0, 1) * SP**2 * (xp *
                                      (2 * k1**2 - 1) + xm) + 16 * complex(
                                          0, 1) * xp * x[2]**2
    RPBAR = -complex(0, 1) * SP**2 * (xm *
                                      (2 * k1**2 - 1) + xp) - 16 * complex(
                                          0, 1) * xm * x[2]**2
    r = sqrt(x[0]**2 + x[1]**2 + x[2]**2)

    DM = dmus(zeta, x, k)
    DZ = dzetas(zeta, x, k)
    DDM = ddmus(zeta, x, k)
    DDZ = ddzetas(zeta, x, k)

    GNUM = grams(zeta, mu, [x1, x2, x3], k)

    # DGS1 = dgrams1(zeta, mu, DM, DZ, x, k)
    #
    # DGS2 = dgrams2(zeta, mu, DM, DZ, x, k)
    #
    # DGS3 = dgrams3(zeta, mu, DM, DZ, x, k)

    # return  exp(-6 * mu[0])
    print zeta, '\n', abel, '\n', mu, '\n'  #mu[0], abel[0], exp(-6*mu[0])
    return
Example #7
0
def calc_t_z(qz, zp, zm, En, aa):
    """
    delta_t_theta in Drasco and Hughes (2003?)

    Parameters:
        qz (float)
        zp (float): polar root
        zm (float): polar root
        En (float): energy
        aa (float): spin

    Returns:
        t_z (float)
    """
    psi_z = calc_psi_z(qz, zp, zm, En, aa)
    ktheta = (aa**2 * (1 - En**2) * zm**2) / zp**2
    return (En * zp * ((2 * (pi / 2.0 + qz) * ellipe(ktheta)) / pi -
                       ellipe(psi_z, ktheta))) / (1 - En**2)
Example #8
0
def one_side(x,y):
    m = ((-1 + x)*(1 + y))/((1 + x)*(-1 + y))
    k = sqrt(m)
    u = asin(1/k)
    EE = ellipe(m)
    EF = re(ellipf(u,m))
    n = (-1 + x)/(-1 + y)
    EPI = ellippi(n/m,1/m)/k
    #EPI = ellippi(n,u,m)
    return re(-(EE*(1 + x)*(-1 + y) + (x - y)*(EF + EPI*(x-y) + EF*y))/sqrt(((1 + x)*(1 - y))))
Example #9
0
def dmus(zeta, x, k):

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm= (2*E-K)/K

    k1 = sqrt(1-k**2)

    xp = x[0]+complex(0,1)*x[1]
    xm = x[0]-complex(0,1)*x[1]
    S =  sqrt(K**2-4*xp*xm)
    SP = sqrt(K**2-4*xp**2)
    SM = sqrt(K**2-4*xm**2)
    SPM = sqrt(-k1**2*(K**2*k**2-4*xm*xp)+(xm-xp)**2)
    R = 2*K**2*k1**2-S**2-8*x[2]**2
    RM = complex(0,1)*SM**2*(xm*(2*k1**2-1)+xp)-(16*complex(0,1))*xm*x[2]**2
    RP = complex(0,1)*SM**2*(xp*(2*k1**2-1)+xm)+(16*complex(0,1))*xp*x[2]**2
    RMBAR=-complex(0,1)*SP**2*( xp*(2*k1**2-1)+xm ) +16*complex(0,1)*xp*x[2]**2
    RPBAR=-complex(0,1)*SP**2*( xm*(2*k1**2-1)+xp ) -16*complex(0,1)*xm*x[2]**2
    r=sqrt(x[0]**2+x[1]**2+x[2]**2)

    DM = [None,None,None,None]

    DM[0] = [None]*3
    DM[1] = [None]*3
    DM[2] = [None]*3
    DM[3] = [None]*3

    DM[0][0] = complex(0, 1) * (E * K * zeta[0] ** 2 - K ** 2 * zeta[0] ** 2 + 4 * zeta[0] ** 2 * x[0] ** 2 + complex(0, -4) * zeta[0] ** 2 * x[1] * x[0] + E * K - K ** 2 + 4 * x[0] ** 2 + complex(0, -8) * zeta[0] * x[2] * x[0] + complex(0, 4) * x[0] * x[1]) / (4 * zeta[0] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[0] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[0] - K ** 2 * zeta[0] ** 3 + 4 * x[0] ** 2 * zeta[0] + complex(0, -12) * zeta[0] ** 2 * x[0] * x[2] - 4 * zeta[0] ** 3 * x[1] ** 2 - 12 * zeta[0] ** 2 * x[1] * x[2] - K ** 2 * zeta[0] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[0] - 8 * zeta[0] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[1][0] = complex(0, 1) * (E * K * zeta[1] ** 2 - K ** 2 * zeta[1] ** 2 + 4 * zeta[1] ** 2 * x[0] ** 2 + complex(0, -4) * zeta[1] ** 2 * x[1] * x[0] + E * K - K ** 2 + 4 * x[0] ** 2 + complex(0, -8) * zeta[1] * x[2] * x[0] + complex(0, 4) * x[0] * x[1]) / (4 * zeta[1] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[1] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[1] - K ** 2 * zeta[1] ** 3 + 4 * x[0] ** 2 * zeta[1] + complex(0, -12) * zeta[1] ** 2 * x[0] * x[2] - 4 * zeta[1] ** 3 * x[1] ** 2 - 12 * zeta[1] ** 2 * x[1] * x[2] - K ** 2 * zeta[1] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[1] - 8 * zeta[1] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[2][0] = complex(0, 1) * (E * K * zeta[2] ** 2 - K ** 2 * zeta[2] ** 2 + 4 * zeta[2] ** 2 * x[0] ** 2 + complex(0, -4) * zeta[2] ** 2 * x[1] * x[0] + E * K - K ** 2 + 4 * x[0] ** 2 + complex(0, -8) * zeta[2] * x[2] * x[0] + complex(0, 4) * x[0] * x[1]) / (4 * zeta[2] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[2] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[2] - K ** 2 * zeta[2] ** 3 + 4 * x[0] ** 2 * zeta[2] + complex(0, -12) * zeta[2] ** 2 * x[0] * x[2] - 4 * zeta[2] ** 3 * x[1] ** 2 - 12 * zeta[2] ** 2 * x[1] * x[2] - K ** 2 * zeta[2] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[2] - 8 * zeta[2] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[3][0] = complex(0, 1) * (E * K * zeta[3] ** 2 - K ** 2 * zeta[3] ** 2 + 4 * zeta[3] ** 2 * x[0] ** 2 + complex(0, -4) * zeta[3] ** 2 * x[1] * x[0] + E * K - K ** 2 + 4 * x[0] ** 2 + complex(0, -8) * zeta[3] * x[2] * x[0] + complex(0, 4) * x[0] * x[1]) / (4 * zeta[3] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[3] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[3] - K ** 2 * zeta[3] ** 3 + 4 * x[0] ** 2 * zeta[3] + complex(0, -12) * zeta[3] ** 2 * x[0] * x[2] - 4 * zeta[3] ** 3 * x[1] ** 2 - 12 * zeta[3] ** 2 * x[1] * x[2] - K ** 2 * zeta[3] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[3] - 8 * zeta[3] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[0][1] = (complex(0, 4) * zeta[0] ** 2 * x[1] * x[0] + E * K * zeta[0] ** 2 + 4 * zeta[0] ** 2 * x[1] ** 2 + complex(0, 4) * x[0] * x[1] + 8 * zeta[0] * x[1] * x[2] - E * K - 4 * x[1] ** 2) / (4 * zeta[0] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[0] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[0] - K ** 2 * zeta[0] ** 3 + 4 * x[0] ** 2 * zeta[0] + complex(0, -12) * zeta[0] ** 2 * x[0] * x[2] - 4 * zeta[0] ** 3 * x[1] ** 2 - 12 * zeta[0] ** 2 * x[1] * x[2] - K ** 2 * zeta[0] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[0] - 8 * zeta[0] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[1][1] = (complex(0, 4) * zeta[1] ** 2 * x[1] * x[0] + E * K * zeta[1] ** 2 + 4 * zeta[1] ** 2 * x[1] ** 2 + complex(0, 4) * x[0] * x[1] + 8 * zeta[1] * x[1] * x[2] - E * K - 4 * x[1] ** 2) / (4 * zeta[1] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[1] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[1] - K ** 2 * zeta[1] ** 3 + 4 * x[0] ** 2 * zeta[1] + complex(0, -12) * zeta[1] ** 2 * x[0] * x[2] - 4 * zeta[1] ** 3 * x[1] ** 2 - 12 * zeta[1] ** 2 * x[1] * x[2] - K ** 2 * zeta[1] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[1] - 8 * zeta[1] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[2][1] = (complex(0, 4) * zeta[2] ** 2 * x[1] * x[0] + E * K * zeta[2] ** 2 + 4 * zeta[2] ** 2 * x[1] ** 2 + complex(0, 4) * x[0] * x[1] + 8 * zeta[2] * x[1] * x[2] - E * K - 4 * x[1] ** 2) / (4 * zeta[2] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[2] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[2] - K ** 2 * zeta[2] ** 3 + 4 * x[0] ** 2 * zeta[2] + complex(0, -12) * zeta[2] ** 2 * x[0] * x[2] - 4 * zeta[2] ** 3 * x[1] ** 2 - 12 * zeta[2] ** 2 * x[1] * x[2] - K ** 2 * zeta[2] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[2] - 8 * zeta[2] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[3][1] = (complex(0, 4) * zeta[3] ** 2 * x[1] * x[0] + E * K * zeta[3] ** 2 + 4 * zeta[3] ** 2 * x[1] ** 2 + complex(0, 4) * x[0] * x[1] + 8 * zeta[3] * x[1] * x[2] - E * K - 4 * x[1] ** 2) / (4 * zeta[3] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[3] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[3] - K ** 2 * zeta[3] ** 3 + 4 * x[0] ** 2 * zeta[3] + complex(0, -12) * zeta[3] ** 2 * x[0] * x[2] - 4 * zeta[3] ** 3 * x[1] ** 2 - 12 * zeta[3] ** 2 * x[1] * x[2] - K ** 2 * zeta[3] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[3] - 8 * zeta[3] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[0][2] = 2 * (-K ** 2 * k1 ** 2 * zeta[0] + complex(0, 2) * zeta[0] ** 2 * x[0] * x[2] + 2 * zeta[0] ** 2 * x[1] * x[2] + E * K * zeta[0] + complex(0, 2) * x[0] * x[2] + 4 * zeta[0] * x[2] ** 2 - 2 * x[1] * x[2]) / (4 * zeta[0] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[0] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[0] - K ** 2 * zeta[0] ** 3 + 4 * x[0] ** 2 * zeta[0] + complex(0, -12) * zeta[0] ** 2 * x[0] * x[2] - 4 * zeta[0] ** 3 * x[1] ** 2 - 12 * zeta[0] ** 2 * x[1] * x[2] - K ** 2 * zeta[0] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[0] - 8 * zeta[0] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[1][2] = 2 * (-K ** 2 * k1 ** 2 * zeta[1] + complex(0, 2) * zeta[1] ** 2 * x[0] * x[2] + 2 * zeta[1] ** 2 * x[1] * x[2] + E * K * zeta[1] + complex(0, 2) * x[0] * x[2] + 4 * zeta[1] * x[2] ** 2 - 2 * x[1] * x[2]) / (4 * zeta[1] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[1] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[1] - K ** 2 * zeta[1] ** 3 + 4 * x[0] ** 2 * zeta[1] + complex(0, -12) * zeta[1] ** 2 * x[0] * x[2] - 4 * zeta[1] ** 3 * x[1] ** 2 - 12 * zeta[1] ** 2 * x[1] * x[2] - K ** 2 * zeta[1] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[1] - 8 * zeta[1] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[2][2] = 2 * (-K ** 2 * k1 ** 2 * zeta[2] + complex(0, 2) * zeta[2] ** 2 * x[0] * x[2] + 2 * zeta[2] ** 2 * x[1] * x[2] + E * K * zeta[2] + complex(0, 2) * x[0] * x[2] + 4 * zeta[2] * x[2] ** 2 - 2 * x[1] * x[2]) / (4 * zeta[2] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[2] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[2] - K ** 2 * zeta[2] ** 3 + 4 * x[0] ** 2 * zeta[2] + complex(0, -12) * zeta[2] ** 2 * x[0] * x[2] - 4 * zeta[2] ** 3 * x[1] ** 2 - 12 * zeta[2] ** 2 * x[1] * x[2] - K ** 2 * zeta[2] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[2] - 8 * zeta[2] * x[2] ** 2 + 4 * x[1] * x[2])

    DM[3][2] = 2 * (-K ** 2 * k1 ** 2 * zeta[3] + complex(0, 2) * zeta[3] ** 2 * x[0] * x[2] + 2 * zeta[3] ** 2 * x[1] * x[2] + E * K * zeta[3] + complex(0, 2) * x[0] * x[2] + 4 * zeta[3] * x[2] ** 2 - 2 * x[1] * x[2]) / (4 * zeta[3] ** 3 * x[0] ** 2 + complex(0, -8) * zeta[3] ** 3 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 * zeta[3] - K ** 2 * zeta[3] ** 3 + 4 * x[0] ** 2 * zeta[3] + complex(0, -12) * zeta[3] ** 2 * x[0] * x[2] - 4 * zeta[3] ** 3 * x[1] ** 2 - 12 * zeta[3] ** 2 * x[1] * x[2] - K ** 2 * zeta[3] + complex(0, -4) * x[0] * x[2] + 4 * x[1] ** 2 * zeta[3] - 8 * zeta[3] * x[2] ** 2 + 4 * x[1] * x[2])

    return DM
Example #10
0
def dzetas(zeta, x, k):

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm= (2*E-K)/K

    k1 = sqrt(1-k**2)

    xp = x[0]+complex(0,1)*x[1]
    xm = x[0]-complex(0,1)*x[1]
    S =  sqrt(K**2-4*xp*xm)
    SP = sqrt(K**2-4*xp**2)
    SM = sqrt(K**2-4*xm**2)
    SPM = sqrt(-k1**2*(K**2*k**2-4*xm*xp)+(xm-xp)**2)
    R = 2*K**2*k1**2-S**2-8*x[2]**2
    RM = complex(0,1)*SM**2*(xm*(2*k1**2-1)+xp)-(16*complex(0,1))*xm*x[2]**2
    RP = complex(0,1)*SM**2*(xp*(2*k1**2-1)+xm)+(16*complex(0,1))*xp*x[2]**2
    RMBAR=-complex(0,1)*SP**2*( xp*(2*k1**2-1)+xm ) +16*complex(0,1)*xp*x[2]**2
    RPBAR=-complex(0,1)*SP**2*( xm*(2*k1**2-1)+xp ) -16*complex(0,1)*xm*x[2]**2
    r=sqrt(x[0]**2+x[1]**2+x[2]**2)

    DZ = [None]*4
    DZ[0] = [None]*3
    DZ[1] = [None]*3
    DZ[2] = [None]*3
    DZ[3] = [None]*3

    DZ[0][0] = -2 * ((x[1] + complex(0, 1) * x[0]) * zeta[0] ** 2 + 2 * x[2] * zeta[0] - x[1] + complex(0, 1) * x[0]) * (complex(0, 1) * zeta[0] ** 2 + complex(0, 1)) / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[0] ** 2 + 2 * x[2] * zeta[0] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[0] + 2 * x[2]) + K ** 2 * (4 * zeta[0] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[0]) / 4)

    DZ[1][0] = -2 * ((x[1] + complex(0, 1) * x[0]) * zeta[1] ** 2 + 2 * zeta[1] * x[2] - x[1] + complex(0, 1) * x[0]) * (complex(0, 1) * zeta[1] ** 2 + complex(0, 1)) / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[1] ** 2 + 2 * zeta[1] * x[2] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[1] + 2 * x[2]) + K ** 2 * (4 * zeta[1] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[1]) / 4)

    DZ[2][0] = -2 * ((x[1] + complex(0, 1) * x[0]) * zeta[2] ** 2 + 2 * x[2] * zeta[2] - x[1] + complex(0, 1) * x[0]) * (complex(0, 1) * zeta[2] ** 2 + complex(0, 1)) / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[2] ** 2 + 2 * x[2] * zeta[2] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[2] + 2 * x[2]) + K ** 2 * (4 * zeta[2] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[2]) / 4)

    DZ[3][0] = -2 * ((x[1] + complex(0, 1) * x[0]) * zeta[3] ** 2 + 2 * zeta[3] * x[2] - x[1] + complex(0, 1) * x[0]) * (complex(0, 1) * zeta[3] ** 2 + complex(0, 1)) / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[3] ** 2 + 2 * zeta[3] * x[2] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[3] + 2 * x[2]) + K ** 2 * (4 * zeta[3] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[3]) / 4)

    DZ[0][1] = -2 * ((x[1] + complex(0, 1) * x[0]) * zeta[0] ** 2 + 2 * x[2] * zeta[0] - x[1] + complex(0, 1) * x[0]) * (zeta[0] ** 2 - 1) / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[0] ** 2 + 2 * x[2] * zeta[0] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[0] + 2 * x[2]) + K ** 2 * (4 * zeta[0] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[0]) / 4)

    DZ[1][1] = -2 * ((x[1] + complex(0, 1) * x[0]) * zeta[1] ** 2 + 2 * zeta[1] * x[2] - x[1] + complex(0, 1) * x[0]) * (zeta[1] ** 2 - 1) / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[1] ** 2 + 2 * zeta[1] * x[2] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[1] + 2 * x[2]) + K ** 2 * (4 * zeta[1] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[1]) / 4)

    DZ[2][1] = -2 * ((x[1] + complex(0, 1) * x[0]) * zeta[2] ** 2 + 2 * x[2] * zeta[2] - x[1] + complex(0, 1) * x[0]) * (zeta[2] ** 2 - 1) / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[2] ** 2 + 2 * x[2] * zeta[2] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[2] + 2 * x[2]) + K ** 2 * (4 * zeta[2] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[2]) / 4)

    DZ[3][1] = -2 * ((x[1] + complex(0, 1) * x[0]) * zeta[3] ** 2 + 2 * zeta[3] * x[2] - x[1] + complex(0, 1) * x[0]) * (zeta[3] ** 2 - 1) / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[3] ** 2 + 2 * zeta[3] * x[2] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[3] + 2 * x[2]) + K ** 2 * (4 * zeta[3] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[3]) / 4)

    DZ[0][2] = -4 * ((x[1] + complex(0, 1) * x[0]) * zeta[0] ** 2 + 2 * x[2] * zeta[0] - x[1] + complex(0, 1) * x[0]) * zeta[0] / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[0] ** 2 + 2 * x[2] * zeta[0] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[0] + 2 * x[2]) + K ** 2 * (4 * zeta[0] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[0]) / 4)

    DZ[1][2] = -4 * ((x[1] + complex(0, 1) * x[0]) * zeta[1] ** 2 + 2 * zeta[1] * x[2] - x[1] + complex(0, 1) * x[0]) * zeta[1] / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[1] ** 2 + 2 * zeta[1] * x[2] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[1] + 2 * x[2]) + K ** 2 * (4 * zeta[1] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[1]) / 4)

    DZ[2][2] = -4 * ((x[1] + complex(0, 1) * x[0]) * zeta[2] ** 2 + 2 * x[2] * zeta[2] - x[1] + complex(0, 1) * x[0]) * zeta[2] / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[2] ** 2 + 2 * x[2] * zeta[2] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[2] + 2 * x[2]) + K ** 2 * (4 * zeta[2] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[2]) / 4)

    DZ[3][2] = -4 * ((x[1] + complex(0, 1) * x[0]) * zeta[3] ** 2 + 2 * zeta[3] * x[2] - x[1] + complex(0, 1) * x[0]) * zeta[3] / (2 * ((x[1] + complex(0, 1) * x[0]) * zeta[3] ** 2 + 2 * zeta[3] * x[2] - x[1] + complex(0, 1) * x[0]) * (2 * (x[1] + complex(0, 1) * x[0]) * zeta[3] + 2 * x[2]) + K ** 2 * (4 * zeta[3] ** 3 + 4 * (-2 * k1 ** 2 + 1) * zeta[3]) / 4)

    return DZ
Example #11
0
    def evaluate(self, time):
        """ 
        Calculate a light curve according to the analytical models
        given by Pal 2008.

        Parameters
        ----------
        time : array
            An array of time points at which the light curve
            shall be calculated.

        .. note:: time = 0 -> Planet is exactly in the line of sight (phase = 0).

        Returns
        -------
        Model : array
            The analytical light curve is stored in the property `lightcurve`.
        """

        # Translate the given parameters into an orbit and, finally,
        # into a projected, normalized distance (z-parameter)
        self._calcZList(time - self["T0"])

        # 'W' parameters corresponding to notation in Pal '08
        w = 6. - 2. * self["linLimb"] - self["quadLimb"]
        w0 = (6. - 6. * self["linLimb"] - 12. * self["quadLimb"]) / w
        w1 = (6. * self["linLimb"] + 12. * self["quadLimb"]) / w
        w2 = 6. * self["quadLimb"] / w

        # Initialize flux decrease array
        df = numpy.zeros(len(time))
        # Get a list of 'cases' (according to Pal '08). Depends on radius ratio and 'z'-parameter along the orbit
        ca = self._selectCases()
        # Loop through z-list, and calculate the light curve at each point in z (->time)
        for i in self._intrans:
            # Calculate the coefficients to be substituted into the Pal '08 equation
            c = self._returnCoeff(ca[i].step, self._zlist[i])
            # Substitute the coefficients and get 'flux decrease'
            if ca[i].step != 12:
                # Calculate flux decrease only if there is an occultation
                if not self.useBoost:
                    df[i] = w0 * c[0] + w2 * c[5] + w1 * (
                        c[1] + c[2] * mpmath.ellipk(c[6]**2) +
                        c[3] * mpmath.ellipe(c[6]**2) +
                        c[4] * mpmath.ellippi(c[7], c[6]**2))
                else:
                    df[i] = w0 * c[0] + w2 * c[5] + w1 * (
                        c[1] + c[2] * self.ell.ell1(c[6]) + c[3] *
                        self.ell.ell2(c[6]) + c[4] * self.ell.ell3(c[7], c[6]))
        self.lightcurve = (1. - df) * 1. / \
            (1. + self["b"]) + self["b"] / (1.0 + self["b"])
        return self.lightcurve
Example #12
0
def testing_components_energy_density(k, x1, x2, x3):


    if (is_awc_multiple_root(k, x1, x2, x3) ):
        return 4

    if (is_awc_branch_point(k, x1, x2, x3) ):
        return 4

    zeta = calc_zeta(k ,x1, x2, x3)
    eta = calc_eta(k, x1, x2, x3)
    abel = calc_abel(k, zeta, eta)
    mu = calc_mu(k, x1, x2, x3, zeta, abel)
    x=[x1,x2,x3]

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm= (2*E-K)/K

    k1 = sqrt(1-k**2)

    xp = x[0]+complex(0,1)*x[1]
    xm = x[0]-complex(0,1)*x[1]
    S =  sqrt(K**2-4*xp*xm)
    SP = sqrt(K**2-4*xp**2)
    SM = sqrt(K**2-4*xm**2)
    SPM = sqrt(-k1**2*(K**2*k**2-4*xm*xp)+(xm-xp)**2)
    R = 2*K**2*k1**2-S**2-8*x[2]**2
    RM = complex(0,1)*SM**2*(xm*(2*k1**2-1)+xp)-(16*complex(0,1))*xm*x[2]**2
    RP = complex(0,1)*SM**2*(xp*(2*k1**2-1)+xm)+(16*complex(0,1))*xp*x[2]**2
    RMBAR=-complex(0,1)*SP**2*( xp*(2*k1**2-1)+xm ) +16*complex(0,1)*xp*x[2]**2
    RPBAR=-complex(0,1)*SP**2*( xm*(2*k1**2-1)+xp ) -16*complex(0,1)*xm*x[2]**2
    r=sqrt(x[0]**2+x[1]**2+x[2]**2)

    DM = dmus(zeta, x, k)
    DZ = dzetas(zeta, x,k)
    DDM = ddmus(zeta, x, k)
    DDZ = ddzetas(zeta, x,k)

    GNUM = grams(zeta, mu, [x1, x2, x3], k)

    # DGS1 = dgrams1(zeta, mu, DM, DZ, x, k)
    #
    # DGS2 = dgrams2(zeta, mu, DM, DZ, x, k)
    #
    # DGS3 = dgrams3(zeta, mu, DM, DZ, x, k)

    # return  exp(-6 * mu[0])
    print zeta, '\n', abel,  '\n', mu, '\n' #mu[0], abel[0], exp(-6*mu[0])
    return
Example #13
0
 def xtau(phi):
     out = np.zeros((6, ))
     s, c, A, B = consts(phi)
     E = ellipe(asin(w * c), 1 / w)
     F = ellipf(asin(w * c), 1 / w)
     out[0] = -2 * A * (s**2 * B + w * s**3)  # x_D1
     out[1] = A * (w * E + 3 * w * c + 2 * s * c * B - 2 * w * c**3)  # y_D1
     out[3] = 2 * l * F / w - 3 * w * E * A - 3 * w * c * A  # y_D2
     out[4] = A * (B *
                   (2 * w**2 * c**2 - w**2 - 1) - 2 * w**3 * s**3 + 2 * w *
                   (w**2 - 1) * s)  # x_I
     out[5] = A * (w * E + 2 * w**2 * s * c * B - 2 * w**3 * c**3 + w * c *
                   (2 + w**2))  # y_I
     return out
Example #14
0
    def evaluate(self, time):
        """ 
        Calculate a light curve according to the analytical models
        given by Pal 2008.

        Parameters
        ----------
        time : array
            An array of time points at which the light curve
            shall be calculated.

        .. note:: time = 0 -> Planet is exactly in the line of sight (phase = 0).

        Returns
        -------
        Model : array
            The analytical light curve is stored in the property `lightcurve`.
        """

        # Translate the given parameters into an orbit and, finally,
        # into a projected, normalized distance (z-parameter)
        self._calcZList(time - self["T0"])

        # 'W' parameters corresponding to notation in Pal '08
        w = 6. - 2. * self["linLimb"] - self["quadLimb"]
        w0 = (6. - 6. * self["linLimb"] - 12. * self["quadLimb"]) / w
        w1 = (6. * self["linLimb"] + 12. * self["quadLimb"]) / w
        w2 = 6. * self["quadLimb"] / w

        # Initialize flux decrease array
        df = numpy.zeros(len(time))
        # Get a list of 'cases' (according to Pal '08). Depends on radius ratio and 'z'-parameter along the orbit
        ca = self._selectCases()
        # Loop through z-list, and calculate the light curve at each point in z (->time)
        for i in self._intrans:
            # Calculate the coefficients to be substituted into the Pal '08 equation
            c = self._returnCoeff(ca[i].step, self._zlist[i])
            # Substitute the coefficients and get 'flux decrease'
            if ca[i].step != 12:
                # Calculate flux decrease only if there is an occultation
                if not self.useBoost:
                    df[i] = w0 * c[0] + w2 * c[5] + w1 * (c[1] + c[2] * mpmath.ellipk(
                        c[6]**2) + c[3] * mpmath.ellipe(c[6]**2) + c[4] * mpmath.ellippi(c[7], c[6]**2))
                else:
                    df[i] = w0 * c[0] + w2 * c[5] + w1 * (c[1] + c[2] * self.ell.ell1(
                        c[6]) + c[3] * self.ell.ell2(c[6]) + c[4] * self.ell.ell3(c[7], c[6]))
        self.lightcurve = (1. - df) * 1. / \
            (1. + self["b"]) + self["b"] / (1.0 + self["b"])
        return self.lightcurve
Example #15
0
def mino_freqs_sc(slr, ecc, x):
    """
    Mino frequencies for the SC case (aa = 0)

    Parameters:
        slr (float): semi-latus rectum
        ecc (float): eccentricity
        x (float): inclincation

    Returns:
        ups_r (float): radial Mino frequency
        ups_theta (float): polar Mino frequency
        ups_phi (float): azimuthal Mino frequency
        gamma (float): time Mino frequency
    """
    pi = mp.pi
    ups_r = (pi * sqrt(-((slr * (-6 + 2 * ecc + slr)) /
                         (3 + ecc**2 - slr)))) / (2 * ellipk(
                             (4 * ecc) / (-6 + 2 * ecc + slr)))
    ups_theta = slr / sqrt(-3 - ecc**2 + slr)
    ups_phi = (slr * x) / (sqrt(-3 - ecc**2 + slr) * abs(x))
    gamma = (sqrt(
        (-4 * ecc**2 + (-2 + slr)**2) / (slr * (-3 - ecc**2 + slr))) *
             (8 + (-(((-4 + slr) * slr**2 * (-6 + 2 * ecc + slr) * ellipe(
                 (4 * ecc) / (-6 + 2 * ecc + slr))) / (-1 + ecc**2)) +
                   (slr**2 * (28 + 4 * ecc**2 - 12 * slr + slr**2) * ellipk(
                       (4 * ecc) / (-6 + 2 * ecc + slr))) / (-1 + ecc**2) -
                   (2 * (6 + 2 * ecc - slr) *
                    (3 + ecc**2 - slr) * slr**2 * ellippi(
                        (2 * ecc * (-4 + slr)) / ((1 + ecc) *
                                                  (-6 + 2 * ecc + slr)),
                        (4 * ecc) / (-6 + 2 * ecc + slr),
                    )) / ((-1 + ecc) * (1 + ecc)**2) +
                   (4 * (-4 + slr) * slr * (2 * (1 + ecc) * ellipk(
                       (4 * ecc) /
                       (-6 + 2 * ecc + slr)) + (-6 - 2 * ecc + slr) * ellippi(
                           (2 * ecc * (-4 + slr)) / ((1 + ecc) *
                                                     (-6 + 2 * ecc + slr)),
                           (4 * ecc) / (-6 + 2 * ecc + slr),
                       ))) / (1 + ecc) + 2 * (-4 + slr)**2 *
                   ((-4 + slr) * ellipk((4 * ecc) / (-6 + 2 * ecc + slr)) -
                    ((6 + 2 * ecc - slr) * slr * ellippi(
                        (16 * ecc) /
                        (12 + 8 * ecc - 4 * ecc**2 - 8 * slr + slr**2),
                        (4 * ecc) / (-6 + 2 * ecc + slr),
                    )) / (2 + 2 * ecc - slr))) / ((-4 + slr)**2 * ellipk(
                        (4 * ecc) / (-6 + 2 * ecc + slr))))) / 2.0

    return ups_r, ups_theta, ups_phi, gamma
Example #16
0
def higgs_squared(k, x1, x2, x3):

    if (is_awc_multiple_root(k, x1, x2, x3)):
        return float(255) / float(256)

    if (is_awc_branch_point(k, x1, x2, x3)):
        return float(255) / float(256)

    zeta = calc_zeta(k, x1, x2, x3)
    eta = calc_eta(k, x1, x2, x3)
    abel = calc_abel(k, zeta, eta)
    mu = calc_mu(k, x1, x2, x3, zeta, abel)
    x = [x1, x2, x3]

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm = (2 * E - K) / K

    k1 = sqrt(1 - k**2)

    xp = x[0] + complex(0, 1) * x[1]
    xm = x[0] - complex(0, 1) * x[1]
    S = sqrt(K**2 - 4 * xp * xm)
    SP = sqrt(K**2 - 4 * xp**2)
    SM = sqrt(K**2 - 4 * xm**2)
    SPM = sqrt(-k1**2 * (K**2 * k**2 - 4 * xm * xp) + (xm - xp)**2)
    R = 2 * K**2 * k1**2 - S**2 - 8 * x[2]**2
    RM = complex(0, 1) * SM**2 * (xm * (2 * k1**2 - 1) +
                                  xp) - (16 * complex(0, 1)) * xm * x[2]**2
    RP = complex(0, 1) * SM**2 * (xp * (2 * k1**2 - 1) +
                                  xm) + (16 * complex(0, 1)) * xp * x[2]**2
    RMBAR = -complex(0, 1) * SP**2 * (xp *
                                      (2 * k1**2 - 1) + xm) + 16 * complex(
                                          0, 1) * xp * x[2]**2
    RPBAR = -complex(0, 1) * SP**2 * (xm *
                                      (2 * k1**2 - 1) + xp) - 16 * complex(
                                          0, 1) * xm * x[2]**2
    r = sqrt(x[0]**2 + x[1]**2 + x[2]**2)

    GNUM = grams(zeta, mu, [x1, x2, x3], k)

    inv_gram = matrix(GNUM).I

    higgs = phis(zeta, mu, [x1, x2, x3], k)

    return -(trace(matmul(matmul(higgs, inv_gram), matmul(higgs,
                                                          inv_gram))).real) / 2
Example #17
0
def calc_arclength_coeff(amp):
	# Arc length of sinusoidal surface from 0 to pi/2 (one quarter wave)
	# is Complete Elliptic Integral of Second Kind, E(m)
	# The argument m is m = -A^2, where A is amplitude of sinusoid.
	
	amplitude = float(amp)
	m = - amplitude*amplitude
	
	arclength = mpmath.ellipe(m)
	
	domainlength = mpmath.pi()/2
	
	arc_coeff = float(arclength/domainlength)
	
	return arc_coeff
Example #18
0
def higgs_squared(k, x1, x2, x3):

    if (is_awc_multiple_root(k, x1, x2, x3) ):
        return float(255)/float(256)

    if (is_awc_branch_point(k, x1, x2, x3) ):
        return float(255)/float(256)

    zeta = calc_zeta(k ,x1, x2, x3)
    eta = calc_eta(k, x1, x2, x3)
    abel = calc_abel(k, zeta, eta)
    mu = calc_mu(k, x1, x2, x3, zeta, abel)
    x=[x1,x2,x3]

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm= (2*E-K)/K

    k1 = sqrt(1-k**2)

    xp = x[0]+complex(0,1)*x[1]
    xm = x[0]-complex(0,1)*x[1]
    S =  sqrt(K**2-4*xp*xm)
    SP = sqrt(K**2-4*xp**2)
    SM = sqrt(K**2-4*xm**2)
    SPM = sqrt(-k1**2*(K**2*k**2-4*xm*xp)+(xm-xp)**2)
    R = 2*K**2*k1**2-S**2-8*x[2]**2
    RM = complex(0,1)*SM**2*(xm*(2*k1**2-1)+xp)-(16*complex(0,1))*xm*x[2]**2
    RP = complex(0,1)*SM**2*(xp*(2*k1**2-1)+xm)+(16*complex(0,1))*xp*x[2]**2
    RMBAR=-complex(0,1)*SP**2*( xp*(2*k1**2-1)+xm ) +16*complex(0,1)*xp*x[2]**2
    RPBAR=-complex(0,1)*SP**2*( xm*(2*k1**2-1)+xp ) -16*complex(0,1)*xm*x[2]**2
    r=sqrt(x[0]**2+x[1]**2+x[2]**2)

    GNUM = grams(zeta, mu, [x1, x2, x3], k)

    inv_gram = matrix(GNUM).I

    higgs = phis(zeta, mu, [x1, x2, x3], k)

    # print GNUM, inv_gram, higgs # for testing

    return  -(trace(matmul( matmul(higgs, inv_gram),  matmul(higgs, inv_gram) )).real)/2
Example #19
0
def loop(R, Z, I0, Ra, N_windings):
    mu0 = 4.0e-7 * np.pi
    alfa = R / Ra
    beta = Z / Ra
    gamma = Z / R
    Q = (1 + alfa)**2 + beta**2

    ksq = 4.0 * alfa / Q

    K = mp.ellipk(ksq)
    E = mp.ellipe(ksq)

    B0 = mu0 / 2.0 / Ra * I0 * N_windings
    Br = gamma * B0 / np.pi / np.sqrt(Q) * (E * (1 + alfa**2 + beta**2) /
                                            (Q - 4 * alfa) - K)
    Bz = B0 / np.pi / np.sqrt(Q) * (E * (1 - alfa**2 - beta**2) /
                                    (Q - 4 * alfa) + K)

    return Br, Bz
Example #20
0
def psi_x(z, x, beta):
    """
    Eq.(24) from Ref[1] with argument zeta=0 and no constant factor e*beta**2/2/rho**2.
    Note that 'x' here corresponds to 'chi = x/rho', 
    and 'z' here corresponds to 'xi = z/2/rho' in the paper. 
    """
    kap = kappa(z, x, beta)
    alp = alpha(z, x, beta)
    arg2 = -4 * (1 + x) / x**2

    T1 = (1 / fabs(x) / (1 + x) *
          ((2 + 2 * x + x**2) * ellipf(alp, arg2) - x**2 * ellipe(alp, arg2)))
    D = kap**2 - beta**2 * (1 + x)**2 * sin(2 * alp)**2
    T2 = ((kap**2 - 2 * beta**2 * (1 + x)**2 + beta**2 * (1 + x) *
           (2 + 2 * x + x**2) * cos(2 * alp)) / beta / (1 + x) / D)
    T3 = -kap * sin(2 * alp) / D
    T4 = kap * beta**2 * (1 + x) * sin(2 * alp) * cos(2 * alp) / D
    T5 = 1 / fabs(x) * ellipf(alp, arg2)  # psi_phi without e/rho**2 factor
    out = re((T1 + T2 + T3 + T4) - 2 / beta**2 * T5)

    return out
Example #21
0
def grams(zeta, mu, x, k):

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm= (2*E-K)/K

    k1 = sqrt(1-k**2)

    xp = x[0]+complex(0,1)*x[1]
    xm = x[0]-complex(0,1)*x[1]
    S =  sqrt(K**2-4*xp*xm)
    SP = sqrt(K**2-4*xp**2)
    SM = sqrt(K**2-4*xm**2)
    SPM = sqrt(-k1**2*(K**2*k**2-4*xm*xp)+(xm-xp)**2)
    R = 2*K**2*k1**2-S**2-8*x[2]**2
    RM = complex(0,1)*SM**2*(xm*(2*k1**2-1)+xp)-(16*complex(0,1))*xm*x[2]**2
    RP = complex(0,1)*SM**2*(xp*(2*k1**2-1)+xm)+(16*complex(0,1))*xp*x[2]**2
    RMBAR=-complex(0,1)*SP**2*( xp*(2*k1**2-1)+xm ) +16*complex(0,1)*xp*x[2]**2
    RPBAR=-complex(0,1)*SP**2*( xm*(2*k1**2-1)+xp ) -16*complex(0,1)*xm*x[2]**2
    r=sqrt(x[0]**2+x[1]**2+x[2]**2)

    return mat([[(complex(0, -1) * (-exp(2 * mu[2]) + exp(2 * mu[1])) * zeta[0] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[0] ** 3 - R / zeta[0] ** 2 + complex(0, 12) * xm * x[2] / zeta[0] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[0]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[2] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[0] - (-x[0] + complex(0, -1) * x[1]) / zeta[0] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[0]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[0] - x[2] / zeta[0] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[2] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[0] + complex(0, 2) * pi - 2 * mu[2])) / K ** 2 / (-RMBAR / zeta[0] ** 3 + 2 * R * x[2] / zeta[0] ** 2 + RPBAR / zeta[0] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (exp(2 * mu[2]) - exp(2 * mu[0])) * zeta[1] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[1] ** 3 - R / zeta[1] ** 2 + complex(0, 12) * xm * x[2] / zeta[1] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[1]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[2] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[1] - (-x[0] + complex(0, -1) * x[1]) / zeta[1] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[1]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[1] - x[2] / zeta[1] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[2] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[1] + complex(0, 2) * pi - 2 * mu[2])) / K ** 2 / (-RMBAR / zeta[1] ** 3 + 2 * R * x[2] / zeta[1] ** 2 + RPBAR / zeta[1] - x[2] * (SM ** 2 + SP ** 2))) * (exp(-2 * mu[0]) - exp(-2 * mu[3])) + (complex(0, -1) * (-exp(2 * mu[1]) + exp(2 * mu[0])) * zeta[2] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[2] ** 3 - R / zeta[2] ** 2 + complex(0, 12) * xm * x[2] / zeta[2] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[2]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[3] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[2] - (-x[0] + complex(0, -1) * x[1]) / zeta[2] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[3] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[3] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[2]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[3] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[3] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[2] - x[2] / zeta[2] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[3] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[2] - 2 * mu[3])) / K ** 2 / (-RMBAR / zeta[2] ** 3 + 2 * R * x[2] / zeta[2] ** 2 + RPBAR / zeta[2] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (-exp(2 * mu[2]) + exp(2 * mu[1])) * zeta[0] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[0] ** 3 - R / zeta[0] ** 2 + complex(0, 12) * xm * x[2] / zeta[0] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[0]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[3] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[0] - (-x[0] + complex(0, -1) * x[1]) / zeta[0] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[3] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[3] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[0]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[3] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[3] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[0] - x[2] / zeta[0] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[3] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[0] + complex(0, 2) * pi - 2 * mu[3])) / K ** 2 / (-RMBAR / zeta[0] ** 3 + 2 * R * x[2] / zeta[0] ** 2 + RPBAR / zeta[0] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (exp(2 * mu[2]) - exp(2 * mu[0])) * zeta[1] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[1] ** 3 - R / zeta[1] ** 2 + complex(0, 12) * xm * x[2] / zeta[1] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[1]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[3] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[1] - (-x[0] + complex(0, -1) * x[1]) / zeta[1] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[3] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[3] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[1]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[3] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[3] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[1] - x[2] / zeta[1] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[3] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[1] + complex(0, 2) * pi - 2 * mu[3])) / K ** 2 / (-RMBAR / zeta[1] ** 3 + 2 * R * x[2] / zeta[1] ** 2 + RPBAR / zeta[1] - x[2] * (SM ** 2 + SP ** 2))) * (-exp(-2 * mu[0]) + exp(-2 * mu[2])) + (complex(0, -1) * (-exp(2 * mu[1]) + exp(2 * mu[0])) * zeta[2] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[2] ** 3 - R / zeta[2] ** 2 + complex(0, 12) * xm * x[2] / zeta[2] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[2]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[0] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[2] - (-x[0] + complex(0, -1) * x[1]) / zeta[2] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[2]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[2] - x[2] / zeta[2] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[0] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[2] + complex(0, -2) * pi - 2 * mu[0])) / K ** 2 / (-RMBAR / zeta[2] ** 3 + 2 * R * x[2] / zeta[2] ** 2 + RPBAR / zeta[2] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (exp(2 * mu[2]) - exp(2 * mu[0])) * zeta[1] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[1] ** 3 - R / zeta[1] ** 2 + complex(0, 12) * xm * x[2] / zeta[1] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[1]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[0] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[1] - (-x[0] + complex(0, -1) * x[1]) / zeta[1] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[1]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[1] - x[2] / zeta[1] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[0] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[1] - 2 * mu[0])) / K ** 2 / (-RMBAR / zeta[1] ** 3 + 2 * R * x[2] / zeta[1] ** 2 + RPBAR / zeta[1] - x[2] * (SM ** 2 + SP ** 2))) * (exp(-2 * mu[3]) - exp(-2 * mu[2])),(complex(0, -1) * (-exp(2 * mu[2]) + exp(2 * mu[1])) * zeta[0] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[0] ** 3 - R / zeta[0] ** 2 + complex(0, 12) * xm * x[2] / zeta[0] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[0]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[2] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[0] - (-x[0] + complex(0, -1) * x[1]) / zeta[0] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[0]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[0] - x[2] / zeta[0] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[2] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[0] + complex(0, 2) * pi - 2 * mu[2])) / K ** 2 / (-RMBAR / zeta[0] ** 3 + 2 * R * x[2] / zeta[0] ** 2 + RPBAR / zeta[0] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (exp(2 * mu[2]) - exp(2 * mu[0])) * zeta[1] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[1] ** 3 - R / zeta[1] ** 2 + complex(0, 12) * xm * x[2] / zeta[1] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[1]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[2] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[1] - (-x[0] + complex(0, -1) * x[1]) / zeta[1] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[1]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[1] - x[2] / zeta[1] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[2] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[1] + complex(0, 2) * pi - 2 * mu[2])) / K ** 2 / (-RMBAR / zeta[1] ** 3 + 2 * R * x[2] / zeta[1] ** 2 + RPBAR / zeta[1] - x[2] * (SM ** 2 + SP ** 2))) * (exp(-2 * mu[1]) - exp(-2 * mu[0])) + (complex(0, -1) * (-exp(2 * mu[1]) + exp(2 * mu[0])) * zeta[2] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[2] ** 3 - R / zeta[2] ** 2 + complex(0, 12) * xm * x[2] / zeta[2] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[2]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[0] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[2] - (-x[0] + complex(0, -1) * x[1]) / zeta[2] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[2]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[2] - x[2] / zeta[2] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[0] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[2] + complex(0, -2) * pi - 2 * mu[0])) / K ** 2 / (-RMBAR / zeta[2] ** 3 + 2 * R * x[2] / zeta[2] ** 2 + RPBAR / zeta[2] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (exp(2 * mu[2]) - exp(2 * mu[0])) * zeta[1] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[1] ** 3 - R / zeta[1] ** 2 + complex(0, 12) * xm * x[2] / zeta[1] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[1]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[0] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[1] - (-x[0] + complex(0, -1) * x[1]) / zeta[1] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[1]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[1] - x[2] / zeta[1] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[0] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[1] - 2 * mu[0])) / K ** 2 / (-RMBAR / zeta[1] ** 3 + 2 * R * x[2] / zeta[1] ** 2 + RPBAR / zeta[1] - x[2] * (SM ** 2 + SP ** 2))) * (exp(-2 * mu[2]) - exp(-2 * mu[1])) + (complex(0, -1) * (-exp(2 * mu[1]) + exp(2 * mu[0])) * zeta[2] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[2] ** 3 - R / zeta[2] ** 2 + complex(0, 12) * xm * x[2] / zeta[2] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[2]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[1] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[2] - (-x[0] + complex(0, -1) * x[1]) / zeta[2] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[1] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[1] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[2]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[1] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[1] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[2] - x[2] / zeta[2] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[1] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[2] + complex(0, -2) * pi - 2 * mu[1])) / K ** 2 / (-RMBAR / zeta[2] ** 3 + 2 * R * x[2] / zeta[2] ** 2 + RPBAR / zeta[2] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (-exp(2 * mu[2]) + exp(2 * mu[1])) * zeta[0] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[0] ** 3 - R / zeta[0] ** 2 + complex(0, 12) * xm * x[2] / zeta[0] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[0]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[1] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[0] - (-x[0] + complex(0, -1) * x[1]) / zeta[0] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[1] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[1] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[0]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[1] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[1] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[0] - x[2] / zeta[0] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[1] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[0] - 2 * mu[1])) / K ** 2 / (-RMBAR / zeta[0] ** 3 + 2 * R * x[2] / zeta[0] ** 2 + RPBAR / zeta[0] - x[2] * (SM ** 2 + SP ** 2))) * (-exp(-2 * mu[2]) + exp(-2 * mu[0]))],[(complex(0, -1) * (exp(2 * mu[0]) - exp(2 * mu[2])) * zeta[3] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[3] ** 3 - R / zeta[3] ** 2 + complex(0, 12) * xm * x[2] / zeta[3] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[3]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[2] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[3] - (-x[0] + complex(0, -1) * x[1]) / zeta[3] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[3]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[3] - x[2] / zeta[3] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[2] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[3] - 2 * mu[2])) / K ** 2 / (-RMBAR / zeta[3] ** 3 + 2 * R * x[2] / zeta[3] ** 2 + RPBAR / zeta[3] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (-exp(2 * mu[3]) + exp(2 * mu[2])) * zeta[0] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[0] ** 3 - R / zeta[0] ** 2 + complex(0, 12) * xm * x[2] / zeta[0] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[0]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[2] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[0] - (-x[0] + complex(0, -1) * x[1]) / zeta[0] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[0]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[0] - x[2] / zeta[0] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[2] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[0] + complex(0, 2) * pi - 2 * mu[2])) / K ** 2 / (-RMBAR / zeta[0] ** 3 + 2 * R * x[2] / zeta[0] ** 2 + RPBAR / zeta[0] - x[2] * (SM ** 2 + SP ** 2))) * (exp(-2 * mu[0]) - exp(-2 * mu[3])) + (complex(0, -1) * (-exp(2 * mu[0]) + exp(2 * mu[3])) * zeta[2] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[2] ** 3 - R / zeta[2] ** 2 + complex(0, 12) * xm * x[2] / zeta[2] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[2]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[3] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[2] - (-x[0] + complex(0, -1) * x[1]) / zeta[2] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[3] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[3] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[2]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[3] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[3] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[2] - x[2] / zeta[2] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[3] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[2] - 2 * mu[3])) / K ** 2 / (-RMBAR / zeta[2] ** 3 + 2 * R * x[2] / zeta[2] ** 2 + RPBAR / zeta[2] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (-exp(2 * mu[3]) + exp(2 * mu[2])) * zeta[0] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[0] ** 3 - R / zeta[0] ** 2 + complex(0, 12) * xm * x[2] / zeta[0] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[0]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[3] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[0] - (-x[0] + complex(0, -1) * x[1]) / zeta[0] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[3] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[3] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[0]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[3] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[3] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[0] - x[2] / zeta[0] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[3] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[0] + complex(0, 2) * pi - 2 * mu[3])) / K ** 2 / (-RMBAR / zeta[0] ** 3 + 2 * R * x[2] / zeta[0] ** 2 + RPBAR / zeta[0] - x[2] * (SM ** 2 + SP ** 2))) * (-exp(-2 * mu[0]) + exp(-2 * mu[2])) + (complex(0, -1) * (-exp(2 * mu[0]) + exp(2 * mu[3])) * zeta[2] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[2] ** 3 - R / zeta[2] ** 2 + complex(0, 12) * xm * x[2] / zeta[2] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[2]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[0] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[2] - (-x[0] + complex(0, -1) * x[1]) / zeta[2] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[2]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[2] - x[2] / zeta[2] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[0] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[2] + complex(0, -2) * pi - 2 * mu[0])) / K ** 2 / (-RMBAR / zeta[2] ** 3 + 2 * R * x[2] / zeta[2] ** 2 + RPBAR / zeta[2] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (exp(2 * mu[0]) - exp(2 * mu[2])) * zeta[3] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[3] ** 3 - R / zeta[3] ** 2 + complex(0, 12) * xm * x[2] / zeta[3] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[3]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[0] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[3] - (-x[0] + complex(0, -1) * x[1]) / zeta[3] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[3]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[3] - x[2] / zeta[3] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[0] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[3] + complex(0, -2) * pi - 2 * mu[0])) / K ** 2 / (-RMBAR / zeta[3] ** 3 + 2 * R * x[2] / zeta[3] ** 2 + RPBAR / zeta[3] - x[2] * (SM ** 2 + SP ** 2))) * (exp(-2 * mu[3]) - exp(-2 * mu[2])),(complex(0, -1) * (exp(2 * mu[0]) - exp(2 * mu[2])) * zeta[3] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[3] ** 3 - R / zeta[3] ** 2 + complex(0, 12) * xm * x[2] / zeta[3] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[3]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[2] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[3] - (-x[0] + complex(0, -1) * x[1]) / zeta[3] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[3]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[3] - x[2] / zeta[3] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[2] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[3] - 2 * mu[2])) / K ** 2 / (-RMBAR / zeta[3] ** 3 + 2 * R * x[2] / zeta[3] ** 2 + RPBAR / zeta[3] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (-exp(2 * mu[3]) + exp(2 * mu[2])) * zeta[0] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[0] ** 3 - R / zeta[0] ** 2 + complex(0, 12) * xm * x[2] / zeta[0] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[0]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[2] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[0] - (-x[0] + complex(0, -1) * x[1]) / zeta[0] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[0]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[2] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[2] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[0] - x[2] / zeta[0] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[2] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[0] + complex(0, 2) * pi - 2 * mu[2])) / K ** 2 / (-RMBAR / zeta[0] ** 3 + 2 * R * x[2] / zeta[0] ** 2 + RPBAR / zeta[0] - x[2] * (SM ** 2 + SP ** 2))) * (exp(-2 * mu[1]) - exp(-2 * mu[0])) + (complex(0, -1) * (-exp(2 * mu[0]) + exp(2 * mu[3])) * zeta[2] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[2] ** 3 - R / zeta[2] ** 2 + complex(0, 12) * xm * x[2] / zeta[2] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[2]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[0] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[2] - (-x[0] + complex(0, -1) * x[1]) / zeta[2] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[2]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[2] - x[2] / zeta[2] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[0] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[2] + complex(0, -2) * pi - 2 * mu[0])) / K ** 2 / (-RMBAR / zeta[2] ** 3 + 2 * R * x[2] / zeta[2] ** 2 + RPBAR / zeta[2] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (exp(2 * mu[0]) - exp(2 * mu[2])) * zeta[3] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[3] ** 3 - R / zeta[3] ** 2 + complex(0, 12) * xm * x[2] / zeta[3] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[3]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[0] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[3] - (-x[0] + complex(0, -1) * x[1]) / zeta[3] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[3]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[0] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[0] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[3] - x[2] / zeta[3] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[0] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[3] + complex(0, -2) * pi - 2 * mu[0])) / K ** 2 / (-RMBAR / zeta[3] ** 3 + 2 * R * x[2] / zeta[3] ** 2 + RPBAR / zeta[3] - x[2] * (SM ** 2 + SP ** 2))) * (exp(-2 * mu[2]) - exp(-2 * mu[1])) + (complex(0, -1) * (-exp(2 * mu[0]) + exp(2 * mu[3])) * zeta[2] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[2] ** 3 - R / zeta[2] ** 2 + complex(0, 12) * xm * x[2] / zeta[2] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[2]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[1] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[2] - (-x[0] + complex(0, -1) * x[1]) / zeta[2] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[1] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[1] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[2]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[1] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[1] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[2] - x[2] / zeta[2] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[1] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[2] + complex(0, -2) * pi - 2 * mu[1])) / K ** 2 / (-RMBAR / zeta[2] ** 3 + 2 * R * x[2] / zeta[2] ** 2 + RPBAR / zeta[2] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (exp(2 * mu[0]) - exp(2 * mu[2])) * zeta[3] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[3] ** 3 - R / zeta[3] ** 2 + complex(0, 12) * xm * x[2] / zeta[3] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[3]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[1] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[3] - (-x[0] + complex(0, -1) * x[1]) / zeta[3] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[1] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[1] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[3]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[1] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[1] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[3] - x[2] / zeta[3] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[1] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[3] + complex(0, -2) * pi - 2 * mu[1])) / K ** 2 / (-RMBAR / zeta[3] ** 3 + 2 * R * x[2] / zeta[3] ** 2 + RPBAR / zeta[3] - x[2] * (SM ** 2 + SP ** 2)) + complex(0, -1) * (-exp(2 * mu[3]) + exp(2 * mu[2])) * zeta[0] * SP ** 2 * (complex(0, 4) * x[2] * xp / zeta[0] ** 3 - R / zeta[0] ** 2 + complex(0, 12) * xm * x[2] / zeta[0] + SM ** 2) * ((-x[2] + complex(0, 1) * (-x[0] + complex(0, -1) * x[1]) / zeta[0]) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, -1) * x[1]) ** 2) * zeta[1] - (x[0] + complex(0, -1) * x[1]) * x[2]) + (complex(0, -1) * x[2] / zeta[0] - (-x[0] + complex(0, -1) * x[1]) / zeta[0] ** 2) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[1] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[1] + K ** 2 * (-2 * k ** 2 + 1) / 8 - 0.3e1 / 0.2e1 * x[2] ** 2) + (-x[0] + complex(0, 1) * x[1] + complex(0, 1) * x[2] / zeta[0]) * (-(K ** 2 / 8 - (x[0] + complex(0, 1) * x[1]) ** 2 / 2) / zeta[1] ** 2 + complex(0, -2) * (x[0] + complex(0, 1) * x[1]) * x[2] / zeta[1] + K ** 2 * (-2 * k ** 2 + 1) / 8 + (x[0] + complex(0, -1) * x[1]) * (x[0] + complex(0, 1) * x[1]) - x[2] ** 2 / 2) + (complex(0, 1) * (complex(0, 1) * x[1] - x[0]) / zeta[0] - x[2] / zeta[0] ** 2) * (complex(0, 0.1e1 / 0.4e1) * (K ** 2 - 4 * (x[0] + complex(0, 1) * x[1]) ** 2) / zeta[1] - (x[0] + complex(0, 1) * x[1]) * x[2])) * (1 - exp(2 * mu[0] - 2 * mu[1])) / K ** 2 / (-RMBAR / zeta[0] ** 3 + 2 * R * x[2] / zeta[0] ** 2 + RPBAR / zeta[0] - x[2] * (SM ** 2 + SP ** 2))) * (-exp(-2 * mu[2]) + exp(-2 * mu[0]))]])
Example #22
0
def dmus(zeta, x, k):

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm = (2 * E - K) / K

    k1 = sqrt(1 - k**2)

    xp = x[0] + complex(0, 1) * x[1]
    xm = x[0] - complex(0, 1) * x[1]
    S = sqrt(K**2 - 4 * xp * xm)
    SP = sqrt(K**2 - 4 * xp**2)
    SM = sqrt(K**2 - 4 * xm**2)
    SPM = sqrt(-k1**2 * (K**2 * k**2 - 4 * xm * xp) + (xm - xp)**2)
    R = 2 * K**2 * k1**2 - S**2 - 8 * x[2]**2
    RM = complex(0, 1) * SM**2 * (xm * (2 * k1**2 - 1) +
                                  xp) - (16 * complex(0, 1)) * xm * x[2]**2
    RP = complex(0, 1) * SM**2 * (xp * (2 * k1**2 - 1) +
                                  xm) + (16 * complex(0, 1)) * xp * x[2]**2
    RMBAR = -complex(0, 1) * SP**2 * (xp *
                                      (2 * k1**2 - 1) + xm) + 16 * complex(
                                          0, 1) * xp * x[2]**2
    RPBAR = -complex(0, 1) * SP**2 * (xm *
                                      (2 * k1**2 - 1) + xp) - 16 * complex(
                                          0, 1) * xm * x[2]**2
    r = sqrt(x[0]**2 + x[1]**2 + x[2]**2)

    DM = [None, None, None, None]

    DM[0] = [None] * 3
    DM[1] = [None] * 3
    DM[2] = [None] * 3
    DM[3] = [None] * 3

    DM[0][0] = complex(0, 1) * (
        E * K * zeta[0]**2 - K**2 * zeta[0]**2 + 4 * zeta[0]**2 * x[0]**2 +
        complex(0, -4) * zeta[0]**2 * x[1] * x[0] + E * K - K**2 + 4 * x[0]**2
        + complex(0, -8) * zeta[0] * x[2] * x[0] + complex(0, 4) * x[0] * x[1]
    ) / (4 * zeta[0]**3 * x[0]**2 + complex(0, -8) * zeta[0]**3 * x[0] * x[1] +
         2 * K**2 * k1**2 * zeta[0] - K**2 * zeta[0]**3 +
         4 * x[0]**2 * zeta[0] + complex(0, -12) * zeta[0]**2 * x[0] * x[2] -
         4 * zeta[0]**3 * x[1]**2 - 12 * zeta[0]**2 * x[1] * x[2] -
         K**2 * zeta[0] + complex(0, -4) * x[0] * x[2] +
         4 * x[1]**2 * zeta[0] - 8 * zeta[0] * x[2]**2 + 4 * x[1] * x[2])

    DM[1][0] = complex(0, 1) * (
        E * K * zeta[1]**2 - K**2 * zeta[1]**2 + 4 * zeta[1]**2 * x[0]**2 +
        complex(0, -4) * zeta[1]**2 * x[1] * x[0] + E * K - K**2 + 4 * x[0]**2
        + complex(0, -8) * zeta[1] * x[2] * x[0] + complex(0, 4) * x[0] * x[1]
    ) / (4 * zeta[1]**3 * x[0]**2 + complex(0, -8) * zeta[1]**3 * x[0] * x[1] +
         2 * K**2 * k1**2 * zeta[1] - K**2 * zeta[1]**3 +
         4 * x[0]**2 * zeta[1] + complex(0, -12) * zeta[1]**2 * x[0] * x[2] -
         4 * zeta[1]**3 * x[1]**2 - 12 * zeta[1]**2 * x[1] * x[2] -
         K**2 * zeta[1] + complex(0, -4) * x[0] * x[2] +
         4 * x[1]**2 * zeta[1] - 8 * zeta[1] * x[2]**2 + 4 * x[1] * x[2])

    DM[2][0] = complex(0, 1) * (
        E * K * zeta[2]**2 - K**2 * zeta[2]**2 + 4 * zeta[2]**2 * x[0]**2 +
        complex(0, -4) * zeta[2]**2 * x[1] * x[0] + E * K - K**2 + 4 * x[0]**2
        + complex(0, -8) * zeta[2] * x[2] * x[0] + complex(0, 4) * x[0] * x[1]
    ) / (4 * zeta[2]**3 * x[0]**2 + complex(0, -8) * zeta[2]**3 * x[0] * x[1] +
         2 * K**2 * k1**2 * zeta[2] - K**2 * zeta[2]**3 +
         4 * x[0]**2 * zeta[2] + complex(0, -12) * zeta[2]**2 * x[0] * x[2] -
         4 * zeta[2]**3 * x[1]**2 - 12 * zeta[2]**2 * x[1] * x[2] -
         K**2 * zeta[2] + complex(0, -4) * x[0] * x[2] +
         4 * x[1]**2 * zeta[2] - 8 * zeta[2] * x[2]**2 + 4 * x[1] * x[2])

    DM[3][0] = complex(0, 1) * (
        E * K * zeta[3]**2 - K**2 * zeta[3]**2 + 4 * zeta[3]**2 * x[0]**2 +
        complex(0, -4) * zeta[3]**2 * x[1] * x[0] + E * K - K**2 + 4 * x[0]**2
        + complex(0, -8) * zeta[3] * x[2] * x[0] + complex(0, 4) * x[0] * x[1]
    ) / (4 * zeta[3]**3 * x[0]**2 + complex(0, -8) * zeta[3]**3 * x[0] * x[1] +
         2 * K**2 * k1**2 * zeta[3] - K**2 * zeta[3]**3 +
         4 * x[0]**2 * zeta[3] + complex(0, -12) * zeta[3]**2 * x[0] * x[2] -
         4 * zeta[3]**3 * x[1]**2 - 12 * zeta[3]**2 * x[1] * x[2] -
         K**2 * zeta[3] + complex(0, -4) * x[0] * x[2] +
         4 * x[1]**2 * zeta[3] - 8 * zeta[3] * x[2]**2 + 4 * x[1] * x[2])

    DM[0][1] = (complex(0, 4) * zeta[0]**2 * x[1] * x[0] + E * K * zeta[0]**2 +
                4 * zeta[0]**2 * x[1]**2 + complex(0, 4) * x[0] * x[1] +
                8 * zeta[0] * x[1] * x[2] - E * K - 4 * x[1]**2) / (
                    4 * zeta[0]**3 * x[0]**2 + complex(0, -8) * zeta[0]**3 *
                    x[0] * x[1] + 2 * K**2 * k1**2 * zeta[0] -
                    K**2 * zeta[0]**3 + 4 * x[0]**2 * zeta[0] +
                    complex(0, -12) * zeta[0]**2 * x[0] * x[2] -
                    4 * zeta[0]**3 * x[1]**2 - 12 * zeta[0]**2 * x[1] * x[2] -
                    K**2 * zeta[0] + complex(0, -4) * x[0] * x[2] +
                    4 * x[1]**2 * zeta[0] - 8 * zeta[0] * x[2]**2 +
                    4 * x[1] * x[2])

    DM[1][1] = (complex(0, 4) * zeta[1]**2 * x[1] * x[0] + E * K * zeta[1]**2 +
                4 * zeta[1]**2 * x[1]**2 + complex(0, 4) * x[0] * x[1] +
                8 * zeta[1] * x[1] * x[2] - E * K - 4 * x[1]**2) / (
                    4 * zeta[1]**3 * x[0]**2 + complex(0, -8) * zeta[1]**3 *
                    x[0] * x[1] + 2 * K**2 * k1**2 * zeta[1] -
                    K**2 * zeta[1]**3 + 4 * x[0]**2 * zeta[1] +
                    complex(0, -12) * zeta[1]**2 * x[0] * x[2] -
                    4 * zeta[1]**3 * x[1]**2 - 12 * zeta[1]**2 * x[1] * x[2] -
                    K**2 * zeta[1] + complex(0, -4) * x[0] * x[2] +
                    4 * x[1]**2 * zeta[1] - 8 * zeta[1] * x[2]**2 +
                    4 * x[1] * x[2])

    DM[2][1] = (complex(0, 4) * zeta[2]**2 * x[1] * x[0] + E * K * zeta[2]**2 +
                4 * zeta[2]**2 * x[1]**2 + complex(0, 4) * x[0] * x[1] +
                8 * zeta[2] * x[1] * x[2] - E * K - 4 * x[1]**2) / (
                    4 * zeta[2]**3 * x[0]**2 + complex(0, -8) * zeta[2]**3 *
                    x[0] * x[1] + 2 * K**2 * k1**2 * zeta[2] -
                    K**2 * zeta[2]**3 + 4 * x[0]**2 * zeta[2] +
                    complex(0, -12) * zeta[2]**2 * x[0] * x[2] -
                    4 * zeta[2]**3 * x[1]**2 - 12 * zeta[2]**2 * x[1] * x[2] -
                    K**2 * zeta[2] + complex(0, -4) * x[0] * x[2] +
                    4 * x[1]**2 * zeta[2] - 8 * zeta[2] * x[2]**2 +
                    4 * x[1] * x[2])

    DM[3][1] = (complex(0, 4) * zeta[3]**2 * x[1] * x[0] + E * K * zeta[3]**2 +
                4 * zeta[3]**2 * x[1]**2 + complex(0, 4) * x[0] * x[1] +
                8 * zeta[3] * x[1] * x[2] - E * K - 4 * x[1]**2) / (
                    4 * zeta[3]**3 * x[0]**2 + complex(0, -8) * zeta[3]**3 *
                    x[0] * x[1] + 2 * K**2 * k1**2 * zeta[3] -
                    K**2 * zeta[3]**3 + 4 * x[0]**2 * zeta[3] +
                    complex(0, -12) * zeta[3]**2 * x[0] * x[2] -
                    4 * zeta[3]**3 * x[1]**2 - 12 * zeta[3]**2 * x[1] * x[2] -
                    K**2 * zeta[3] + complex(0, -4) * x[0] * x[2] +
                    4 * x[1]**2 * zeta[3] - 8 * zeta[3] * x[2]**2 +
                    4 * x[1] * x[2])

    DM[0][2] = 2 * (
        -K**2 * k1**2 * zeta[0] + complex(0, 2) * zeta[0]**2 * x[0] * x[2] +
        2 * zeta[0]**2 * x[1] * x[2] + E * K * zeta[0] +
        complex(0, 2) * x[0] * x[2] + 4 * zeta[0] * x[2]**2 - 2 * x[1] * x[2]
    ) / (4 * zeta[0]**3 * x[0]**2 + complex(0, -8) * zeta[0]**3 * x[0] * x[1] +
         2 * K**2 * k1**2 * zeta[0] - K**2 * zeta[0]**3 +
         4 * x[0]**2 * zeta[0] + complex(0, -12) * zeta[0]**2 * x[0] * x[2] -
         4 * zeta[0]**3 * x[1]**2 - 12 * zeta[0]**2 * x[1] * x[2] -
         K**2 * zeta[0] + complex(0, -4) * x[0] * x[2] +
         4 * x[1]**2 * zeta[0] - 8 * zeta[0] * x[2]**2 + 4 * x[1] * x[2])

    DM[1][2] = 2 * (
        -K**2 * k1**2 * zeta[1] + complex(0, 2) * zeta[1]**2 * x[0] * x[2] +
        2 * zeta[1]**2 * x[1] * x[2] + E * K * zeta[1] +
        complex(0, 2) * x[0] * x[2] + 4 * zeta[1] * x[2]**2 - 2 * x[1] * x[2]
    ) / (4 * zeta[1]**3 * x[0]**2 + complex(0, -8) * zeta[1]**3 * x[0] * x[1] +
         2 * K**2 * k1**2 * zeta[1] - K**2 * zeta[1]**3 +
         4 * x[0]**2 * zeta[1] + complex(0, -12) * zeta[1]**2 * x[0] * x[2] -
         4 * zeta[1]**3 * x[1]**2 - 12 * zeta[1]**2 * x[1] * x[2] -
         K**2 * zeta[1] + complex(0, -4) * x[0] * x[2] +
         4 * x[1]**2 * zeta[1] - 8 * zeta[1] * x[2]**2 + 4 * x[1] * x[2])

    DM[2][2] = 2 * (
        -K**2 * k1**2 * zeta[2] + complex(0, 2) * zeta[2]**2 * x[0] * x[2] +
        2 * zeta[2]**2 * x[1] * x[2] + E * K * zeta[2] +
        complex(0, 2) * x[0] * x[2] + 4 * zeta[2] * x[2]**2 - 2 * x[1] * x[2]
    ) / (4 * zeta[2]**3 * x[0]**2 + complex(0, -8) * zeta[2]**3 * x[0] * x[1] +
         2 * K**2 * k1**2 * zeta[2] - K**2 * zeta[2]**3 +
         4 * x[0]**2 * zeta[2] + complex(0, -12) * zeta[2]**2 * x[0] * x[2] -
         4 * zeta[2]**3 * x[1]**2 - 12 * zeta[2]**2 * x[1] * x[2] -
         K**2 * zeta[2] + complex(0, -4) * x[0] * x[2] +
         4 * x[1]**2 * zeta[2] - 8 * zeta[2] * x[2]**2 + 4 * x[1] * x[2])

    DM[3][2] = 2 * (
        -K**2 * k1**2 * zeta[3] + complex(0, 2) * zeta[3]**2 * x[0] * x[2] +
        2 * zeta[3]**2 * x[1] * x[2] + E * K * zeta[3] +
        complex(0, 2) * x[0] * x[2] + 4 * zeta[3] * x[2]**2 - 2 * x[1] * x[2]
    ) / (4 * zeta[3]**3 * x[0]**2 + complex(0, -8) * zeta[3]**3 * x[0] * x[1] +
         2 * K**2 * k1**2 * zeta[3] - K**2 * zeta[3]**3 +
         4 * x[0]**2 * zeta[3] + complex(0, -12) * zeta[3]**2 * x[0] * x[2] -
         4 * zeta[3]**3 * x[1]**2 - 12 * zeta[3]**2 * x[1] * x[2] -
         K**2 * zeta[3] + complex(0, -4) * x[0] * x[2] +
         4 * x[1]**2 * zeta[3] - 8 * zeta[3] * x[2]**2 + 4 * x[1] * x[2])

    return DM
Example #23
0
def mino_freqs_kerr(r1, r2, r3, r4, En, Lz, Q, aa, slr, ecc, x, M=1):
    """
    Mino frequencies for the Kerr case (aa != 0)

    Parameters:
        r1 (float): radial root
        r2 (float): radial root
        r3 (float): radial root
        r4 (float): radial root
        En (float): energy
        Lz (float): angular momentum
        Q (float): Carter constant
        aa (float): spin
        slr (float): semi-latus rectum
        ecc (float): eccentricity
        x (float): inclincation

    Keyword Args:
        M (float): mass

    Returns:
        ups_r (float): radial Mino frequency
        ups_theta (float): polar Mino frequency
        ups_phi (float): azimuthal Mino frequency
        gamma (float): time Mino frequency
    """
    # En, Lz, Q = calc_eq_constants(aa, slr, ecc)
    # r1, r2, r3, r4 = radial_roots(En, Q, aa, slr, ecc, M)
    pi = mp.pi
    L2 = Lz * Lz
    aa2 = aa * aa
    En2 = En * En
    M2 = M * M

    # polar pieces
    zm = 1 - x * x
    # a2zp = (L2 + aa2*(-1 + En2)*(-1 + zm))/((-1 + En2)*(-1 + zm))
    eps0zp = -((L2 + aa2 * (-1 + En2) * (-1 + zm)) / (L2 * (-1 + zm)))
    zmOverzp = (aa2 * (-1 + En2) * (-1 + zm) * zm) / (L2 + aa2 * (-1 + En2) *
                                                      (-1 + zm))

    kr = sqrt(((r1 - r2) * (r3 - r4)) / ((r1 - r3) * (r2 - r4)))
    ktheta = sqrt(zmOverzp)

    kr2 = kr * kr
    ktheta2 = ktheta * ktheta

    ellipticK_r = ellipk(kr2)
    ellipticK_theta = ellipk(ktheta2)

    rp = M + sqrt(M2 - aa2)
    rm = M - sqrt(M2 - aa2)
    hr = (r1 - r2) / (r1 - r3)
    hp = ((r1 - r2) * (r3 - rp)) / ((r1 - r3) * (r2 - rp))
    hm = ((r1 - r2) * (r3 - rm)) / ((r1 - r3) * (r2 - rm))

    ellipticPi_hmkr = ellippi(hm, kr2)
    ellipticPi_hpkr = ellippi(hp, kr2)
    ellipticPi_hrkr = ellippi(hr, kr2)
    ellipticPi_zmktheta = ellippi(zm, ktheta2)
    ellipticE_kr = ellipe(kr2)
    ellipticE_ktheta = ellipe(ktheta2)

    ups_r = (pi * sqrt((1 - En2) * (r1 - r3) * (r2 - r4))) / (2 * ellipticK_r)
    ups_theta = (sqrt(eps0zp) * Lz * pi) / (2.0 * ellipticK_theta)
    ups_phi = (2 * aa * ups_r * (-(
        ((-(aa * Lz) + 2 * En * M * rm) *
         (ellipticK_r - ((r2 - r3) * ellipticPi_hmkr) / (r2 - rm))) /
        (r3 - rm)) + (
            (-(aa * Lz) + 2 * En * M * rp) *
            (ellipticK_r - ((r2 - r3) * ellipticPi_hpkr) /
             (r2 - rp))) / (r3 - rp))) / (pi * sqrt(
                 (1 - En2) * (r1 - r3) * (r2 - r4)) * (-rm + rp)) + (
                     2 * ups_theta * ellipticPi_zmktheta) / (sqrt(eps0zp) * pi)
    gamma = (4 * En * M2 + (2 * En * ups_theta * (L2 + aa2 * (-1 + En2) *
                                                  (-1 + zm)) *
                            (-ellipticE_ktheta + ellipticK_theta)) /
             ((-1 + En2) * sqrt(eps0zp) * Lz * pi * (-1 + zm)) +
             (2 * ups_r *
              ((2 * M *
                (-(((-2 * aa2 * En * M + (-(aa * Lz) + 4 * En * M2) * rm) *
                    (ellipticK_r - ((r2 - r3) * ellipticPi_hmkr) /
                     (r2 - rm))) / (r3 - rm)) +
                 ((-2 * aa2 * En * M + (-(aa * Lz) + 4 * En * M2) * rp) *
                  (ellipticK_r - ((r2 - r3) * ellipticPi_hpkr) /
                   (r2 - rp))) / (r3 - rp))) / (-rm + rp) + 2 * En * M *
               (r3 * ellipticK_r + (r2 - r3) * ellipticPi_hrkr) +
               (En *
                ((r1 - r3) * (r2 - r4) * ellipticE_kr +
                 (-(r1 * r2) + r3 * (r1 + r2 + r3)) * ellipticK_r + (r2 - r3) *
                 (r1 + r2 + r3 + r4) * ellipticPi_hrkr)) / 2.0)) / (pi * sqrt(
                     (1 - En2) * (r1 - r3) * (r2 - r4))))

    return ups_r, ups_theta, ups_phi, gamma
def f42(x):
    # ellint_Ecomp
    x = mpmath.mpf(x)
    return mpmath.ellipe(x * x)
Example #25
0
def f_func(r,s):
  alpha=0.5*(r/s+s/r)
  t1 = 4*np.sqrt(alpha-1)/(alpha*alpha-1)*mp.ellipe(-2/(alpha-1))
  t2 = 2.0*(mp.ellipk(2./(1-alpha))/np.sqrt(alpha-1)+mp.ellipk(2/(1+alpha))/np.sqrt(alpha+1))
  return -float(s*s*G/np.power(2.0*r*s,1.5)*((r/s-alpha)*t1+t2))
Example #26
0
    def get_W(self, k2, phi1, phi2):
        """
        Return the vector of `W` integrals, computed
        recursively given a lower boundary condition
        (analytic in terms of elliptic integrals) and an upper
        boundary condition (computed numerically).

        The term `W_j` is the solution to the integral of
        
            sin(u)^(2 * j) * sqrt(1 - sin(u)^2 / (1 - k^2))

        from u = u1 to u = u2, where 
        
            u = (pi - 2 * phi) / 4

        """
        # Useful quantities
        N = 2 * self.lmax + 4
        kc2 = 1 - k2
        u1 = 0.25 * (np.pi - 2 * phi1)
        u2 = 0.25 * (np.pi - 2 * phi2)
        u = np.array([u1, u2])
        sinu = np.sin(u)
        cosu = np.cos(u)
        diff = lambda x: np.diff(x)[0]
        D2 = 1 - sinu**2 / kc2
        if k2 >= 1:
            sgn = 1
        else:
            sgn = -1
        D3 = sgn * abs(D2)**1.5

        # The two boundary conditions
        if sgn == 1:
            f0 = float((ellipe(u[1], 1 / kc2) - ellipe(u[0], 1 / kc2)).real)
        else:
            f0 = float((ellipe(u[1], 1 / kc2) - ellipe(u[0], 1 / kc2)).imag)
            """
            For reference, this expression can be written in terms of the
            real parts of elliptic integrals as follows:

                n = np.floor((u + 0.5 * np.pi) / np.pi)
                term = np.sqrt((sinu ** 2 / kc2 - 1) * (1 / k2 - 1))
                A = n * np.pi + (-1) ** n * np.arcsin(term / sinu)
                F = float((ellipf(A[1], k2) - ellipf(A[0], k2)).real)
                E = float((ellipe(A[1], k2) - ellipe(A[0], k2)).real)
                C = diff(
                    (np.sin(A) * np.cos(A)) / np.sqrt(1 - k2 * np.sin(A) ** 2)
                )
                f0 = -np.sqrt(kc2) * (F - E / kc2 + k2 / kc2 * C)
            """

        fN = quad(
            lambda u: np.sin(u)**(2 * N) * abs(1 - np.sin(u)**2 / kc2)**0.5,
            u1,
            u2,
            epsabs=1e-12,
            epsrel=1e-12,
        )[0]

        # The recursion coefficients
        A = lambda j: 2 * (j + (j - 1) * kc2) / (2 * j + 1)
        B = lambda j: -(2 * j - 3) / (2 * j + 1) * kc2
        C = lambda j: diff(kc2 * sinu**(2 * j - 3) * cosu * D3) / (2 * j + 1)

        # Solve the linear system
        return self.solve(f0, fN, A, B, C, N)
Example #27
0
 def ellip_sec(self,k):
     return mp.ellipe(k**2)
Example #28
0
def z_zn(u, m):
    """Jacobi Zeta (zn(u,m)) function (eq 16.26.12, [Abramowitz]_)."""
    phi = z_am(u, m)
    zn = ellipe(phi, m) - ellipe(m) * u / ellipk(m)
    return zn
Example #29
0
def energy_density(k, x1, x2, x3):   # If there is a multiple root or branch point a value of maxint-1 will be returned; maxint is globally set.

    try:
        if (is_awc_multiple_root(k, x1, x2, x3) ):
            return -1

        if (is_awc_branch_point(k, x1, x2, x3) ):
            return -2

        zeta = calc_zeta(k ,x1, x2, x3)
        eta = calc_eta(k, x1, x2, x3)
        abel = calc_abel(k, zeta, eta)
        mu = calc_mu(k, x1, x2, x3, zeta, abel)
        x=[x1,x2,x3]

        K = complex64(ellipk(k**2))

        E = complex64(ellipe(k**2))

        cm= (2*E-K)/K

        k1 = sqrt(1-k**2)

        xp = x[0]+complex(0,1)*x[1]
        xm = x[0]-complex(0,1)*x[1]
        S =  sqrt(K**2-4*xp*xm)
        SP = sqrt(K**2-4*xp**2)
        SM = sqrt(K**2-4*xm**2)
        SPM = sqrt(-k1**2*(K**2*k**2-4*xm*xp)+(xm-xp)**2)
        R = 2*K**2*k1**2-S**2-8*x[2]**2
        RM = complex(0,1)*SM**2*(xm*(2*k1**2-1)+xp)-(16*complex(0,1))*xm*x[2]**2
        RP = complex(0,1)*SM**2*(xp*(2*k1**2-1)+xm)+(16*complex(0,1))*xp*x[2]**2
        RMBAR=-complex(0,1)*SP**2*( xp*(2*k1**2-1)+xm ) +16*complex(0,1)*xp*x[2]**2
        RPBAR=-complex(0,1)*SP**2*( xm*(2*k1**2-1)+xp ) -16*complex(0,1)*xm*x[2]**2
        r=sqrt(x[0]**2+x[1]**2+x[2]**2)

        DM = dmus(zeta, x, k)
        DZ = dzetas(zeta, x,k)
        DDM = ddmus(zeta, x, k)
        DDZ = ddzetas(zeta, x,k)

        GNUM = grams(zeta, mu, [x1, x2, x3], k)

        inv_gram = matrix(GNUM).I

        higgs = phis(zeta, mu, [x1, x2, x3], k)

        DGS1 = dgrams1(zeta, mu, DM, DZ, x, k)

        DGS2 = dgrams2(zeta, mu, DM, DZ, x, k)

        DGS3 = dgrams3(zeta, mu, DM, DZ, x, k)


        # Using the hermiticity properties its faster to evaluate the matrix entries just once and so if we evaluate
        # the *12 element the *21 is minus the conjugate of this
        # DHS1 = mat([[ dphis111(zeta, mu, DM, DZ, [x1, x2, x3], k), dphis112(zeta, mu, DM, DZ, [x1, x2, x3], k)],
        #            [ dphis121(zeta, mu, DM, DZ, [x1, x2, x3], k), dphis122(zeta, mu, DM, DZ, [x1, x2, x3], k)]])

        DH112 = dphis112(zeta, mu, DM, DZ, [x1, x2, x3], k)

        DHS1 = mat([[ dphis111(zeta, mu, DM, DZ, [x1, x2, x3], k), DH112   ],
                    [ -conj(DH112), dphis122(zeta, mu, DM, DZ, [x1, x2, x3], k)]])

        DH212 = dphis212(zeta, mu, DM, DZ, [x1, x2, x3], k)

        DHS2 = mat([[ dphis211(zeta, mu, DM, DZ, [x1, x2, x3], k), DH212   ],
                    [ -conj(DH212), dphis222(zeta, mu, DM, DZ, [x1, x2, x3], k)]])

        DH312 = dphis312(zeta, mu, DM, DZ, [x1, x2, x3], k)

        DHS3 = mat([[ dphis311(zeta, mu, DM, DZ, [x1, x2, x3], k), DH312   ],
                    [ -conj(DH312), dphis322(zeta, mu, DM, DZ, [x1, x2, x3], k)]])

        DDGS112 = ddgrams112(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)

        DDGS1 = mat([[ ddgrams111(zeta, mu, DM, DZ, DDM,  DDZ, [x1, x2, x3], k), DDGS112 ],
                     [ -conj(DDGS112), ddgrams122(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)]])

        DDGS212 = ddgrams212(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)

        DDGS2 = mat([[ ddgrams211(zeta, mu, DM, DZ, DDM,  DDZ, [x1, x2, x3], k), DDGS212 ],
                     [ -conj(DDGS212) , ddgrams222(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)]])

        DDGS312 = ddgrams312(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)

        DDGS3 = mat([[ ddgrams311(zeta, mu, DM, DZ, DDM,  DDZ, [x1, x2, x3], k), DDGS312 ],
                     [ -conj(DDGS312), ddgrams322(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)]])

        DDHS111 = ddphis111(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS112 = ddphis112(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        # DDHS121 = ddphis121(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS122 = ddphis122(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)

        DDHS1 = mat( [[DDHS111, DDHS112], [ -conj(DDHS112),DDHS122]])

        DDHS211 = ddphis211(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS212 = ddphis212(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        # DDHS221 = ddphis221(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS222 = ddphis222(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)

        DDHS2 = mat( [[DDHS211, DDHS212], [-conj(DDHS212),DDHS222]])

        DDHS311 = ddphis311(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS312 = ddphis312(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        # DDHS321 = ddphis321(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS322 = ddphis322(zeta, mu, DM, DZ, DDM,  DDZ, [x1, x2, x3], k)

        DDHS3 = mat( [[DDHS311, DDHS312], [-conj(DDHS312),DDHS322]])

        ed1 = trace(matmul( matmul(DDHS1, inv_gram) -2* matmul( matmul(DHS1 , inv_gram), matmul(DGS1, inv_gram)) \
                            + matmul(higgs, matmul( 2* matmul(matmul(inv_gram,DGS1), matmul(inv_gram, DGS1)), inv_gram)  - matmul(matmul(inv_gram, DDGS1), inv_gram)),
                            matmul(higgs,inv_gram)) ) \
              + trace( matmul(matmul(DHS1, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS1, inv_gram)),
                              matmul(DHS1, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS1, inv_gram))))

        ed2 = trace(matmul( matmul(DDHS2, inv_gram) -2* matmul( matmul(DHS2 , inv_gram), matmul(DGS2, inv_gram)) \
                            + matmul(higgs, matmul( 2* matmul(matmul(inv_gram,DGS2), matmul(inv_gram, DGS2)), inv_gram)  - matmul(matmul(inv_gram, DDGS2), inv_gram)),
                            matmul(higgs,inv_gram)) ) \
              + trace( matmul(matmul(DHS2, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS2, inv_gram)),
                              matmul(DHS2, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS2, inv_gram))))

        ed3 = trace(matmul( matmul(DDHS3, inv_gram) -2* matmul( matmul(DHS3 , inv_gram), matmul(DGS3, inv_gram)) \
                            + matmul(higgs, matmul( 2* matmul(matmul(inv_gram,DGS3), matmul(inv_gram, DGS3)), inv_gram)  - matmul(matmul(inv_gram, DDGS3), inv_gram)),
                            matmul(higgs,inv_gram)) ) \
              + trace( matmul(matmul(DHS3, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS3, inv_gram)),
                              matmul(DHS3, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS3, inv_gram))))

        # energy_density = -(ed1 + ed2 + ed3).real

        return  -(ed1 + ed2 + ed3).real
    except:
        return -3
Example #30
0
def dexp(x, k):

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm = (2 * E - K) / K

    k1 = sqrt(1 - k**2)

    xp = x[0] + complex(0, 1) * x[1]
    xm = x[0] - complex(0, 1) * x[1]
    S = sqrt(K**2 - 4 * xp * xm)
    SP = sqrt(K**2 - 4 * xp**2)
    SM = sqrt(K**2 - 4 * xm**2)
    SPM = sqrt(-k1**2 * (K**2 * k**2 - 4 * xm * xp) + (xm - xp)**2)
    R = 2 * K**2 * k1**2 - S**2 - 8 * x[2]**2
    RM = complex(0, 1) * SM**2 * (xm * (2 * k1**2 - 1) +
                                  xp) - (16 * complex(0, 1)) * xm * x[2]**2
    RP = complex(0, 1) * SM**2 * (xp * (2 * k1**2 - 1) +
                                  xm) + (16 * complex(0, 1)) * xp * x[2]**2
    RMBAR = -complex(0, 1) * SP**2 * (xp *
                                      (2 * k1**2 - 1) + xm) + 16 * complex(
                                          0, 1) * xp * x[2]**2
    RPBAR = -complex(0, 1) * SP**2 * (xm *
                                      (2 * k1**2 - 1) + xp) - 16 * complex(
                                          0, 1) * xm * x[2]**2
    r = sqrt(x[0]**2 + x[1]**2 + x[2]**2)

    DS = [None] * 2
    DSP = [None] * 2
    DSM = [None] * 2
    DSPM = [None] * 2
    DRP = [None] * 3
    DRM = [None] * 3
    DRPBAR = [None] * 3
    DRMBAR = [None] * 3

    DS[0] = -4 * (K**2 - 4 * x[0]**2 - 4 * x[1]**2)**(-0.1e1 / 0.2e1) * x[0]

    DS[1] = -4 * (K**2 - 4 * x[0]**2 - 4 * x[1]**2)**(-0.1e1 / 0.2e1) * x[1]

    DSP[0] = -4 * (x[0] + complex(0, 1) * x[1]) * (
        4 * x[1]**2 + complex(0, -8) * x[0] * x[1] + K**2 -
        4 * x[0]**2)**(-0.1e1 / 0.2e1)

    DSP[1] = -4 * (complex(0, 1) * x[0] -
                   x[1]) * (4 * x[1]**2 + complex(0, -8) * x[0] * x[1] + K**2 -
                            4 * x[0]**2)**(-0.1e1 / 0.2e1)

    DSM[0] = 4 * (complex(0, 1) * x[1] -
                  x[0]) * (4 * x[1]**2 + complex(0, 8) * x[0] * x[1] + K**2 -
                           4 * x[0]**2)**(-0.1e1 / 0.2e1)

    DSM[1] = 4 * (x[1] + complex(0, 1) * x[0]) * (
        4 * x[1]**2 + complex(0, 8) * x[0] * x[1] + K**2 -
        4 * x[0]**2)**(-0.1e1 / 0.2e1)

    DSPM[0] = 4 * (-K**2 * k**2 * k1**2 + 4 * k1**2 * x[0]**2 + 4 * k1**2 *
                   x[1]**2 - 4 * x[1]**2)**(-0.1e1 / 0.2e1) * k1**2 * x[0]

    DSPM[1] = 4 * x[1] * (
        k1**2 - 1) * (-K**2 * k**2 * k1**2 + 4 * k1**2 * x[0]**2 +
                      4 * k1**2 * x[1]**2 - 4 * x[1]**2)**(-0.1e1 / 0.2e1)

    DRP[0] = complex(
        0, -8) * k1**2 * x[1]**2 - 16 * k1**2 * x[0] * x[1] + complex(
            0, 2) * K**2 * k1**2 + complex(0, 16) * x[1]**2 + complex(
                0, -24) * k1**2 * x[0]**2 - 16 * x[0] * x[1] + complex(
                    0, 16) * x[2]**2

    DRP[1] = -24 * k1**2 * x[1]**2 + complex(0, -16) * k1**2 * x[0] * x[
        1] - 2 * K**2 * k1**2 + 24 * x[1]**2 - 8 * k1**2 * x[0]**2 + complex(
            0, 32) * x[0] * x[1] + 2 * K**2 - 8 * x[0]**2 - 16 * x[2]**2

    DRP[2] = -32 * x[1] * x[2] + complex(0, 32) * x[0] * x[2]

    DRM[0] = complex(
        0, 24) * k1**2 * x[1]**2 - 48 * k1**2 * x[0] * x[1] + complex(
            0, 2) * K**2 * k1**2 + complex(0, -16) * x[1]**2 + complex(
                0, -24) * k1**2 * x[0]**2 + 16 * x[0] * x[1] + complex(
                    0, -16) * x[2]**2

    DRM[1] = 24 * k1**2 * x[1]**2 + complex(0, 48) * k1**2 * x[0] * x[
        1] + 2 * K**2 * k1**2 - 24 * x[1]**2 - 24 * k1**2 * x[0]**2 + complex(
            0, -32) * x[0] * x[1] - 2 * K**2 + 8 * x[0]**2 - 16 * x[2]**2

    DRM[2] = -32 * x[1] * x[2] + complex(0, -32) * x[0] * x[2]

    DRPBAR[0] = complex(
        0, 8) * k1**2 * x[1]**2 - 16 * k1**2 * x[0] * x[1] + complex(
            0, -2) * K**2 * k1**2 + complex(0, -16) * x[1]**2 + complex(
                0, 24) * k1**2 * x[0]**2 - 16 * x[0] * x[1] + complex(
                    0, -16) * x[2]**2

    DRPBAR[1] = -24 * k1**2 * x[1]**2 + complex(0, 16) * k1**2 * x[0] * x[
        1] - 2 * K**2 * k1**2 + 24 * x[1]**2 - 8 * k1**2 * x[0]**2 + complex(
            0, -32) * x[0] * x[1] + 2 * K**2 - 8 * x[0]**2 - 16 * x[2]**2

    DRPBAR[2] = -32 * x[1] * x[2] + complex(0, -32) * x[0] * x[2]

    DRMBAR[0] = complex(
        0, -24) * k1**2 * x[1]**2 - 48 * k1**2 * x[0] * x[1] + complex(
            0, -2) * K**2 * k1**2 + complex(0, 16) * x[1]**2 + complex(
                0, 24) * k1**2 * x[0]**2 + 16 * x[0] * x[1] + complex(
                    0, 16) * x[2]**2

    DRMBAR[1] = 24 * k1**2 * x[1]**2 + complex(0, -48) * k1**2 * x[0] * x[
        1] + 2 * K**2 * k1**2 - 24 * x[1]**2 - 24 * k1**2 * x[0]**2 + complex(
            0, 32) * x[0] * x[1] - 2 * K**2 + 8 * x[0]**2 - 16 * x[2]**2

    DRMBAR[2] = -32 * x[1] * x[2] + complex(0, 32) * x[0] * x[2]

    return DS, DSP, DSM, DSPM, DRP, DRM, DRPBAR, DRMBAR
Example #31
0
def energy_density(k, x1, x2, x3):   # If there is a multiple root or branch point a value of maxint-1 will be returned; maxint is globally set.

    try:
        if (is_awc_multiple_root(k, x1, x2, x3) ):
            return -1

        if (is_awc_branch_point(k, x1, x2, x3) ):
            return -2

        zeta = calc_zeta(k ,x1, x2, x3)
        eta = calc_eta(k, x1, x2, x3)
        abel = calc_abel(k, zeta, eta)
        mu = calc_mu(k, x1, x2, x3, zeta, abel)
        x=[x1,x2,x3]

        K = complex64(ellipk(k**2))

        E = complex64(ellipe(k**2))

        cm= (2*E-K)/K

        k1 = sqrt(1-k**2)

        xp = x[0]+complex(0,1)*x[1]
        xm = x[0]-complex(0,1)*x[1]
        S =  sqrt(K**2-4*xp*xm)
        SP = sqrt(K**2-4*xp**2)
        SM = sqrt(K**2-4*xm**2)
        SPM = sqrt(-k1**2*(K**2*k**2-4*xm*xp)+(xm-xp)**2)
        R = 2*K**2*k1**2-S**2-8*x[2]**2
        RM = complex(0,1)*SM**2*(xm*(2*k1**2-1)+xp)-(16*complex(0,1))*xm*x[2]**2
        RP = complex(0,1)*SM**2*(xp*(2*k1**2-1)+xm)+(16*complex(0,1))*xp*x[2]**2
        RMBAR=-complex(0,1)*SP**2*( xp*(2*k1**2-1)+xm ) +16*complex(0,1)*xp*x[2]**2
        RPBAR=-complex(0,1)*SP**2*( xm*(2*k1**2-1)+xp ) -16*complex(0,1)*xm*x[2]**2
        r=sqrt(x[0]**2+x[1]**2+x[2]**2)

        DM = dmus(zeta, x, k)
        DZ = dzetas(zeta, x,k)
        DDM = ddmus(zeta, x, k)
        DDZ = ddzetas(zeta, x,k)

        GNUM = grams(zeta, mu, [x1, x2, x3], k)

        inv_gram = matrix(GNUM).I

        higgs = phis(zeta, mu, [x1, x2, x3], k)

        DGS1 = dgrams1(zeta, mu, DM, DZ, x, k)

        DGS2 = dgrams2(zeta, mu, DM, DZ, x, k)

        DGS3 = dgrams3(zeta, mu, DM, DZ, x, k)


        # Using the hermiticity properties its faster to evaluate the matrix entries just once and so if we evaluate
        # the *12 element the *21 is minus the conjugate of this
        # DHS1 = mat([[ dphis111(zeta, mu, DM, DZ, [x1, x2, x3], k), dphis112(zeta, mu, DM, DZ, [x1, x2, x3], k)],
        #            [ dphis121(zeta, mu, DM, DZ, [x1, x2, x3], k), dphis122(zeta, mu, DM, DZ, [x1, x2, x3], k)]])

        DH112 = dphis112(zeta, mu, DM, DZ, [x1, x2, x3], k)

        DHS1 = mat([[ dphis111(zeta, mu, DM, DZ, [x1, x2, x3], k), DH112   ],
                    [ -conj(DH112), dphis122(zeta, mu, DM, DZ, [x1, x2, x3], k)]])

        DH212 = dphis212(zeta, mu, DM, DZ, [x1, x2, x3], k)

        DHS2 = mat([[ dphis211(zeta, mu, DM, DZ, [x1, x2, x3], k), DH212   ],
                    [ -conj(DH212), dphis222(zeta, mu, DM, DZ, [x1, x2, x3], k)]])

        DH312 = dphis312(zeta, mu, DM, DZ, [x1, x2, x3], k)

        DHS3 = mat([[ dphis311(zeta, mu, DM, DZ, [x1, x2, x3], k), DH312   ],
                    [ -conj(DH312), dphis322(zeta, mu, DM, DZ, [x1, x2, x3], k)]])

        DDGS112 = ddgrams112(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)

        DDGS1 = mat([[ ddgrams111(zeta, mu, DM, DZ, DDM,  DDZ, [x1, x2, x3], k), DDGS112 ],
                     [ -conj(DDGS112), ddgrams122(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)]])

        DDGS212 = ddgrams212(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)

        DDGS2 = mat([[ ddgrams211(zeta, mu, DM, DZ, DDM,  DDZ, [x1, x2, x3], k), DDGS212 ],
                     [ -conj(DDGS212) , ddgrams222(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)]])

        DDGS312 = ddgrams312(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)

        DDGS3 = mat([[ ddgrams311(zeta, mu, DM, DZ, DDM,  DDZ, [x1, x2, x3], k), DDGS312 ],
                     [ -conj(DDGS312), ddgrams322(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k)]])

        DDHS111 = ddphis111(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS112 = ddphis112(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        # DDHS121 = ddphis121(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS122 = ddphis122(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)

        DDHS1 = mat( [[DDHS111, DDHS112], [ -conj(DDHS112),DDHS122]])

        DDHS211 = ddphis211(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS212 = ddphis212(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        # DDHS221 = ddphis221(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS222 = ddphis222(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)

        DDHS2 = mat( [[DDHS211, DDHS212], [-conj(DDHS212),DDHS222]])

        DDHS311 = ddphis311(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS312 = ddphis312(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        # DDHS321 = ddphis321(zeta, mu,DM, DZ, DDM,  DDZ, [x1, x2, x3], k)
        DDHS322 = ddphis322(zeta, mu, DM, DZ, DDM,  DDZ, [x1, x2, x3], k)

        DDHS3 = mat( [[DDHS311, DDHS312], [-conj(DDHS312),DDHS322]])

        ed1 = trace(matmul( matmul(DDHS1, inv_gram) -2* matmul( matmul(DHS1 , inv_gram), matmul(DGS1, inv_gram)) \
                            + matmul(higgs, matmul( 2* matmul(matmul(inv_gram,DGS1), matmul(inv_gram, DGS1)), inv_gram)  - matmul(matmul(inv_gram, DDGS1), inv_gram)),
                            matmul(higgs,inv_gram)) ) \
              + trace( matmul(matmul(DHS1, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS1, inv_gram)),
                              matmul(DHS1, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS1, inv_gram))))

        ed2 = trace(matmul( matmul(DDHS2, inv_gram) -2* matmul( matmul(DHS2 , inv_gram), matmul(DGS2, inv_gram)) \
                            + matmul(higgs, matmul( 2* matmul(matmul(inv_gram,DGS2), matmul(inv_gram, DGS2)), inv_gram)  - matmul(matmul(inv_gram, DDGS2), inv_gram)),
                            matmul(higgs,inv_gram)) ) \
              + trace( matmul(matmul(DHS2, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS2, inv_gram)),
                              matmul(DHS2, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS2, inv_gram))))

        ed3 = trace(matmul( matmul(DDHS3, inv_gram) -2* matmul( matmul(DHS3 , inv_gram), matmul(DGS3, inv_gram)) \
                            + matmul(higgs, matmul( 2* matmul(matmul(inv_gram,DGS3), matmul(inv_gram, DGS3)), inv_gram)  - matmul(matmul(inv_gram, DDGS3), inv_gram)),
                            matmul(higgs,inv_gram)) ) \
              + trace( matmul(matmul(DHS3, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS3, inv_gram)),
                              matmul(DHS3, inv_gram) - matmul(matmul(higgs, inv_gram), matmul(DGS3, inv_gram))))

        # energy_density = -(ed1 + ed2 + ed3).real

        return  -(ed1 + ed2 + ed3).real
    except:
        return -3
Example #32
0
def ddexp(x, k):

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm= (2*E-K)/K

    k1 = sqrt(1-k**2)

    xp = x[0]+complex(0,1)*x[1]
    xm = x[0]-complex(0,1)*x[1]
    S =  sqrt(K**2-4*xp*xm)
    SP = sqrt(K**2-4*xp**2)
    SM = sqrt(K**2-4*xm**2)
    SPM = sqrt(-k1**2*(K**2*k**2-4*xm*xp)+(xm-xp)**2)
    R = 2*K**2*k1**2-S**2-8*x[2]**2
    RM = complex(0,1)*SM**2*(xm*(2*k1**2-1)+xp)-(16*complex(0,1))*xm*x[2]**2
    RP = complex(0,1)*SM**2*(xp*(2*k1**2-1)+xm)+(16*complex(0,1))*xp*x[2]**2
    RMBAR=-complex(0,1)*SP**2*( xp*(2*k1**2-1)+xm ) +16*complex(0,1)*xp*x[2]**2
    RPBAR=-complex(0,1)*SP**2*( xm*(2*k1**2-1)+xp ) -16*complex(0,1)*xm*x[2]**2
    r=sqrt(x[0]**2+x[1]**2+x[2]**2)

    DDS = [None]*2
    DDSP = [None]*2
    DDSM = [None]*2
    DDSPM = [None]*2
    DDRP = [None]*3
    DDRM = [None]*3
    DDRPBAR = [None]*3
    DDRMBAR = [None]*3

    DDS[0] = -4 * (K ** 2 - 4 * x[1] ** 2) * (K ** 2 - 4 * x[0] ** 2 - 4 * x[1] ** 2) ** (-0.3e1 / 0.2e1)

    DDS[1] = -4 * (K ** 2 - 4 * x[0] ** 2) * (K ** 2 - 4 * x[0] ** 2 - 4 * x[1] ** 2) ** (-0.3e1 / 0.2e1)

    DDSP[0] = -4 * K ** 2 * (4 * x[1] ** 2 + complex(0, -8) * x[0] * x[1] + K ** 2 - 4 * x[0] ** 2) ** (-0.3e1 / 0.2e1)

    DDSP[1] = 4 * K ** 2 * (4 * x[1] ** 2 + complex(0, -8) * x[0] * x[1] + K ** 2 - 4 * x[0] ** 2) ** (-0.3e1 / 0.2e1)

    DDSM[0] = -4 * K ** 2 * (4 * x[1] ** 2 + complex(0, 8) * x[0] * x[1] + K ** 2 - 4 * x[0] ** 2) ** (-0.3e1 / 0.2e1)

    DDSM[1] = 4 * K ** 2 * (4 * x[1] ** 2 + complex(0, 8) * x[0] * x[1] + K ** 2 - 4 * x[0] ** 2) ** (-0.3e1 / 0.2e1)

    DDSPM[0] = -4 * k1 ** 2 * (K ** 2 * k ** 2 * k1 ** 2 - 4 * k1 ** 2 * x[1] ** 2 + 4 * x[1] ** 2) * (-K ** 2 * k ** 2 * k1 ** 2 + 4 * k1 ** 2 * x[0] ** 2 + 4 * k1 ** 2 * x[1] ** 2 - 4 * x[1] ** 2) ** (-0.3e1 / 0.2e1)

    DDSPM[1] = -4 * (k1 ** 2 - 1) * k1 ** 2 * (K ** 2 * k ** 2 - 4 * x[0] ** 2) * (-K ** 2 * k ** 2 * k1 ** 2 + 4 * k1 ** 2 * x[0] ** 2 + 4 * k1 ** 2 * x[1] ** 2 - 4 * x[1] ** 2) ** (-0.3e1 / 0.2e1)

    DDRP[0] = -16 * k1 ** 2 * x[1] + complex(0, -48) * k1 ** 2 * x[0] - 16 * x[1]

    DDRP[1] = -48 * k1 ** 2 * x[1] + complex(0, -16) * k1 ** 2 * x[0] + 48 * x[1] + complex(0, 32) * x[0]

    DDRP[2] = -32 * x[1] + complex(0, 32) * x[0]

    DDRM[0] = -48 * k1 ** 2 * x[1] + complex(0, -48) * k1 ** 2 * x[0] + 16 * x[1]

    DDRM[1] = 48 * k1 ** 2 * x[1] + complex(0, 48) * k1 ** 2 * x[0] - 48 * x[1] + complex(0, -32) * x[0]

    DDRM[2] = -32 * x[1] + complex(0, -32) * x[0]

    DDRPBAR[0] = -16 * k1 ** 2 * x[1] + complex(0, 48) * k1 ** 2 * x[0] - 16 * x[1]

    DDRPBAR[1] = -48 * k1 ** 2 * x[1] + complex(0, 16) * k1 ** 2 * x[0] + 48 * x[1] + complex(0, -32) * x[0]

    DDRPBAR[2] = -32 * x[1] + complex(0, -32) * x[0]

    DDRMBAR[0] = -48 * k1 ** 2 * x[1] + complex(0, 48) * k1 ** 2 * x[0] + 16 * x[1]

    DDRMBAR[1] = 48 * k1 ** 2 * x[1] + complex(0, -48) * k1 ** 2 * x[0] - 48 * x[1] + complex(0, 32) * x[0]

    DDRMBAR[2] = -32 * x[1] + complex(0, 32) * x[0]
Example #33
0
def ddexp(x, k):

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm = (2 * E - K) / K

    k1 = sqrt(1 - k**2)

    xp = x[0] + complex(0, 1) * x[1]
    xm = x[0] - complex(0, 1) * x[1]
    S = sqrt(K**2 - 4 * xp * xm)
    SP = sqrt(K**2 - 4 * xp**2)
    SM = sqrt(K**2 - 4 * xm**2)
    SPM = sqrt(-k1**2 * (K**2 * k**2 - 4 * xm * xp) + (xm - xp)**2)
    R = 2 * K**2 * k1**2 - S**2 - 8 * x[2]**2
    RM = complex(0, 1) * SM**2 * (xm * (2 * k1**2 - 1) +
                                  xp) - (16 * complex(0, 1)) * xm * x[2]**2
    RP = complex(0, 1) * SM**2 * (xp * (2 * k1**2 - 1) +
                                  xm) + (16 * complex(0, 1)) * xp * x[2]**2
    RMBAR = -complex(0, 1) * SP**2 * (xp *
                                      (2 * k1**2 - 1) + xm) + 16 * complex(
                                          0, 1) * xp * x[2]**2
    RPBAR = -complex(0, 1) * SP**2 * (xm *
                                      (2 * k1**2 - 1) + xp) - 16 * complex(
                                          0, 1) * xm * x[2]**2
    r = sqrt(x[0]**2 + x[1]**2 + x[2]**2)

    DDS = [None] * 2
    DDSP = [None] * 2
    DDSM = [None] * 2
    DDSPM = [None] * 2
    DDRP = [None] * 3
    DDRM = [None] * 3
    DDRPBAR = [None] * 3
    DDRMBAR = [None] * 3

    DDS[0] = -4 * (K**2 - 4 * x[1]**2) * (K**2 - 4 * x[0]**2 -
                                          4 * x[1]**2)**(-0.3e1 / 0.2e1)

    DDS[1] = -4 * (K**2 - 4 * x[0]**2) * (K**2 - 4 * x[0]**2 -
                                          4 * x[1]**2)**(-0.3e1 / 0.2e1)

    DDSP[0] = -4 * K**2 * (4 * x[1]**2 + complex(0, -8) * x[0] * x[1] + K**2 -
                           4 * x[0]**2)**(-0.3e1 / 0.2e1)

    DDSP[1] = 4 * K**2 * (4 * x[1]**2 + complex(0, -8) * x[0] * x[1] + K**2 -
                          4 * x[0]**2)**(-0.3e1 / 0.2e1)

    DDSM[0] = -4 * K**2 * (4 * x[1]**2 + complex(0, 8) * x[0] * x[1] + K**2 -
                           4 * x[0]**2)**(-0.3e1 / 0.2e1)

    DDSM[1] = 4 * K**2 * (4 * x[1]**2 + complex(0, 8) * x[0] * x[1] + K**2 -
                          4 * x[0]**2)**(-0.3e1 / 0.2e1)

    DDSPM[0] = -4 * k1**2 * (
        K**2 * k**2 * k1**2 - 4 * k1**2 * x[1]**2 +
        4 * x[1]**2) * (-K**2 * k**2 * k1**2 + 4 * k1**2 * x[0]**2 +
                        4 * k1**2 * x[1]**2 - 4 * x[1]**2)**(-0.3e1 / 0.2e1)

    DDSPM[1] = -4 * (k1**2 - 1) * k1**2 * (K**2 * k**2 - 4 * x[0]**2) * (
        -K**2 * k**2 * k1**2 + 4 * k1**2 * x[0]**2 + 4 * k1**2 * x[1]**2 -
        4 * x[1]**2)**(-0.3e1 / 0.2e1)

    DDRP[0] = -16 * k1**2 * x[1] + complex(0, -48) * k1**2 * x[0] - 16 * x[1]

    DDRP[1] = -48 * k1**2 * x[1] + complex(
        0, -16) * k1**2 * x[0] + 48 * x[1] + complex(0, 32) * x[0]

    DDRP[2] = -32 * x[1] + complex(0, 32) * x[0]

    DDRM[0] = -48 * k1**2 * x[1] + complex(0, -48) * k1**2 * x[0] + 16 * x[1]

    DDRM[1] = 48 * k1**2 * x[1] + complex(
        0, 48) * k1**2 * x[0] - 48 * x[1] + complex(0, -32) * x[0]

    DDRM[2] = -32 * x[1] + complex(0, -32) * x[0]

    DDRPBAR[0] = -16 * k1**2 * x[1] + complex(0, 48) * k1**2 * x[0] - 16 * x[1]

    DDRPBAR[1] = -48 * k1**2 * x[1] + complex(
        0, 16) * k1**2 * x[0] + 48 * x[1] + complex(0, -32) * x[0]

    DDRPBAR[2] = -32 * x[1] + complex(0, -32) * x[0]

    DDRMBAR[0] = -48 * k1**2 * x[1] + complex(0, 48) * k1**2 * x[0] + 16 * x[1]

    DDRMBAR[1] = 48 * k1**2 * x[1] + complex(
        0, -48) * k1**2 * x[0] - 48 * x[1] + complex(0, 32) * x[0]

    DDRMBAR[2] = -32 * x[1] + complex(0, 32) * x[0]
Example #34
0
def z_zn(u, m):
    """Jacobi Zeta (zn(u,m)) function (eq 16.26.12, [Abramowitz]_)."""
    phi = z_am(u, m)
    zn = ellipe(phi, m) - ellipe(m) * u / ellipk(m)
    return zn
Example #35
0
def dexp(x, k):

    K = complex64(ellipk(k**2))

    E = complex64(ellipe(k**2))

    cm= (2*E-K)/K

    k1 = sqrt(1-k**2)

    xp = x[0]+complex(0,1)*x[1]
    xm = x[0]-complex(0,1)*x[1]
    S =  sqrt(K**2-4*xp*xm)
    SP = sqrt(K**2-4*xp**2)
    SM = sqrt(K**2-4*xm**2)
    SPM = sqrt(-k1**2*(K**2*k**2-4*xm*xp)+(xm-xp)**2)
    R = 2*K**2*k1**2-S**2-8*x[2]**2
    RM = complex(0,1)*SM**2*(xm*(2*k1**2-1)+xp)-(16*complex(0,1))*xm*x[2]**2
    RP = complex(0,1)*SM**2*(xp*(2*k1**2-1)+xm)+(16*complex(0,1))*xp*x[2]**2
    RMBAR=-complex(0,1)*SP**2*( xp*(2*k1**2-1)+xm ) +16*complex(0,1)*xp*x[2]**2
    RPBAR=-complex(0,1)*SP**2*( xm*(2*k1**2-1)+xp ) -16*complex(0,1)*xm*x[2]**2
    r=sqrt(x[0]**2+x[1]**2+x[2]**2)

    DS = [None]*2
    DSP = [None]*2
    DSM = [None]*2
    DSPM = [None]*2
    DRP = [None]*3
    DRM = [None]*3
    DRPBAR = [None]*3
    DRMBAR = [None]*3


    DS[0] = -4 * (K ** 2 - 4 * x[0] ** 2 - 4 * x[1] ** 2) ** (-0.1e1 / 0.2e1) * x[0]

    DS[1] = -4 * (K ** 2 - 4 * x[0] ** 2 - 4 * x[1] ** 2) ** (-0.1e1 / 0.2e1) * x[1]

    DSP[0] = -4 * (x[0] + complex(0, 1) * x[1]) * (4 * x[1] ** 2 + complex(0, -8) * x[0] * x[1] + K ** 2 - 4 * x[0] ** 2) ** (-0.1e1 / 0.2e1)

    DSP[1] = -4 * (complex(0, 1) * x[0] - x[1]) * (4 * x[1] ** 2 + complex(0, -8) * x[0] * x[1] + K ** 2 - 4 * x[0] ** 2) ** (-0.1e1 / 0.2e1)

    DSM[0] = 4 * (complex(0, 1) * x[1] - x[0]) * (4 * x[1] ** 2 + complex(0, 8) * x[0] * x[1] + K ** 2 - 4 * x[0] ** 2) ** (-0.1e1 / 0.2e1)

    DSM[1] = 4 * (x[1] + complex(0, 1) * x[0]) * (4 * x[1] ** 2 + complex(0, 8) * x[0] * x[1] + K ** 2 - 4 * x[0] ** 2) ** (-0.1e1 / 0.2e1)

    DSPM[0] = 4 * (-K ** 2 * k ** 2 * k1 ** 2 + 4 * k1 ** 2 * x[0] ** 2 + 4 * k1 ** 2 * x[1] ** 2 - 4 * x[1] ** 2) ** (-0.1e1 / 0.2e1) * k1 ** 2 * x[0]

    DSPM[1] = 4 * x[1] * (k1 ** 2 - 1) * (-K ** 2 * k ** 2 * k1 ** 2 + 4 * k1 ** 2 * x[0] ** 2 + 4 * k1 ** 2 * x[1] ** 2 - 4 * x[1] ** 2) ** (-0.1e1 / 0.2e1)

    DRP[0] = complex(0, -8) * k1 ** 2 * x[1] ** 2 - 16 * k1 ** 2 * x[0] * x[1] + complex(0, 2) * K ** 2 * k1 ** 2 + complex(0, 16) * x[1] ** 2 + complex(0, -24) * k1 ** 2 * x[0] ** 2 - 16 * x[0] * x[1] + complex(0, 16) * x[2] ** 2

    DRP[1] = -24 * k1 ** 2 * x[1] ** 2 + complex(0, -16) * k1 ** 2 * x[0] * x[1] - 2 * K ** 2 * k1 ** 2 + 24 * x[1] ** 2 - 8 * k1 ** 2 * x[0] ** 2 + complex(0, 32) * x[0] * x[1] + 2 * K ** 2 - 8 * x[0] ** 2 - 16 * x[2] ** 2

    DRP[2] = -32 * x[1] * x[2] + complex(0, 32) * x[0] * x[2]

    DRM[0] = complex(0, 24) * k1 ** 2 * x[1] ** 2 - 48 * k1 ** 2 * x[0] * x[1] + complex(0, 2) * K ** 2 * k1 ** 2 + complex(0, -16) * x[1] ** 2 + complex(0, -24) * k1 ** 2 * x[0] ** 2 + 16 * x[0] * x[1] + complex(0, -16) * x[2] ** 2

    DRM[1] = 24 * k1 ** 2 * x[1] ** 2 + complex(0, 48) * k1 ** 2 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 - 24 * x[1] ** 2 - 24 * k1 ** 2 * x[0] ** 2 + complex(0, -32) * x[0] * x[1] - 2 * K ** 2 + 8 * x[0] ** 2 - 16 * x[2] ** 2

    DRM[2] = -32 * x[1] * x[2] + complex(0, -32) * x[0] * x[2]

    DRPBAR[0] = complex(0, 8) * k1 ** 2 * x[1] ** 2 - 16 * k1 ** 2 * x[0] * x[1] + complex(0, -2) * K ** 2 * k1 ** 2 + complex(0, -16) * x[1] ** 2 + complex(0, 24) * k1 ** 2 * x[0] ** 2 - 16 * x[0] * x[1] + complex(0, -16) * x[2] ** 2

    DRPBAR[1] = -24 * k1 ** 2 * x[1] ** 2 + complex(0, 16) * k1 ** 2 * x[0] * x[1] - 2 * K ** 2 * k1 ** 2 + 24 * x[1] ** 2 - 8 * k1 ** 2 * x[0] ** 2 + complex(0, -32) * x[0] * x[1] + 2 * K ** 2 - 8 * x[0] ** 2 - 16 * x[2] ** 2

    DRPBAR[2] = -32 * x[1] * x[2] + complex(0, -32) * x[0] * x[2]

    DRMBAR[0] = complex(0, -24) * k1 ** 2 * x[1] ** 2 - 48 * k1 ** 2 * x[0] * x[1] + complex(0, -2) * K ** 2 * k1 ** 2 + complex(0, 16) * x[1] ** 2 + complex(0, 24) * k1 ** 2 * x[0] ** 2 + 16 * x[0] * x[1] + complex(0, 16) * x[2] ** 2

    DRMBAR[1] = 24 * k1 ** 2 * x[1] ** 2 + complex(0, -48) * k1 ** 2 * x[0] * x[1] + 2 * K ** 2 * k1 ** 2 - 24 * x[1] ** 2 - 24 * k1 ** 2 * x[0] ** 2 + complex(0, 32) * x[0] * x[1] - 2 * K ** 2 + 8 * x[0] ** 2 - 16 * x[2] ** 2

    DRMBAR[2] = -32 * x[1] * x[2] + complex(0, 32) * x[0] * x[2]

    return DS, DSP, DSM, DSPM, DRP, DRM, DRPBAR, DRMBAR
Example #36
0
def ellip(bo, ro, kappa):

    # Helper variables
    k2 = (1 - ro**2 - bo**2 + 2 * bo * ro) / (4 * bo * ro)
    if np.abs(1 - k2) < STARRY_K2_ONE_TOL:
        if k2 == 1.0:
            k2 = 1 + STARRY_K2_ONE_TOL
        elif k2 < 1.0:
            k2 = 1.0 - STARRY_K2_ONE_TOL
        else:
            k2 = 1.0 + STARRY_K2_ONE_TOL
    k = np.sqrt(k2)
    k2inv = 1 / k2
    kinv = np.sqrt(k2inv)
    kc2 = 1 - k2

    # Complete elliptic integrals (we'll need them to compute offsets below)
    if k2 < 1:
        K0 = float(ellipk(k2))
        E0 = float(ellipe(k2))
        E0 = np.sqrt(k2inv) * (E0 - (1 - k2) * K0)
        K0 *= np.sqrt(k2)
        RJ0 = 0.0
    else:
        K0 = float(ellipk(k2inv))
        E0 = float(ellipe(k2inv))
        if (bo != 0) and (bo != ro):
            p0 = (ro * ro + bo * bo + 2 * ro * bo) / (ro * ro + bo * bo -
                                                      2 * ro * bo)
            PI0 = float(ellippi(1 - p0, k2inv))
            RJ0 = -12.0 / (1 - p0) * (PI0 - K0)
        else:
            RJ0 = 0.0

    if k2 < 1:

        # Analytic continuation from (17.4.15-16) in Abramowitz & Stegun
        # A better format is here: https://dlmf.nist.gov/19.7#ii

        # Helper variables
        arg = kinv * np.sin(kappa / 2)
        tanphi = arg / np.sqrt(1 - arg**2)
        tanphi[arg >= 1] = STARRY_HUGE_TAN
        tanphi[arg <= -1] = -STARRY_HUGE_TAN

        # Compute the elliptic integrals
        F = EllipF(tanphi, k2) * k
        E = kinv * (EllipE(tanphi, k2) - kc2 * kinv * F)

        # Add offsets to account for the limited domain of `el2`
        for i in range(len(kappa)):
            if kappa[i] > 3 * np.pi:
                F[i] += 4 * K0
                E[i] += 4 * E0
            elif kappa[i] > np.pi:
                F[i] = 2 * K0 - F[i]
                E[i] = 2 * E0 - E[i]

    else:

        # Helper variables
        tanphi = np.tan(kappa / 2)

        # Compute the elliptic integrals
        F = EllipF(tanphi, k2inv)  # el2(tanphi, kcinv, 1, 1)
        E = EllipE(tanphi, k2inv)  # el2(tanphi, kcinv, 1, kc2inv)

        # Add offsets to account for the limited domain of `el2`
        for i in range(len(kappa)):
            if kappa[i] > 3 * np.pi:
                F[i] += 4 * K0
                E[i] += 4 * E0
            elif kappa[i] > np.pi:
                F[i] += 2 * K0
                E[i] += 2 * E0

    # Must compute RJ separately
    if np.abs(bo - ro) > STARRY_PAL_BO_EQUALS_RO_TOL:
        p = (ro * ro + bo * bo -
             2 * ro * bo * np.cos(kappa)) / (ro * ro + bo * bo - 2 * ro * bo)
        RJ = EllipJ(kappa, k2, p)

        # Add offsets to account for the limited domain of `rj`
        if RJ0 != 0.0:
            for i in range(len(kappa)):
                if kappa[i] > 3 * np.pi:
                    RJ[i] += 2 * RJ0
                elif kappa[i] > np.pi:
                    RJ[i] += RJ0

    else:
        RJ = np.zeros_like(kappa)

    # Compute the *definite* elliptic integrals
    F = pairdiff(F)
    E = pairdiff(E)
    PIprime = pairdiff(RJ)

    return F, E, PIprime