<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calc_cov_x(infodic, p):
 """ Calculate cov_x from fjac, ipvt and p as is done in leastsq """


    fjac = infodic["fjac"]
    ipvt = infodic["ipvt"]
    n = len(p)

    # adapted from leastsq function in scipy/optimize/minpack.py
    perm = np.take(np.eye(n), ipvt - 1, 0)
    r = np.triu(np.transpose(fjac)[:n, :])
    R = np.dot(r, perm)
    try:
        cov_x = np.linalg.inv(np.dot(np.transpose(R), R))
    except LinAlgError:
        cov_x = None
    return cov_x