In [2]:
%matplotlib inline
from sympy import *
init_printing(use_unicode=True)
In [3]:
r, u, v, c, r_c, u_c, v_c, E, p, r_p, u_p, v_p, e, a, b, q, b_0, b_1, b_2, b_3, q_0, q_1, q_2, q_3, q_4, q_5 = symbols('r u v c r_c u_c v_c E p r_p u_p v_p e a b q b_0 b_1 b_2 b_3 q_0 q_1 q_2 q_3 q_4 q_5')
In [4]:
gamma = symbols('gamma',positive=True)
In [6]:
f = ((1/2)*r_c*c**2+(1/4)*u_c*c**4+(1/6)*v_c*c**6+(1/2)*p**2
+(1/4)*p**4+(1/6)*v_p*p**6-E*p-gamma*c*p-c**2*p**2/2)
nsimplify(f)
Out[6]:
In [7]:
E_c = solve(f.diff(p),E)[0]
E_c
Out[7]:
In [8]:
p_min = nsimplify(solve(f.diff(c),p)[0])
p_min
Out[8]:
In [9]:
E_c = nsimplify(E_c.subs(p,p_min))
E_c
Out[9]:
In [10]:
series(E_c,c,n=7)
Out[10]:
In [9]:
Etrun = a*c+b*c**3+q*c**5
In [10]:
solve(Etrun.diff(c),c)
Out[10]:
In [11]:
c_L = solve(Etrun.diff(c),c)[1]
c_U = solve(Etrun.diff(c),c)[3]
c_L,c_U
Out[11]:
In [12]:
E_L = simplify(Etrun.subs(c,c_U))
E_U = simplify(Etrun.subs(c,c_L))
In [13]:
E_L,E_U
Out[13]:
In [13]:
rc = (gamma**2+a*gamma)
B = (-r_c/gamma+u_c/gamma+(r_c/gamma)**3-r_c**2/gamma**3)
Q = (-u_c/gamma+v_c/gamma+3*u_c*r_c**2/gamma**3+r_c**2/gamma**3
-2*r_c*u_c/gamma**3+v_p*(r_c/gamma)**5-3*r_c**4/gamma**5+2*r_c**3/gamma**5)
In [19]:
collect(expand(B.subs(r_c,rc)),a)
Out[19]:
In [20]:
collect(expand(Q.subs(r_c,rc)),a)
Out[20]:
In [18]:
b0 = gamma**3-2*gamma+u_c/gamma
b1 = 3*gamma**2-3
b2 = 3*gamma-1/gamma
b3 = 1
q0 = gamma**5*v_p-3*gamma**3+3*gamma*u_c+3*gamma-3*u_c/gamma+v_c/gamma
q1 = 5*gamma**4*v_p-12*gamma**2+6*u_c+8-2*u_c/gamma**2
q2 = 10*v_p*gamma**3-18*gamma+(7+3*u_c)/gamma
q3 = 10*v_p*gamma**2-12+2/gamma**2
q4 = 5*v_p*gamma-3/gamma
q5 = v_p
In [12]:
uc = solve(b0-b_0,u_c)[0]
up = solve(b3-b_3,u_p)[0]
vc = solve(q0-q_0,v_c)[0]
vp = solve(q5-q_5,v_p)[0]
In [13]:
replacements = [(v_p,vp),(u_p,up),(u_c,uc)]
In [16]:
vc = simplify(vc.subs([i for i in replacements]))
In [17]:
expand(vc)
Out[17]:
In [18]:
uc = simplify(uc.subs([i for i in replacements]))
In [19]:
expand(uc)
Out[19]:
In [20]:
up
Out[20]:
In [21]:
vp
Out[21]:
In [22]:
b0
Out[22]:
In [23]:
b1 = simplify(b1.subs(u_p,up))
In [24]:
b1
Out[24]:
In [25]:
b2 = simplify(b2.subs(u_p,up))
In [26]:
b2
Out[26]:
In [27]:
b3
Out[27]:
In [28]:
B_a = b_0+b1*a+b2*a**2+b_3*a**3
In [29]:
B_a
Out[29]:
In [30]:
q0
Out[30]:
In [33]:
q1 = simplify(q1.subs([i for i in replacements]))
In [34]:
q1
Out[34]:
In [37]:
q2 = q2.subs([i for i in replacements])
In [38]:
expand(q2)
Out[38]:
In [39]:
q3 = simplify(q3.subs([i for i in replacements]))
In [40]:
q3
Out[40]:
In [41]:
q4 = simplify(q4.subs([i for i in replacements]))
In [42]:
q4
Out[42]:
In [43]:
Q_a = q_0+q1*a+q2*a**2+q3*a**3+q4*a**4+q_5*a**5
In [44]:
collect(expand(Q_a),a)
Out[44]:
In [45]:
series(B_a**2-(20*a*Q_a/9),a,n=7)
Out[45]:
In [ ]: