Python solving 2nd order ODE with quad function
Question: I am studying the dynamics of a damped, driven pendulum with second order ODE
defined like
[so](http://www.cmp.caltech.edu/~mcc/Chaos_Course/Lesson2/Demos.html), and
specifically I am progamming:

d^2y/dt^2 + c * dy/dt + sin(y) = a * cos(wt)

    
    
    import numpy as np
    import matplotlib.pyplot as plt
    from scipy import integrate
    
    
    def pendeq(t,y,a,c,w):
        y0 = -c*y[1] - np.sin(y[0]) + a*np.cos(w*t)
        y1 = y[1]
        z = np.array([y0, y1])
        return z
    
    a = 2.1
    c = 1e-4
    w = 0.666667     # driving angular frequency
    
    t = np.array([0, 5000])   # interval of integration
    y = np.array([0, 0])      # initial conditions
    
    yp = integrate.quad(pendeq, t[0], t[1], args=(y,a,c,w))
    

This problem does look quite similar to [Need help solving a second order non-
linear ODE in python](http://stackoverflow.com/questions/19779217/need-help-
solving-a-second-order-non-linear-ode-in-python), but I am getting the error

    
    
    Supplied function does not return a valid float.
    

What am I doing wrong??


Answer: `integrate.quad` requires that the function supplied (`pendeq`, in your case)
**returns only a float**. Your function is returning an array.

