-
Notifications
You must be signed in to change notification settings - Fork 1
/
a.py
131 lines (56 loc) · 1.4 KB
/
a.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# coding: utf-8
# In[7]:
# import sympy as sy
from sympy import Symbol, Eq, Rational, sqrt, solve
from sympy.abc import a, b, c, d, m, x, y, alpha, beta, gamma, kappa
from IPython.display import display, Latex
from util import *
from transform import *
f_ = xg**3+a*xg+m+gamma
f = f_.subs(xg, x-gamma)
ff = f_.subs(xg, f_-gamma).expand().subs(xg,x)
p = ff.as_poly(x)
p
# In[34]:
q.subs(a,2*m).factor()
# In[37]:
ff.subs(a,2*m).simplify()
# In[38]:
def delta(var):
return sqrt(-3*var**2-4*a)
# In[42]:
def r_p(var):
return (-var+delta(var))/2
def r_m(var):
return (-var-delta(var))/2
# In[46]:
for subscript in range(10):
globals()['b{}'.format(subscript)] = Symbol('beta{}'.format(subscript))
# In[64]:
fact1=(x-r_p(b1))*(x-r_p(b2))*(x-r_p(b3))
fact2=(x-r_m(b1))*(x-r_m(b2))*(x-r_m(b3))
# In[68]:
(fact1.expand()-fact2.expand()).as_poly(x)
# In[69]:
(fact1.expand()-fact2.expand()).as_poly(x).coeffs()
# In[74]:
(fact1.expand()+fact2.expand()).as_poly(x).coeffs()
# In[76]:
fact3=(x-r_m(b1))*(x-r_p(b2))*(x-r_p(b3))
fact4=(x-r_p(b1))*(x-r_m(b2))*(x-r_m(b3))
(fact3+fact4).expand().as_poly(x).coeffs()
# In[77]:
(fact3-fact4).expand().as_poly(x).coeffs()
# In[84]:
c1=fact1.expand().as_poly(x).coeffs()[-1]
c2=fact2.expand().as_poly(x).coeffs()[-1]
# In[85]:
c1
# In[86]:
c2
# In[88]:
c1+c2
# In[1]:
from mpmath import *
# In[8]:
polar(4*x)