[SciPy-user] Another leastsq Jacobian bug

Christian K ckkart@hoc....
Tue Jun 26 18:47:41 CDT 2007

Lin Shao wrote:
> No I didn't. The simplest refute to your answer is that your J[1] is
> -2*params[0]*(xx*params[1]-params[1]^2). How could there be a term
> with params[1]'s quadratic in the derivative if the original function
> is a quadratic function?
> On 6/25/07, Christian K <ckkart@hoc.net> wrote:
>> Lin Shao wrote:
>>>>> ## Now define my Jacobian
>>>>> def Jacobian(params,xx,yy,mode='col'):
>>>>>     J = N.empty((len(params),xx.size))
>>>>>     J[0] = (xx-params[1])**2
>>>>>     J[1] = -2*params[0]*(xx-params[1])
>>>> shouldn't that be -2*params[0]*(xx-params[1])*params[1]  ?
>>> I think I was right. Think about what's the derivative of -x^2 -- it's -2x
>> you forgot about the chain rule .

You're right. Sorry.


More information about the SciPy-user mailing list