Powell's singular function (lmder test #6). Don't run this as a
    test, since it just zooms to zero parameters.  The precise results
    depend a lot on nitty-gritty rounding and tolerances and things.

def _lmder1_powell_singular():
    """Powell's singular function (lmder test #6). Don't run this as a
    test, since it just zooms to zero parameters.  The precise results
    depend a lot on nitty-gritty rounding and tolerances and things."""

    def func(params, vec):
        vec[0] = params[0] + 10 * params[1]
        vec[1] = np.sqrt(5) * (params[2] - params[3])
        vec[2] = (params[1] - 2 * params[2])**2
        vec[3] = np.sqrt(10) * (params[0] - params[3])**2

    def jac(params, jac):
        jac.fill(0)
        jac[0,0] = 1
        jac[0,3] = 2 * np.sqrt(10) * (params[0] - params[3])
        jac[1,0] = 10
        jac[1,2] = 2 * (params[1] - 2 * params[2])
        jac[2,1] = np.sqrt(5)
        jac[2,2] = -2 * jac[2,1]
        jac[3,1] = -np.sqrt(5)
        jac[3,3] = -jac[3,0]

    guess = np.asfarray([3, -1, 0, 1])

    _lmder1_test(4, func, jac, guess)
    _lmder1_test(4, func, jac, guess * 10)
    _lmder1_test(4, func, jac, guess * 100)