I want to plot the following quadratic form:
f(x) = 1/2 x^T * A * x -b^T *x
where A is a 2x2 matrix. x1-axis: [-6,4] x2-axis: [-4,6]
I did the following:
x = arange(-6,4,0.1)
y = arange(-4,6,0.1)
So both x and y conatain 100 points. Now I want to evaluate the quadratic form at all those pairs of points, i.e. I get 100*100 = 10000 points.
Done by the following code:
res= []
for a in x:
for b in y:
val = f(array([a,b]))
res.append(val)
Now I want to make a kind of surface plot. Can anyone help me figure out how to do this? I tried:
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
surf = ax.plot_surface(x, y, res)
I think the following method should be help but I really do not know how exactly:
griddata- Interpolates from a nonuniformly spaced grid to some other grid.
any ideas?