def compute_2nd_order_finite_difference_coefficients(x):
    """Compute 2nd-order finite difference coefficients for a centered,
    three-node stencil. 

    Parameters
    ----------
    x : ndarray
        1-D vector of node positions for which to compute the finite
        difference approximations.

    Returns
    -------
    am, a0, ap : ndarray
        Three 1-D vectors containing the coefficients to compute the
        finite difference approximate 2nd order derivative at the N-2
        inner nodes of x.

    Notes
    -----
    len(am) == len(a0) == len(ap) == len(x) - 2

    Example
    -------
    # Get the finite difference approximate second derivative of sin(x)
    x = np.linspace(0., 1.)
    am, a0, ap = compute_2nd_order_finite_difference_coefficients(x)
    y = np.sin(x)
    result = am * y[:-2] + a0 * y[1:-1] + ap * y[2:]
    
    """
    h = x[1:] - x[:-1]
    hm = h[:-1]
    hp = h[1:]
    am = 2./(hm*hp + hm*hm)
    a0 = -2./(hm*hp)
    ap = 2./(hm*hp + hp*hp)

    return am, a0, ap