def __compute_periods(self): # A+S 18.9. from mpmath import sqrt, ellipk, mpc, pi, mpf Delta = self.Delta e1, e2, e3 = self.__roots if Delta > 0: m = (e2 - e3) / (e1 - e3) Km = ellipk(m) Kpm = ellipk(1 - m) om = Km / sqrt(e1 - e3) omp = mpc(0,1) * om * Kpm / Km elif Delta < 0: # NOTE: the expression in the sqrt has to be real and positive, as e1 and e3 are # complex conjugate and e2 is real. H2 = (sqrt((e2 - e3) * (e2 - e1))).real assert(H2 > 0) m = mpf(1) / mpf(2) - 3 * e2 / (4 * H2) Km = ellipk(m) Kpm = ellipk(1 - m) om2 = Km / sqrt(H2) om2p = mpc(0,1) * Kpm * om2 / Km om = (om2 - om2p) / 2 omp = (om2 + om2p) / 2 else: g2, g3 = self.__invariants if g2 == 0 and g3 == 0: om = mpf('+inf') omp = mpc(0,'+inf') else: # NOTE: here there is no need for the dichotomy on the sign of g3 because # we are already working in a regime in which g3 >= 0 by definition. c = e1 / 2 om = 1 / sqrt(12 * c) * pi() omp = mpc(0,'+inf') return 2 * om, 2 * omp
def __compute_periods(self): # A+S 18.9. from mpmath import sqrt, ellipk, mpc, pi, mpf Delta = self.Delta e1, e2, e3 = self.__roots if Delta > 0: m = (e2 - e3) / (e1 - e3) Km = ellipk(m) Kpm = ellipk(1 - m) om = Km / sqrt(e1 - e3) omp = mpc(0, 1) * om * Kpm / Km elif Delta < 0: # NOTE: the expression in the sqrt has to be real and positive, as e1 and e3 are # complex conjugate and e2 is real. H2 = (sqrt((e2 - e3) * (e2 - e1))).real assert (H2 > 0) m = mpf(1) / mpf(2) - 3 * e2 / (4 * H2) Km = ellipk(m) Kpm = ellipk(1 - m) om2 = Km / sqrt(H2) om2p = mpc(0, 1) * Kpm * om2 / Km om = (om2 - om2p) / 2 omp = (om2 + om2p) / 2 else: g2, g3 = self.__invariants if g2 == 0 and g3 == 0: om = mpf('+inf') omp = mpc(0, '+inf') else: # NOTE: here there is no need for the dichotomy on the sign of g3 because # we are already working in a regime in which g3 >= 0 by definition. c = e1 / 2 om = 1 / sqrt(12 * c) * pi() omp = mpc(0, '+inf') return 2 * om, 2 * omp
def test_value3( self): k = np.sqrt( 0.50) m = mp.mfrom( k = k) K = mp.ellipk( m) Kp = mp.ellipk( 1 - m) self.assertAlmostEqual( 0.50, m) self.assertAlmostEqual( mp.mpf( 1.854074677301), K) self.assertAlmostEqual( mp.mpf( 1.854074677301), Kp)
def test_value4( self): k = np.sqrt( 0.90) m = mp.mfrom( k = k) K = mp.ellipk( m) Kp = mp.ellipk( 1 - m) self.assertAlmostEqual( 0.90, m) self.assertAlmostEqual( mp.mpf( 2.578092113348), K) self.assertAlmostEqual( mp.mpf( 1.612441348720), Kp)
def test_value5( self): k = np.sqrt( 0.99) m = mp.mfrom( k = k) K = mp.ellipk( m) Kp = mp.ellipk( 1 - m) self.assertEqual( 0.99, m) self.assertAlmostEqual( mp.mpf( 3.695637362989), K) self.assertAlmostEqual( mp.mpf( 1.574745561317), Kp)
def test_value0( self): k = np.sqrt( 0.00) m = mp.mfrom( k = k) K = mp.ellipk( m) Kp = mp.ellipk( 1 - m) self.assertAlmostEqual( 0.00, m) self.assertAlmostEqual( mp.mpf( 1.570796326794), K) self.assertEqual( mp.mpf( '+inf'), Kp)
def DOS(gamfactor, E): kred = redE(gamfactor, E) if abs(E) < 1 - gamfactor: return 1 / sqrt(gamfactor) * kred * (mpmath.ellipk(kred + 10**(-3) * 1j)).real elif abs(E) < 1 + gamfactor: return sqrt(gamfactor) * (mpmath.ellipk(kred + 10**(-3) * 1j)).real else: return 0
def band_stop_obj(wp, ind, passb, stopb, gpass, gstop, type): """ Band Stop Objective Function for order minimization. Returns the non-integer order for an analog band stop filter. Parameters ---------- wp : scalar Edge of passband `passb`. ind : int, {0, 1} Index specifying which `passb` edge to vary (0 or 1). passb : ndarray Two element sequence of fixed passband edges. stopb : ndarray Two element sequence of fixed stopband edges. gstop : float Amount of attenuation in stopband in dB. gpass : float Amount of ripple in the passband in dB. type : {'butter', 'cheby', 'ellip'} Type of filter. Returns ------- n : scalar Filter order (possibly non-integer). """ passbC = passb.copy() passbC[ind] = wp nat = (stopb * (passbC[0] - passbC[1]) / (stopb**2 - passbC[0] * passbC[1])) nat = min(abs(nat)) if type == 'butter': GSTOP = 10**(0.1 * abs(gstop)) GPASS = 10**(0.1 * abs(gpass)) n = (log10((GSTOP - 1.0) / (GPASS - 1.0)) / (2 * log10(nat))) elif type == 'cheby': GSTOP = 10**(0.1 * abs(gstop)) GPASS = 10**(0.1 * abs(gpass)) n = arccosh(sqrt((GSTOP - 1.0) / (GPASS - 1.0))) / arccosh(nat) elif type == 'ellip': GSTOP = 10**(0.1 * gstop) GPASS = 10**(0.1 * gpass) arg1 = sqrt((GPASS - 1.0) / (GSTOP - 1.0)) arg0 = 1.0 / nat d0 = ellipk([arg0**2, 1 - arg0**2]) d1 = ellipk([arg1**2, 1 - arg1**2]) n = (d0[0] * d1[1] / (d0[1] * d1[0])) else: raise ValueError("Incorrect type: %s" % type) return n
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
def Zolotarev2(p, q, m): """Another way to generate Zolotarev polynomial. It is not done yet.""" n = p + q u0 = (p / (p + q)) * ellipk(m) wp = 2 * (ellipfun('cd', u0, m)) ** 2 - 1 ws = 2 * (ellipfun('cn', u0, m)) ** 2 - 1 wq = (wp + ws) / 2 sn = ellipfun('sn', u0, m) cn = ellipfun('cn', u0, m) dn = ellipfun('dn', u0, m) wm = ws + 2 * z_zn(u0, m) * ((sn * cn) / (dn)) beta = np.zeros((n + 5, 1)) beta[n] = 1 d = np.zeros((6, 1)) # Implementation of the main recursive algorithm for m1 in range(n + 2, 2, -1): d[0] = (m1 + 2) * (m1 + 1) * wp * ws * wm d[1] = -(m1 + 1) * (m1 - 1) * wp * ws - (m1 + 1) * (2 * m1 + 1) * wm * wq d[2] = wm * (n ** 2 * wm ** 2 - m1 ** 2 * wp * ws) + m1 ** 2 * (wm - wq) + 3 * m1 * (m1 - 1) * wq d[3] = (m1 - 1) * (m1 - 2) * (wp * ws - wm * wq - 1) - 3 * wm * (n ** 2 * wm - (m1 - 1) ** 2 * wq) d[4] = (2 * m1 - 5) * (m1 - 2) * (wm - wq) + 3 * wm * (n ** 2 - (m1 - 2) ** 2) d[5] = n ** 2 - (m1 - 3) ** 2 tmp = 0 for mu in range(0, 5): tmp = tmp + d[mu] * beta[m1 + 3 - (mu + 1)] beta[m1 - 3] = tmp / d[5] tmp = 0 for m1 in range(0, n + 1): tmp = tmp + beta[m1] b = np.zeros((n + 1, 1)) for m1 in range(0, n + 1): b[m1] = (-1) ** p * (beta[m1] / tmp) return b
def z_eta(u, m): """Jacobi eta function (eq 16.31.3, [Abramowitz]_).""" q = qfrom(m=m) DM = ellipk(m) z = mp.pi * u / (2 * DM) eta = jtheta(n=1, z=z, q=q) return eta
def calc_lambda_0(chi, zp, zm, En, Lz, aa, slr, x): """ Mino time as a function of polar angle, chi Parameters: chi (float): polar angle zp (float): polar root zm (float): polar root En (float): energy Lz (float): angular momentum aa (float): spin slr (float): semi-latus rectum x (float): inclination Returns: lambda_0 (float) """ pi = mp.pi beta = aa * aa * (1 - En * En) k = sqrt(zm / zp) k2 = k * k prefactor = 1 / sqrt(beta * zp) ellipticK_k = ellipk(k2) ellipticF = ellipf(pi / 2 - chi, k2) return prefactor * (ellipticK_k - ellipticF)
def phi_inf(P, M): Qvar = Q(P, M) ksq = (Qvar - P + 6. * M) / (2. * Qvar) zinf = zeta_inf(P, M) phi = 2. * (mpmath.sqrt( P / Qvar)) * (mpmath.ellipk(ksq) - mpmath.ellipf(zinf, ksq)) return phi
def z_Zolotarev(N, x, m): r""" Function to evaluate the Zolotarev polynomial (eq 1, [McNamara93]_). :param N: Order of the Zolotarev polynomial :param x: The argument at which one would like to evaluate the Zolotarev polynomial :param m: m is the elliptic parameter (not the modulus k and not the nome q) :rtype: Returns a float, the value of Zolotarev polynomial at x """ M = -ellipk(m) / N x3 = ellipfun('sn', u=-M, m=m) xbar = x3 * mp.sqrt( (x**2 - 1) / (x**2 - x3**2)) # rearranged eq 21, [Levy70]_ u = ellipf(mp.asin(xbar), m) # rearranged eq 20, [Levy70]_, asn(x) = F(asin(x)|m) f = mp.cosh((N / 2) * mp.log(z_eta(M + u, m) / z_eta(M - u, m))) if f.imag / f.real > 1e-10: print("imaginary part of the Zolotarev function is not negligible!") print("f_imaginary = ", f.imag) else: if (x > 0): # no idea why I am doing this ... anyhow, it seems working f = -f.real else: f = f.real return f
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
def test_ellipk(self): assert_mpmath_equal(sc.ellipk, mpmath.ellipk, [Arg(b=1.0)]) assert_mpmath_equal(sc.ellipkm1, lambda m: mpmath.ellipk(1 - m), [Arg(a=0.0)], dps=400)
def testJacobiEllipticCn(self): """ Test some special cases of the cn(z, q) function. This is an intensive test, so precision turned down during development. """ mpmath.mpf.dps = 100 mpmath.mp.dps = 100 #mpmath.mpf.dps = 20 # testing version #mpmath.mp.dps = 20 testlimit = mpmath.mpf('10')**(-1*(mpmath.mpf.dps - 4)) #print >> sys.stderr, testlimit zero = mpmath.mpf('0') one = mpmath.mpf('1') # Abramowitz Table 16.5 # # cn(0, q) = 1 for i in range(10): qstring = str(random.random()) q = mpmath.mpf(qstring) cn = jacobi_elliptic_cn(zero, q) equality = one - cn if equality < testlimit: self.assertEquals(True, True) else: print >> sys.stderr, 'Cn (~ 1): %e' % cn print >> sys.stderr, 'Equality (~ zero): %e' % equality self.assertEquals(False, True) # Abramowitz Table 16.5 # # cn(K, q) = 0; K is K(k), first complete elliptic integral for i in range(10): mstring = str(random.random()) m = mpmath.mpf(mstring) k = m.sqrt() K = mpmath.ellipk(k**2) equality = jacobi_elliptic_cn(K, m) if equality < testlimit: self.assertEquals(True, True) else: print >> sys.stderr, '\n**** Cn failure ****' print >> sys.stderr, '\nK: %e' % K, print >> sys.stderr, '\tm: %f' % m, print >> sys.stderr, '\tcn: %e' % equality equality = jacobi_elliptic_cn(K, k, True) self.assertEquals(False, True)
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
def density_of_states_simple(s): density_of_states = 0 gamma = 1 if s > 1 and s < 3: density_of_states = (1 / math.pi)**2 * integrate.quad( lambda x: mpmath.ellipk( (k_simple(s, gamma, x)**2 - 1)**0.5 / k_simple(s, gamma, x)), 0, math.acos((s - 2) / gamma))[0] elif s > 0 and s < 1: density_of_states = (1 / math.pi)**2 * integrate.quad( lambda x: mpmath.ellipk( ((k_simple(s, gamma, x)**2 - 1)**0.5) / k_simple(s, gamma, x)), 0, math.pi, limit=10000, points=[math.acos(s / gamma)])[0] return density_of_states
def quartic_roots(k, x1, x2, x3): K = complex128(ellipk(k**2)) e0 = complex128((x1*j - x2)**2 + .25 * K**2) e1 = complex128(4*(x1*j-x2)*x3) e2 = complex128(4*(x3**2) - 2 * (x1**2) - 2 * (x2**2) + (K**2) * (k**2 - 0.5)) e3 = complex128(4*x3*(x2 + j*x1)) e4 = complex128(x2**2 - x1**2 + 2*j*x1*x2 + 0.25*K**2) return sort_complex(roots([e4, e3, e2, e1, e0])) # I put the sort_complex to have a canonical form, so that when we order them they will vary continuously
def is_awc_branch_point(k, x1, x2, x3): # This will test if we get a branch point as a roots; these are numerically unstable K = complex64(ellipk(k**2)) k1 = sqrt(1-k**2) tol = 0.001 if ( (abs(k1 * x1- k * x2) < tol) and x3==0): return True return False
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
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
def density_of_states_bcc(s): density_of_states = 0 if s <= 0 or s > 1: raise ValueError("s must be between 0 and 1.") else: density_of_states = 4 / (math.pi**2 * s) * integrate.quad( lambda x: 1 / k_bcc(s, x) * mpmath.ellipk( (k_bcc(s, x)**2 - 1)**0.5 / k_bcc(s, x)), 0, math.acos(s))[0] return density_of_states
def is_awc_multiple_root(k, x1, x2, x3): # This will test if there are multiple roots; the analytic derivation assumes they are distinct K = complex64(ellipk(k**2)) k1 = sqrt(1-k**2) tol = 0.001 if ( (abs(4 * x1**2 * k1**2 - k**2 *( K**2 *k1**2 + 4* x2**2)) < tol) and x3==0): return True elif ( (abs(4 * x1**2 * k1**2 - K**2 *k1**2 + 4* x3**2 )< tol) and x2==0): return True return False
def z_x123_frm_m(N, m): """Function to get x1, x2 and x3 (eq 3, 5 and 6, [McNamara93]_).""" M = -ellipk(m) / N snMM = ellipfun('sn', u= -M, m=m) snM = ellipfun('sn', u=M, m=m) cnM = ellipfun('cn', u=M, m=m) dnM = ellipfun('dn', u=M, m=m) znM = z_zn(M, m) x3 = snMM x1 = x3 * mp.sqrt(1 - m) / dnM x2 = x3 * mp.sqrt(1 - (cnM * znM) / (snM * dnM)) return x1, x2, x3
def z_x123_frm_m(N, m): """Function to get x1, x2 and x3 (eq 3, 5 and 6, [McNamara93]_).""" M = -ellipk(m) / N snMM = ellipfun('sn', u=-M, m=m) snM = ellipfun('sn', u=M, m=m) cnM = ellipfun('cn', u=M, m=m) dnM = ellipfun('dn', u=M, m=m) znM = z_zn(M, m) x3 = snMM x1 = x3 * mp.sqrt(1 - m) / dnM x2 = x3 * mp.sqrt(1 - (cnM * znM) / (snM * dnM)) return x1, x2, x3
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
def calc_rq(qr, r1, r2, r3, r4): """ function used in computing radial geodesic coordinates Parameters: qr (float) r1 (float): radial root r2 (float): radial root r3 (float): radial root r4 (float): radial root Returns: rq (float) """ pi = mp.pi kr = ((r1 - r2) * (r3 - r4)) / ((r1 - r3) * (r2 - r4)) sn = ellipfun("sn") return (-(r2 * (r1 - r3)) + (r1 - r2) * r3 * sn( (qr * ellipk(kr)) / pi, kr)**2) / (-r1 + r3 + (r1 - r2) * sn( (qr * ellipk(kr)) / pi, kr)**2)
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
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
def z_eta(u, m): r""" A function evaluate Jacobi eta function (eq 16.31.3, [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 eta function evaluated for the argument `u` and parameter `m` """ q = qfrom(m=m) DM = ellipk(m) z = mp.pi * u / (2 * DM) eta = jtheta(n=1, z=z, q=q) return eta
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
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
def is_awc_multiple_root( k, x1, x2, x3 ): # This will test if there are multiple roots; the analytic derivation assumes they are distinct K = complex64(ellipk(k**2)) k1 = sqrt(1 - k**2) tol = 0.001 if ((abs(4 * x1**2 * k1**2 - k**2 * (K**2 * k1**2 + 4 * x2**2)) < tol) and x3 == 0): return True elif ((abs(4 * x1**2 * k1**2 - K**2 * k1**2 + 4 * x3**2) < tol) and x2 == 0): return True return False
def elliptic_core_g(x,y): x = x/2 y = y/2 factor = (cos(x)/sin(y) + sin(y)/cos(x) - (cos(y)/tan(y)/cos(x) + sin(x)*tan(x)/sin(y)))/pi k = tan(x)/tan(y) m = k*k n = (sin(x)/sin(y))*(sin(x)/sin(y)) u = asin(tan(y)/tan(x)) complete = ellipk(m) - ellippi(n, m) incomplete = ellipf(u,m) - ellippi(n/k/k,1/m)/k #incomplete = ellipf(u,m) - ellippi(n,u,m) return re(1.0 - factor*(incomplete + complete))
def calc_dwtheta_dchi(chi, zp, zm): """ derivative of w_theta Parameters: chi (float): polar angle zp (float): polar root zm (float): polar root Returns: dw_dtheta (float) """ pi = mp.pi k = sqrt(zm / zp) ellipticK_k = ellipk(k**2) return pi / (2 * ellipticK_k) * (1 / (1 - k * k * cos(chi)**2))
def z_Zolotarev(N, x, m): """Function to evaluate the Zolotarev polynomial (eq 1, [McNamara93]_).""" M = -ellipk(m) / N x3 = ellipfun('sn', u= -M, m=m) xbar = x3 * mp.sqrt((x ** 2 - 1) / (x ** 2 - x3 ** 2)) # rearranged eq 21, [Levy70]_ u = ellipf(mp.asin(xbar), m) # rearranged eq 20, [Levy70]_, asn(x) = F(asin(x)|m) f = mp.cosh((N / 2) * mp.log(z_eta(M + u, m) / z_eta(M - u, m))) if (f.imag / f.real > 1e-10): print "imaginary part of the Zolotarev function is not negligible!" print "f_imaginary = ", f.imag else: if (x > 0): # no idea why I am doing this ... anyhow, it seems working f = -f.real else: f = f.real return f
def calc_psi_z(qz, zp, zm, En, aa): """ angle used in polar geodesic calculations Parameters: qz (float) zp (float): polar root zm (float): polar root En (float): energy aa (float): spin Returns: psi_z (float) """ ktheta = (aa**2 * (1 - En**2) * zm**2) / zp**2 return am((2 * (pi / 2.0 + qz) * ellipk(ktheta)) / pi, ktheta)
def Zolotarev2(p, q, m): r""" Another way to generate Zolotarev polynomial. It is not done yet. :param p: :param q: :param m: :rtype: Returns """ n = p + q u0 = (p / (p + q)) * ellipk(m) wp = 2 * (ellipfun('cd', u0, m))**2 - 1 ws = 2 * (ellipfun('cn', u0, m))**2 - 1 wq = (wp + ws) / 2 sn = ellipfun('sn', u0, m) cn = ellipfun('cn', u0, m) dn = ellipfun('dn', u0, m) wm = ws + 2 * z_zn(u0, m) * ((sn * cn) / (dn)) beta = np.zeros((n + 5, 1)) beta[n] = 1 d = np.zeros((6, 1)) # Implementation of the main recursive algorithm for m1 in range(n + 2, 2, -1): d[0] = (m1 + 2) * (m1 + 1) * wp * ws * wm d[1] = -(m1 + 1) * (m1 - 1) * wp * ws - (m1 + 1) * (2 * m1 + 1) * wm * wq d[2] = wm * (n**2 * wm**2 - m1**2 * wp * ws) + m1**2 * ( wm - wq) + 3 * m1 * (m1 - 1) * wq d[3] = (m1 - 1) * (m1 - 2) * (wp * ws - wm * wq - 1) - 3 * wm * (n**2 * wm - (m1 - 1)**2 * wq) d[4] = (2 * m1 - 5) * (m1 - 2) * (wm - wq) + 3 * wm * (n**2 - (m1 - 2)**2) d[5] = n**2 - (m1 - 3)**2 tmp = 0 for mu in range(0, 5): tmp = tmp + d[mu] * beta[m1 + 3 - (mu + 1)] beta[m1 - 3] = tmp / d[5] tmp = 0 for m1 in range(0, n + 1): tmp = tmp + beta[m1] b = np.zeros((n + 1, 1)) for m1 in range(0, n + 1): b[m1] = (-1)**p * (beta[m1] / tmp) return b
def calc_psi_r(qr, r1, r2, r3, r4): """ radial geodesic angle Parameters: qr (float) r1 (float): radial root r2 (float): radial root r3 (float): radial root r4 (float): radial root Returns: psi_r (float) """ pi = mp.pi kr = ((r1 - r2) * (r3 - r4)) / ((r1 - r3) * (r2 - r4)) return am((qr * ellipk(kr)) / pi, kr)
def calc_abel(k, zeta, eta): k1 = sqrt(1-k**2) a=k1+complex(0, 1)*k b=k1-complex(0, 1)*k abel_tmp = map(lambda zetai : \ complex(0, 1) * 1/(complex64(ellipk(k**2))*2*b) \ * complex64(ellipf( asin( (zetai )/a), mfrom(k=a/b))) \ - taufrom(k=k)/2, zeta) abel = [] for i in range(0, 4, 1): abel.append(abel_select(k, abel_tmp[i], eta[i])) return abel
def z_Zolotarev(N, x, m): """Function to evaluate the Zolotarev polynomial (eq 1, [McNamara93]_).""" M = -ellipk(m) / N x3 = ellipfun('sn', u=-M, m=m) xbar = x3 * mp.sqrt( (x**2 - 1) / (x**2 - x3**2)) # rearranged eq 21, [Levy70]_ u = ellipf(mp.asin(xbar), m) # rearranged eq 20, [Levy70]_, asn(x) = F(asin(x)|m) f = mp.cosh((N / 2) * mp.log(z_eta(M + u, m) / z_eta(M - u, m))) if (f.imag / f.real > 1e-10): print("imaginary part of the Zolotarev function is not negligible!") print("f_imaginary = ", f.imag) else: if (x > 0): # no idea why I am doing this ... anyhow, it seems working f = -f.real else: f = f.real return f
def calc_abel(k, zeta, eta): k1 = sqrt(1 - k**2) a = k1 + complex(0, 1) * k b = k1 - complex(0, 1) * k abel_tmp = map(lambda zetai : \ complex(0, 1) * 1/(complex64(ellipk(k**2))*2*b) \ * complex64(ellipf( asin( (zetai )/a), mfrom(k=a/b))) \ - taufrom(k=k)/2, zeta) abel = [] for i in range(0, 4, 1): abel.append(abel_select(k, abel_tmp[i], eta[i])) return abel
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
def z_x123_frm_m(N, m): r""" Function to get x1, x2 and x3 (eq 3, 5 and 6, [McNamara93]_). :param N: Order of the Zolotarev polynomial :param m: m is the elliptic parameter (not the modulus k and not the nome q) :rtype: Returns [x1,x2,x3] ... where x1, x2, and x3 are defined in Fig. 1, [McNamara93]_ """ M = -ellipk(m) / N snMM = ellipfun('sn', u=-M, m=m) snM = ellipfun('sn', u=M, m=m) cnM = ellipfun('cn', u=M, m=m) dnM = ellipfun('dn', u=M, m=m) znM = z_zn(M, m) x3 = snMM x1 = x3 * mp.sqrt(1 - m) / dnM x2 = x3 * mp.sqrt(1 - (cnM * znM) / (snM * dnM)) return x1, x2, x3
def z_x123_frm_m(N, m): r""" Function to get x1, x2 and x3 (eq 3, 5 and 6, [McNamara93]_). :param N: Order of the Zolotarev polynomial :param m: m is the elliptic parameter (not the modulus k and not the nome q) :rtype: Returns [x1,x2,x3] ... where x1, x2, and x3 are defined in Fig. 1, [McNamara93]_ """ M = -ellipk(m) / N snMM = ellipfun('sn', u= -M, m=m) snM = ellipfun('sn', u=M, m=m) cnM = ellipfun('cn', u=M, m=m) dnM = ellipfun('dn', u=M, m=m) znM = z_zn(M, m) x3 = snMM x1 = x3 * mp.sqrt(1 - m) / dnM x2 = x3 * mp.sqrt(1 - (cnM * znM) / (snM * dnM)) return x1, x2, x3
def test_on_line(k, x0, x1, y, z, partition_size): k1 = sqrt(1-k**2) a=k1+complex(0, 1)*k b=k1-complex(0, 1)*k x_step = (x1 - x0) / partition_size for i in range(0, partition_size): x=x0+i*x_step zeta = calc_zeta(k ,x, y, z) eta = calc_eta(k, x, y, z) abel = calc_abel(k, zeta, eta) mu = calc_mu(k, x, y, z, zeta, abel) print "zeta/a", zeta[0]/a, zeta[1]/a, zeta[2]/a, zeta[3]/a, '\n' print "eta", eta[0], eta[1], eta[2], eta[3], '\n' print "abel", abel[0], abel[1],abel[2],abel[3],'\n' abel_tmp= map(lambda zetai : \ complex(0, 1) * 1/(complex64(ellipk(k**2))*2*b) \ * complex64(ellipf( asin( (zetai )/a), mfrom(k=a/b))) \ - taufrom(k=k)/2, zeta) print "abel_tmp", abel_tmp[0], abel_tmp[1],abel_tmp[2],abel_tmp[3],'\n' print abel[0]+conj(abel[2]), abel[1]+conj(abel[3]), '\n' print - taufrom(k=k)/2, '\n' for l in range(0,4): tmp= abs(complex64(calc_eta_by_theta(k, abel[l])) - eta[l]) print tmp value = higgs_squared(k, x, y, z) print "higgs", higgs_squared(k,x,y,z) if (value > 1.0 or value <0.0): print "Exception" print '\n' # print mu[0]+mu[2], mu[1]+mu[3], '\n' return
def is_awc_multiple_root(k, x1, x2, x3): # This will test if there are multiple roots; the analytic derivation assumes they are distinct K = complex64(ellipk(k**2)) k1 = sqrt(1-k**2) tol1 = 0.007 tol2 = 0.026 # Two smoothings here. This one is the better if ( (abs(4 * x1**2 * k1**2 - k**2 *( K**2 *k1**2 + 4* x2**2)) < tol1) and abs(x3)<tol2): return True elif ( (abs(4 * x1**2 * k1**2 - K**2 *k1**2 + 4* x3**2 )< tol1) and abs(x2)<tol2): return True # Second smoothing # tol = 0.01 # # if ( (abs(4 * x1**2 * k1**2 - k**2 *( K**2 *k1**2 + 4* x2**2)) < tol) and x3==0): # return True # elif ( (abs(4 * x1**2 * k1**2 - K**2 *k1**2 + 4* x3**2 )< tol) and x2==0): # return True return False
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]))]])
def test_timing(k, x1, x2, x3): t0 = time.time() 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] t1 = time.time() K = complex64(ellipk(k**2)) xp = x[0]+complex(0,1)*x[1] xm = x[0]-complex(0,1)*x[1] DM = dmus(zeta, x, k) DZ = dzetas(zeta, x,k) DDM = ddmus(zeta, x, k) DDZ = ddzetas(zeta, x,k) t2 = time.time() A = ddphis111(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k) t3= time.time() B = ddphis222(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k) t4= time.time() C = ddgrams211(zeta, mu, DM, DZ, DDM, DDZ, [x1, x2, x3], k) t5= time.time() return A, B, C
def z_Zolotarev(N, x, m): r""" Function to evaluate the Zolotarev polynomial (eq 1, [McNamara93]_). :param N: Order of the Zolotarev polynomial :param x: The argument at which one would like to evaluate the Zolotarev polynomial :param m: m is the elliptic parameter (not the modulus k and not the nome q) :rtype: Returns a float, the value of Zolotarev polynomial at x """ M = -ellipk(m) / N x3 = ellipfun('sn', u= -M, m=m) xbar = x3 * mp.sqrt((x ** 2 - 1) / (x ** 2 - x3 ** 2)) # rearranged eq 21, [Levy70]_ u = ellipf(mp.asin(xbar), m) # rearranged eq 20, [Levy70]_, asn(x) = F(asin(x)|m) f = mp.cosh((N / 2) * mp.log(z_eta(M + u, m) / z_eta(M - u, m))) if (f.imag / f.real > 1e-10): print "imaginary part of the Zolotarev function is not negligible!" print "f_imaginary = ", f.imag else: if (x > 0): # no idea why I am doing this ... anyhow, it seems working f = -f.real else: f = f.real return f
def order_roots(roots, segment, sign, theta): """ Determine the roots along a trajectory segment. This is done by comparing the direction of the segment in the complex plane with that determined by the evolution equation using the roots in either order. The right one is chosen by similarity with the direction of the segment. e1 and e2 are the colliding roots, e3 is the far one, they are all expected to be evaluated at u1. """ e1_0, e2_0, e3_0 = roots u0, u1 = segment distances = map(abs, [e1_0 - e2_0, e2_0 - e3_0, e3_0 - e1_0]) # the pair e1, e2 pair = min(enumerate(distances), key=itemgetter(1))[0] if pair == 0: twins = [e1_0, e2_0] e3 = e3_0 elif pair == 1: twins = [e3_0, e2_0] e3 = e1_0 elif pair == 2: twins = [e3_0, e1_0] e3 = e2_0 if abs(twins[0] - twins[1]) / abs(twins[0] - e3) < 0.3: ### First possibility ### f1, f2 = twins eta_u1 = (sign) * 4.0 * ((e3 - f1) ** (-0.5)) * \ mp.ellipk( ((f2 - f1) / (e3 - f1)) ) phase_1 = phase( \ cmath.exp(1j * (theta + cmath.pi - phase(eta_u1))) / \ (u1 - u0) \ ) ### Second possibility ### f1, f2 = twins[::-1] eta_u1 = (sign) * 4.0 * ((e3 - f1) ** (-0.5)) * \ mp.ellipk( ((f2 - f1) / (e3 - f1)) ) phase_2 = phase( \ cmath.exp(1j * (theta + cmath.pi - phase(eta_u1))) / \ (u1 - u0) \ ) if abs(phase_1) > PRIMARY_BENDING_TOLERANCE and \ abs(phase_2) > PRIMARY_BENDING_TOLERANCE: # print "Exceeding primary bending tolerance" # print "phase_1=%s" % phase_1 # print "phase_2=%s" % phase_2 return 0 else: if abs(phase_1) < abs(phase_2): e1, e2 = twins else: e1, e2 = twins[::-1] eta_u1 = (sign) * 4.0 * ((e3 - e1) ** (-0.5)) * \ mp.ellipk( ((e2 - e1) / (e3 - e1)) ) return [[e1, e2, e3], complex(eta_u1)] else: return 0