# xAct working with an unspecified function

I am trying to use xCoba with a diagonal metric depending on an unspecified function f[r], but I get the errors:

CTensor::unknown: Unknown expression f[r].

CTensor::unknown: Unknown expression f[r].

ManifoldOfChart::unknown: "Unknown !(\"chart\")Null.

" Throw::nocatch: "Uncaught Throw[Null] returned to top level."

This is my workflow:

<< xActxCore
<< xActxTensor
<< xActxCoba
DefManifold[M4, 4, {a, b, c, d, e, f, i, l}]
DefBasis[red, TangentM4, {0, 1, 2, 3}, BasisColor -> Red]
DefChart[ch, M4, {0, 1, 2, 3}, {t[], r[], \[Theta][], \[Phi][]}, ChartColor -> Brown]
met = CTensor[
DiagonalMatrix[{-f[r[]], 1/f[r[]], r[]^2, r[]^2*Sin[\[Theta]]^2}], {-ch, -ch}]
SetCMetric[met, ch, SignatureOfMetric -> {3, 1, 0}]


How can I work with an unspecified function? Is it even possible?

In case someone needs it in the future I answer my question.

To work with a non defined function f one has to include the line:

DefScalarFunction[f]


If, like in my case, the function depends only on r, one has to write f[r[]] in the rest of the program

• Indeed. In xAct you need to declare all relevant objects, so that the system knows the tensorial properties of everything. In this case you need to declare f as a scalar function, meaning that it is a scalar and that its arguments must also be all scalars. Then r is the name of the scalar field r[], in the same way that T is the name of the tensor field T[i, -j], say. Both need the brackets to be recognized by xAct as tensorial quantities. – jose Feb 21 at 6:38