import sympy
import numpy as np
from sympy.utilities.lambdify import implemented_function
x = sympy.MatrixSymbol('x', 3, 1)
f = implemented_function(sympy.Function('f'), lambda x: x.T * x)
Converting expression involving tranpose of vector to numerical function with lambdify