0

I'm trying to automatically generate the Christoffel Symbol in Mathematica. I'm starting with the formulas:

X[r_, theta_] := r*Cos[theta]; 
Y[r_, theta_] := r*Sin[theta]; 
R[x_, y_] := Sqrt[x^2 + y^2]; 
Theta[x_, y_] := ArcTan[x, y];

Now, without trying to analyze the equations, I'm trying to implement this in Mathematica. So far I have:

D[D[X[r, theta], r], r]*D[R[x, y], x] + D[D[Y[r, theta], r], r]*D[R[x, y], y]
D[D[X[r, theta], r], theta]*D[R[x, y], x] + D[D[Y[r, theta], r], theta]*D[R[x, y], y]

Which results in this:

0
(y Cos[theta])/Sqrt[x^2 + y^2] - (x Sin[theta])/Sqrt[x^2 + y^2]

Now I know that I can reduce the second result using the fact that $y=r\space Sin[theta]$ and $x=r\space Cos[theta]$ and $r=\sqrt{x^2+y^2}$, but I want Mathematica to make the reduction for me. How do I go about telling Mathematica to reduce this equation (hint: the result should be 0)?

Quark Soup
  • 1,610
  • 9
  • 14
  • You can just substitute for x and y: expr /. {y -> Y[r, theta], x -> X[r, theta]}. – Alx Dec 20 '19 at 23:55

1 Answers1

1

Post my comment as answer.

X[r_, theta_] := r*Cos[theta]; 
Y[r_, theta_] := r*Sin[theta]; 
R[x_, y_] := Sqrt[x^2 + y^2]; 
Theta[x_, y_] := ArcTan[x, y];

r1 = D[D[X[r, theta], r], r]*D[R[x, y], x] + D[D[Y[r, theta], r], r]*D[R[x, y], y]
r2 = D[D[X[r, theta], r], theta]*D[R[x, y], x] + D[D[Y[r, theta], r], theta]*D[R[x, y], y]
0
(y Cos[theta])/Sqrt[x^2 + y^2] - (x Sin[theta])/Sqrt[x^2 + y^2]

To simplify last output we can just make substitution for x and y:

r2 /. {y -> Y[r, theta], x -> X[r, theta]}

0

Alx
  • 3,632
  • 11
  • 15