Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Jupyter notebook Ask+sage.ipynb

Project: test
Views: 141
Kernel: SageMath (latest)
%display latex
R7 = Manifold(7, 'R^7', r'\mathbb{R}^7', start_index=1); cart.<x_1,x_2,x_3,x_4,x_5,x_6,x_7> = R7.chart() ; cart
(R7,(x1,x2,x3,x4,x5,x6,x7))\renewcommand{\Bold}[1]{\mathbf{#1}}\left(\mathbb{R}^7,(x_{1}, x_{2}, x_{3}, x_{4}, x_{5}, x_{6}, x_{7})\right)
phi1=R7.diff_form(3,name='phi1',latex_name='\phi_1'); phi1[1,2,3],phi1[1,4,5],phi1[1,6,7],phi1[2,4,6],phi1[2,5,7],phi1[3,4,7],phi1[3,5,6]=1,1,1,1,-1,-1,-1; phi1.display()
ϕ1=dx1dx2dx3+dx1dx4dx5+dx1dx6dx7+dx2dx4dx6dx2dx5dx7dx3dx4dx7dx3dx5dx6\renewcommand{\Bold}[1]{\mathbf{#1}}\phi_1 = \mathrm{d} x_{1}\wedge \mathrm{d} x_{2}\wedge \mathrm{d} x_{3}+\mathrm{d} x_{1}\wedge \mathrm{d} x_{4}\wedge \mathrm{d} x_{5}+\mathrm{d} x_{1}\wedge \mathrm{d} x_{6}\wedge \mathrm{d} x_{7}+\mathrm{d} x_{2}\wedge \mathrm{d} x_{4}\wedge \mathrm{d} x_{6}-\mathrm{d} x_{2}\wedge \mathrm{d} x_{5}\wedge \mathrm{d} x_{7}-\mathrm{d} x_{3}\wedge \mathrm{d} x_{4}\wedge \mathrm{d} x_{7}-\mathrm{d} x_{3}\wedge \mathrm{d} x_{5}\wedge \mathrm{d} x_{6}
var('a1,a2,a3,a4,a5,a6,a7'); va = R7.tensor_field(1,0,name='va',latex_name='v_a'); va[1],va[2],va[3],va[4],va[5],va[6],va[7]=a1,a2,a3,a4,a5,a6,a7;
form=phi1 vec=va res=form['_ijk']*vec['^i'] res_coef=[] for ind in res.comp().non_redundant_index_generator(): if res[ind]!=0: res_coef.append(res[ind].expr()**2)
res_coef
[a32,a22,a52,a42,a72,a62,a12,a62,a72,a42,a52,a72,a62,a52,a42,a12,a22,a32,a32,a22,a12]\renewcommand{\Bold}[1]{\mathbf{#1}}\left[a_{3}^{2}, a_{2}^{2}, a_{5}^{2}, a_{4}^{2}, a_{7}^{2}, a_{6}^{2}, a_{1}^{2}, a_{6}^{2}, a_{7}^{2}, a_{4}^{2}, a_{5}^{2}, a_{7}^{2}, a_{6}^{2}, a_{5}^{2}, a_{4}^{2}, a_{1}^{2}, a_{2}^{2}, a_{3}^{2}, a_{3}^{2}, a_{2}^{2}, a_{1}^{2}\right]
set(res_coef)
set([a4^2,xa6^2,xa2^2,xa5^2,xa7^2,xa1^2,xa3^2])\renewcommand{\Bold}[1]{\mathbf{#1}}\verb|set([a4^2,|\phantom{\verb!x!}\verb|a6^2,|\phantom{\verb!x!}\verb|a2^2,|\phantom{\verb!x!}\verb|a5^2,|\phantom{\verb!x!}\verb|a7^2,|\phantom{\verb!x!}\verb|a1^2,|\phantom{\verb!x!}\verb|a3^2])|
uniq(res_coef)
[a42,a62,a22,a52,a72,a12,a32]\renewcommand{\Bold}[1]{\mathbf{#1}}\left[a_{4}^{2}, a_{6}^{2}, a_{2}^{2}, a_{5}^{2}, a_{7}^{2}, a_{1}^{2}, a_{3}^{2}\right]
v=[a1,a2,a1]
w=[i**2 for i in v]
w
[a12,a22,a12]\renewcommand{\Bold}[1]{\mathbf{#1}}\left[a_{1}^{2}, a_{2}^{2}, a_{1}^{2}\right]
uniq(w)
[a12,a22]\renewcommand{\Bold}[1]{\mathbf{#1}}\left[a_{1}^{2}, a_{2}^{2}\right]
list(set(w))
[a12,a22]\renewcommand{\Bold}[1]{\mathbf{#1}}\left[a_{1}^{2}, a_{2}^{2}\right]