# -*- coding: utf-8 -*-
"""
Created on Mon Mar 26 13:53:13 2018

@author: Taras
"""

def contraction(A,B):
    res = A[0,0]*B[0,0]
    for i in range(3):
        for j in range(3):
            if (i != 0 or j != 0):
                res += A[i,j]*B[j,i]
    return res

T = zeros(3)
for i in range(3):
    for j in range(i, 3):
        T[i,j] = Symbol(r't_{{{}{}}}'.format(i+1, j+1))
        T[j,i] = T[i,j]
        
S = zeros(3)
for i in range(3):
    for j in range(i, 3):
        S[i,j] = Symbol(r's_{{{}{}}}'.format(i+1, j+1))
        S[j,i] = S[i,j]

A = zeros(3)
A[0,0]=Symbol(r'a_{11}')
A[1,1]=Symbol(r'a_{22}')
A[2,2]=Symbol(r'a_{33}')

G = zeros(3)
G[0,0]=A[0,0]**2
G[1,1]=A[1,1]**2
G[2,2]=A[2,2]**2

A_inv = A**-1

T_new = A_inv*T*A_inv.T
S_new = A_inv*S*A_inv.T

e=contraction(G*T_new*G,S_new)

display(e)
@@ -78,16 +78,89 @@
 as%0A%22%22%22%0A%0A
+from sympy import *%0Afrom IPython.display import display%0Ainit_printing()%0A%0A
 def cont
@@ -335,16 +335,42 @@
 rn res%0A%0A
+%0Adef checkGeometry():%0A    
 T = zero
@@ -366,32 +366,36 @@
    T = zeros(3)%0A
+    
 for i in range(3
@@ -389,32 +389,36 @@
  i in range(3):%0A
+    
     for j in ran
@@ -419,32 +419,36 @@
 in range(i, 3):%0A
+    
         T%5Bi,j%5D =
@@ -495,16 +495,20 @@
         
+ 
+   
 T%5Bj,i%5D =
@@ -523,17 +523,25 @@
         
-%0A
+    %0A    
 S = zero
@@ -545,16 +545,20 @@
 eros(3)%0A
+    
 for i in
@@ -564,24 +564,28 @@
 n range(3):%0A
+    
     for j in
@@ -606,16 +606,20 @@
         
+    
 S%5Bi,j%5D =
@@ -666,16 +666,20 @@
         
+    
 S%5Bj,i%5D =
@@ -686,17 +686,25 @@
  S%5Bi,j%5D%0A
-%0A
+    %0A    
 A = zero
@@ -708,16 +708,20 @@
 eros(3)%0A
+    
 A%5B0,0%5D=S
@@ -737,16 +737,20 @@
 _%7B11%7D')%0A
+    
 A%5B1,1%5D=S
@@ -766,16 +766,20 @@
 _%7B22%7D')%0A
+    
 A%5B2,2%5D=S
@@ -795,17 +795,25 @@
 _%7B33%7D')%0A
-%0A
+    %0A    
 G = zero
@@ -817,16 +817,20 @@
 eros(3)%0A
+    
 G%5B0,0%5D=A
@@ -838,16 +838,20 @@
 0,0%5D**2%0A
+    
 G%5B1,1%5D=A
@@ -859,16 +859,20 @@
 1,1%5D**2%0A
+    
 G%5B2,2%5D=A
@@ -880,17 +880,25 @@
 2,2%5D**2%0A
-%0A
+    %0A    
 A_inv = 
@@ -903,17 +903,25 @@
 = A**-1%0A
-%0A
+    %0A    
 T_new = 
@@ -936,16 +936,20 @@
 A_inv.T%0A
+    
 S_new = 
@@ -964,17 +964,25 @@
 A_inv.T%0A
-%0A
+    %0A    
 e=contra
@@ -1004,17 +1004,25 @@
 ,S_new)%0A
-%0A
+    %0A    
 display(
@@ -1023,8 +1023,171 @@
 splay(e)
+%0A    %0A    %0Adef missedJ():%0A    alpha3, K, h = symbols(%22alpha_3, K, h%22)%0A    res = integrate(1/(1+K*alpha3), (alpha3, -h/2, h/2))%0A    display(res)%0A    %0A    %0AmissedJ()

integrate missed Jacobian