# Essays/Torsion Tensor/TorsionTensor01

```NB. ... script torsiontensor.ijs ...

mXsign  =:*/~@({.@\$\$1,_1:)
mXdet   =:-/ . *
mXminors=:1&(|:\.)"2^:2

mXsign1=:(  0|:])@:((mXsign*])"2)@(0 1|:])"3
mXsign2=:(0 1|:])@:((mXsign*])"2)@(0 1|:])"4

L2hdx  =:(  0|:])@(mXminors^:2)@(0 1|:])"3@hcvdx
L3hdx  =:(  0|:])@(mXminors^:1)@(0 1|:])"3@hcvdx
L3hdxdx=:(0 1|:])@(mXminors^:1)@(0 1|:])"4@hcvdxdx

L2H=:(mXsign*])"2@:mXdet@(mXminors^:3)@hcv
L3H=:(mXsign*])"2@:mXdet@(mXminors^:2)@hcv
L4H=:(mXsign*])"2@:mXdet@(mXminors^:1)@hcv
hdet=:              mXdet@(mXminors^:0)@hcv

L3Hdx    =:L2hdx   mXsign1@:(+/"1@((<0 2)|:])@((1|:[)smx    ])"3 2)L2H
L4Hdx    =:L3hdx   mXsign1@:(+/"1@((<0 2)|:])@((1|:[)smx    ])"3 2)L3H
hdetdx    =:hcvdx             +/"1@((<0 2)|:])@((1|:[)smx    ])"3 2 L4H

L4Hdxdxt1=:L3hdx   mXsign2@:(+/"1@((<0 2)|:])@((1|:[)smx 1|:])"3 3)L3Hdx
hdetdxdxt1=:hcvdx             +/"1@((<0 2)|:])@((1|:[)smx 1|:])"3 3 L4Hdx

L4Hdxdxt2=:L3hdxdx mXsign2@:(+/"1@((<0 3)|:])@((1|:[)smx    ])"4 2)L3H
hdetdxdxt2=:hcvdxdx           +/"1@((<0 3)|:])@((1|:[)smx    ])"4 2 L4H

L4Hdxdx=: L4Hdxdxt1+ L4Hdxdxt2
hdetdxdx=:hdetdxdxt1+hdetdxdxt2
```

```NB. ... execute (ijx) ...

gXcme =:( 1.50  1.45  1.51 )"_
gXpAll=:( 0     0     0    )"_
gXqAll=:( 0     0     0    )"_
gXwAll=:( 0     _     _    )"_

yCpts=:3.5 10 28,(0.1,(1p1-0.1),28),0 2p1 44,:0 6 20"_

*./^:4"4 (gXT(([L3Hdx    hkAy)(((2^_14);2^_18)qteq[;])"1(0|:[:(gXT([L3H    hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

*./^:2"2 (gXT(([L4Hdx    hkAy)(((2^_12);2^_19)qteq[;])"1(0|:[:(gXT([L4H    hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

*./^:2"2 (gXT(([L4Hdxdx  hkAy)(((2^_13);2^_18)qteq[;])"2(0|:[:(gXT([L4Hdx  hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

*./^:0"0 (gXT(([hdetdx   hkAy)(((2^_12);2^_19)qteq[;])"1(0|:[:(gXT([hdet   hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

*./^:0"0 (gXT(([hdetdxdx hkAy)(((2^_12);2^_18)qteq[;])"2(0|:[:(gXT([hdetdx hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
```

```NB. ... script torsiontensor.ijs ...

hdetm1=:hdet^_1:

hdetm1dx=:-@(hdet^_2:)*"0 1 hdetdx

hdetm1dxdxt1=:-@(hdet^_2:)*"0 2 hdetdxdx
hdetm1dxdxt2=:2*(hdet^_3:)*"0 2 hdetdx*/"1 hdetdx
hdetm1dxdx  =:hdetm1dxdxt1+hdetm1dxdxt2
```

```NB. ... execute (ijx) ...

gXcme =:( 1.50  1.45  1.51 )"_
gXpAll=:( 0     0     0    )"_
gXqAll=:( 0     0     0    )"_
gXwAll=:( 0     _     _    )"_

yCpts=:3.5 10 28,(0.1,(1p1-0.1),28),0 2p1 44,:0 6 20"_

(gXT(([hdetm1dx   hkAy)(((2^_32);2^_17)qteq[;])"1(0|:[:(gXT([hdetm1   hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

(gXT(([hdetm1dxdx hkAy)(((2^_32);2^_17)qteq[;])"2(0|:[:(gXT([hdetm1dx hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
```

```NB. ... script torsiontensor.ijs ...

hcn=:hdetm1*"0 2 L4H

hcndxt1=:hdetm1         (* )"0 3 L4Hdx
hcndxt2=:hdetm1dx(0|:])@(*/)"1 2 L4H
hcndx  =:hcndxt1+hcndxt2

hcndxdxt1=:hdetm1             (* )"0 4 L4Hdxdx
hcndxdxt2=:hdetm1dx  (  0|:])@(*/)"1 3 L4Hdx
hcndxdxt3=:hdetm1dx  (0 3|:])@(*/)"1 3 L4Hdx
hcndxdxt4=:hdetm1dxdx(0 1|:])@(*/)"2 2 L4H
hcndxdx  =:hcndxdxt1+hcndxdxt2+hcndxdxt3+hcndxdxt4
```

```NB. ... execute (ijx) ...

gXcme =:( 1.50  1.45  1.51 )"_
gXpAll=:( 0     0     0    )"_
gXqAll=:( 0     0     0    )"_
gXwAll=:( 0     _     _    )"_

yCpts=:3.5 10 28,(0.1,(1p1-0.1),28),0 2p1 44,:0 6 20"_

(gXT(([hcndx   hkAy)(((2^_25);2^_17)qteq[;])"3(0|:[:(gXT([hcn   hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

(gXT(([hcndxdx hkAy)(((2^_20);2^_17)qteq[;])"4(0|:[:(gXT([hcndx hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
```

```NB. ... script torsiontensor.ijs ...

ch1k    =:0.5*((    1|:])+(    0 1|:])-])"3@hcvdx
ch1kdx  =:0.5*((  1 3|:])+(  0 1 3|:])-])"4@hcvdxdx
ch1kdxdx=:0.5*((1 3 4|:])+(0 1 3 4|:])-])"5@hcvdxdxdx
```

```NB. ... execute (ijx) ...

gXcme =:( 1.50  1.45  1.51 )"_
gXpAll=:( 0     0     0    )"_
gXqAll=:( 0     0     0    )"_
gXwAll=:( 0     _     _    )"_

yCpts=:3.5 10 28,(0.1,(1p1-0.1),28),0 2p1 44,:0 6 20"_

(gXT(([ch1kdx   hkAy)(((2^_20);2^_18)qteq[;])"4(0|:[:(gXT([ch1k   hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

(gXT(([ch1kdxdx hkAy)(((2^_17);2^_18)qteq[;])"5(0|:[:(gXT([ch1kdx hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
```

```NB. ... script torsiontensor.ijs ...

ch2k=:hcn(0|:])@smx"2 3 ch1k

ch2kdxt1=:hcn  (0 3|:])@((   [)smx 2|:])"2 4 ch1kdx
ch2kdxt2=:hcndx(0 1|:])@((1|:[)smx    ])"3 3 ch1k
ch2kdx  =:ch2kdxt1+ch2kdxt2

ch2kdxdxt1=:hcn    (0 3 4|:])@((   [)smx 2|:])"2 5 ch1kdxdx
ch2kdxdxt2=:hcndx  (0 4 1|:])@((1|:[)smx 2|:])"3 4 ch1kdx
ch2kdxdxt3=:hcndx  (0 1 4|:])@((1|:[)smx 2|:])"3 4 ch1kdx
ch2kdxdxt4=:hcndxdx(0 1 2|:])@((1|:[)smx    ])"4 3 ch1k
ch2kdxdx  =:ch2kdxdxt1+ch2kdxdxt2+ch2kdxdxt3+ch2kdxdxt4
```

```NB. ... execute (ijx) ...

gXcme =:( 1.50  1.45  1.51 )"_
gXpAll=:( 0     0     0    )"_
gXqAll=:( 0     0     0    )"_
gXwAll=:( 0     _     _    )"_

yCpts=:3.5 10 28,(0.1,(1p1-0.1),28),0 2p1 44,:0 6 20"_

(gXT(([ch2kdx   hkAy)(((2^_21);2^_16)qteq[;])"4(0|:[:(gXT([ch2k   hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

(gXT(([ch2kdxdx hkAy)(((2^_17);2^_17)qteq[;])"5(0|:[:(gXT([ch2kdx hkAy)])D.1])"_ 1)]) (50 yCrandom yCpts)''
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
```