code: def laplace(f, g_inv, g_det, X):
      """
      Calculates Laplace(f), using the inverse metric g_inv, the determinant of
      the metric g_det, all in variables X.
      """
      r = 0
      for i in range(len(X)):
          for j in range(len(X)):
              r += g_inv[i, j] * f.diff(X[i]).diff(X[j])
      for sigma in range(len(X)):
          for alpha in range(len(X)):
              r += (
                  g_det.diff(X[sigma])
                  * g_inv[sigma, alpha]
                  * f.diff(X[alpha])
                  / (2 * g_det)
              )
      return r
  
imports: from sympy import var, sin, cos, pprint, Matrix, eye, trigsimp, Eq, Function, simplify, sinh, cosh, expand, symbols
label_desc: Use image node_id 1 for calling a global function with example usage: laplace(f, g_inv, g_det, X) and returns: r