I have written code for calculating cristofell symbol using for loop with 3 iterators for each coordinate
A = {
{1, 0, 0},
{0, r^2, 0},
{0, 0, 1}
} ;
Kor[n_] := \[Piecewise] {
{(r), n == 1},
{(\[Theta]), n == 2},
{(z), n == 3}
}
ChristoffelSymbol1[i_, j_, k_] :=
1/2 (-D[A[[i, j]], Korr[k]] + D[A[[j, k]], Korr[i]] +
D[A[[k, i]], Korr[j]])
For[i = 1, i < 4, i++,
For[j = 1, j < 4, j++,
For[k = 1, k < 4, k++,
Print[Subscript[\[CapitalGamma], i, j, k], " = ",
ChristoffelSymbol1[i, j, k]]
]
]
]
I was wandering if I could use Map
/Table
to do the same without changing the functions too much.
As far as I could tell I need to make the Piecewise
function return symbols for i, j, k
when they are entered instead of number so I dont get an error when I do
ChristoffelSymbol1[1,j,k]
and (this I don't know how) somehow define what happens when I try to access the matrix A
with A[[1,j]]
for example , so it doesn't give me "expression j cannot be used as a part specification"
and leave it in symbolic notation so it can be used when j
iterators start.
Print
like that you would useDo
. I dont see why you would have the part issue you are imagining -- try it. I wouldn't bother with thatPiecewise
by the way , just doKor[1]=r;Kor[2]=theta;Kor[3]=z
or doKor={r,theta,z}
and reference it as a list. $\endgroup$Tuples
and thenMap
function over the obtained list. However, it is unclear from your question what exactly you want to do? $\endgroup$