Question: something wrong with a function in a procedure


I have a difficulty with a function used in procedure. The procedure uses a multivariable function and if the specific choice of the function is not made the procedure seems to give proper result, but In case I make a specific choice of the function and then try use this procedure gives me incorrect result.

To be more exact I use Physics package (there is a need to calcute combinations of covariant derivates ). The calculations are performed in a curved space with a defined metric.

So here is the procedure:

SD2 := proc (psi) SumOverRepeatedIndices(g_[`~kappa`, `~lambda`]*(d_[kappa](d_[lambda](psi(X)))-Christoffel[`~sigma`, kappa, lambda]*d_[sigma](psi(X))))^2-SumOverRepeatedIndices(g_[`~kappa`, `~rho`]*(d_[kappa](d_[lambda](psi(X)))-Christoffel[`~sigma`, kappa, lambda]*d_[sigma](psi(X)))*g_[`~lambda`, `~tau`]*(d_[rho](d_[tau](psi(X)))-Christoffel[`~gamma`, rho, tau]*d_[gamma](psi(X)))) end proc;

If I turn to the procedure :


the result is  correct.

But  then I specify a psi function:

psi:=(t,r,x,y,z)->chi(r)+q*t;(here q is supposed to be a constant)

and turn to the procedure once again:


It gives me a wrong result.

I don't know what is the reason.

Thank you.



Please Wait...