title: Sympy diffgeom: Metric dependent on function
body: <p>I'm having problems defining a metric using sympy's diffgeom package, where the metric depends on a function <code>f(x,y)</code>.</p>
  
  <p>I get the error <code>ValueError: Can't calculate 1st derivative wrt x.</code> </p>
  
  <pre><code>import sympy as sym
  from sympy.diffgeom import Manifold, Patch, CoordSystem
  
  m = Manifold("M",2)
  patch = Patch("P",m)
  cartesian = CoordSystem("cartesian", patch, ["x", "y"])
  x, y = cartesian.coord_functions()
  f = sym.Function('f')
  xi = sym.Symbol('xi')
  
  g = sym.Matrix([
      [ xi + sym.diff(f,x)**2         , sym.diff(f,x) * sym.diff(f,y) ],
      [ sym.diff(f,x) * sym.diff(f,y) , xi + sym.diff(f,y)**2 ]   
  ])
  </code></pre>
  
  <p>I have a feeling it's because of how <code>x</code> and <code>y</code> are defined, but I haven't been able to figure it out.</p>