I'm looking for an efficient method to create two NumPy arrays; the first is a series of evenly spaced numbers and the second is the result of passing the first array data through a maths function.

The NumPy arrays will then be plotted, one as x and the other as y. I'm plotting the damped harmonic oscillations of a spring, which is given as a function of x (x is time on the plot). The function is an exponentially degrading sine wave, where y on the plot is the displacement from zero:

f(x) = e^(-L . x) . a . cos(w . x)

where `L`, `a` and `w` are all constants (given by the user) and `e` is exponential. I'm currently doing it as following where `SAMPLE_TIME` and `SAMPLE_RATE` are module variables set elsewhere. I'd prefer not to iterate over the y array and was looking for a way to do it in one go.

```
# numpy arrays for x and y coords
x = np.arange(0, SAMPLE_TIME, SAMPLE_RATE)
y = np.arange(0, SAMPLE_TIME, SAMPLE_RATE)

# iterate over y array
with np.nditer(y, op_flags=['readwrite']) as arr:
    for el in arr:
        # under-damped harmonic oscillator equation
        el[...] = deflection * math.exp(-el*damping_coefficent) * math.cos(w * el)

```