Re: Using lmdif from MINPACK

From: Peter Spellucci (spellucci_at_fb04373.mathematik.tu-darmstadt.de)
Date: 12/20/04


Date: Mon, 20 Dec 2004 11:26:42 +0000 (UTC)


In article <8pdaz9blcbyh@legacy>,
 chintakk@yahoo.com (Krishna Chinta) writes:
>Hi Peter,
>
>Thank you very much for ur response.
>I have some questions regarding the values of m,nn
>
> from the lmdif subroutine
> m is a positive integer input variable set to the number
> of functions.
>
> n is a positive integer input variable set to the number
> of variables. "n must not exceed m".
>
> from the quoted statement, does it mean that lmdif cant solve with a
>single function and more unknown variables? i think the speciality if
>the non-linear pakage is solving a function with more number of
>unknowns.

  no, this is a misunderstanding. for lmdif you write the function
  which computes the set of residuals as a function vector.
  say you have a fit model like
  y=f(x;a,b,c) = a+b*exp(x*c)
  with a data list (xdata(i),ydata(i))
  then you have three unknowns: a,b,c this is the "x" for lmdif
  and n=3. say a=x(1, b=x(2), c=x(3);
  your xdata,ydata are data which do not appear in the functions parameterlist
  typically, in fortran you will put the data list (xdata(i),ydata(i))
  in a named common block.
  and fcn computes the differences
  f(i)=ydata(i)-(a+b*exp(xdata(i)*c))
  i=1,...,m and of course you must have at list 3 data itmes
   (but typically will have hundreds)
  hth
  peter

>
>And the function which i am planning to solve is having 3 unkowns.
>
>Please give me the suggestions,
>
>Thank you in advance,
>
>Krishna
>
>
>correct me if i m wrong in the interpretation
>On Wed, 15 Dec 2004 14:18:59 +0000 (UTC), Peter Spellucci wrote:
> >
>>In article <azjqdjfpvh3y@legacy>,
>> chintakk@yahoo.com (Krishna Chinta) writes:
>> >Hi all,
>> >
>> >Please help me in the 'examples of systems of non-linear functions
>> >that can be handled by lmdif' and the calling sequense for such.
>> >
>> >I want to minimize a functional, obtained from method of
>fundamental
>> >solution (MFS)with moving sources.
>> >
>> >Thanks in advance,
>> >
>> >Krishna
>> >
>>
>>lmdif is for minimizing the sum of squares of (at least) two times
>>differentiable nonlinear functions.
>>you must write a
>> SUBROUTINE FCN(m,nn,x,fvec,IFLAG)
>>which, given the optimization vector x of length nn computes the
>>m components of the vector fvec which contains the single nonlinear
>>function values (not the squares and not the sum, this is done by
>lmdif himself)
>>for example if you want to minimize
>> 100*(x(1)-x(2)**2)**2+(1-x(1))**2
>>then
>> fvec(1)=10*(x(1)-x(2)**2)
>> fvec(2)=1-x(1)
>>
>>hth
>>peter
>