def linearization(X, Jfun, P):
    """Transform a covariance matrix via linearization

    Arguments:
        X: the point to linearize about, (n,) numpy array
        Jfun: function which takes the state and returns the (n x n) Jacobian of
            the function, f, which we want to transform the covariance by. It
            should return an (n x n) matrix
                df1dx1 df1dx2 ... df1dxn
                df2dx1 df2dx2 ... df2dxn
                 ...    ...   ...  ...
                dfndx1 dfndx2 ... dfndxn
        P: covariance matrix to transform

    Returns:
        P_prime: transformed covariance matrix
    """
    A = Jfun(X)
    P_prime = A.dot(P.dot(A.T))
    return P_prime