       Re: Using LevenbergMarquardt Method with a complicated function

• To: mathgroup at smc.vnet.net
• Subject: [mg52708] Re: Using LevenbergMarquardt Method with a complicated function
• From: algaba at alumni.uv.es (algaba)
• Date: Thu, 9 Dec 2004 20:23:58 -0500 (EST)
• References: <c42fu1475r5h@legacy>
• Sender: owner-wri-mathgroup at wolfram.com

```Hi.
I have defined a very long function like this:

ChiSquare[Per0_?NumericQ, Ppa0_?NumericQ, Ecc0_?NumericQ] :=

(some steps and definitions here)

ChiSQ = Sum[ResAlpha[[i]]^2 + ResDelta[[i]]^2, {i, 1, Length[
TExp]}] + Sum[ResAlphaComp[[i]]^2 +
ResDeltaComp[[i]]^2, {i, 1, Length[TComp]}]);

which tries to find the Chi-Square of an array of data. Now, I want to
minimize it and I use FindMinimum, which works well. The problem
arises when I want to use the Levenberg-Marquardt method, which seems
to be better for this kind of functions (As you can see, it is a sum
of squares) But when I run Mathematica 5 it gives me the next error
message:

FindMinimum::notlm: The objective function for the method
LevenbergMarquardt \
must be in a least-squares form: Sum[f[i][x]^2,{i,1,n}] or Sum[w[i] \
f[i][x]^2,{i,1,n}] with positive w[i].

I think the function accomplishes all the requirements. Why I get this
error? Is it maybe because of the long definition of the function? Is
it because Mathematica doesn't see this function as a sum of squares
but as a sequence of steps?
What can I do to solve this problem? I do want to use this method to
minimize the Chi-Square. Thanks.

******************************************
algaba at alumni.uv.es
Universitat de Valencia
Departamento de Astronomía y Astrofísica
******************************************

```

• Prev by Date: projection of {-1,1}*{-1,1} to a ruled tetrahedral surface in rectangles
• Next by Date: problem getting the area under a parmetric curve
• Previous by thread: Using LevenbergMarquardt Method with a complicated function
• Next by thread: Re: Using LevenbergMarquardt Method with a complicated function