# How to make a symbolic function of a matrix ?

Hi,

I'm beginning with Sage. I've got two matrix Qf and Xf defined by :

```
Qf = 1000000*matrix([[0,0],[0,1]]);
Xf = matrix([1],[1675]);
```

I would like to write a symbolic function "f" which would take a matrix X with 2 rows & 1 column.

```
X = var('X');
f(X) = ((X-Xf).transpose()*Qf*(X-Xf));
```

I easily wrote it with python non-symbolic function syntax, but i didn't find a way to make it symbolic. Because I'll need his gradient later (which is easy to calculate by hand, that I conceed ^^).

Maybe, it's related with SR matrix, no idea, i'm beginning with Sage and that's why I'm asking for help x)

Thank you in advance.