What is a good way to produce a numpy array containing the values of a function evaluated on an n-dimensional grid of points?
For example, suppose I want to evaluate
My two cents:
import numpy as np x = np.linspace(0, 4, 10) y = np.linspace(-1, 1, 20) [X, Y] = np.meshgrid(x, y, indexing = 'ij', sparse = 'true') def func(x, y): return x*y/(x**2 + y**2 + 4) # I have defined a function of x and y. func(X, Y)