Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to solve a set of functions to determine the material properties from a set of measurement values. (To set up this method I just want to fit my model with some already calculated data).

My equations look like this:

eqns = {
   fres[L1] - f1,
   fres[L2] - f2,
   fres[L3] - f3,
   fres[L4] - f4,
   fres[L5] - f5

fres[L_] is defined earlier (very long equations which do not need to matter at the moment) - here is just a working example:

fres[L_] := C1^2 / (L^2)*Sqrt[Sum[Subscript[a, i] + Subscript[b, i], {i, 1, 5}]]

Now I wanted to solve this set of equations by the method of least squares fitting to determine the a_i (note: I'm not using subscript in my code but I'm using a vector with a[[i]]):

sol = FindMinimum[{Total[eqns^2], a1 >= 50*10^9, a2 >= 100*10^9, a3 >= 70*10^9, a4 >= 100*10^9}, {a1, a2, a3, a4}, Method -> "LevenbergMarquardt"]

eqns /. Last@sol (* for manual control *)

The problem is, that I cannot get any solution here, because the LevenbergMarquardt method do not allow constrainted problems. As far as I understoot, the least squares fitting method is best done by this method... My a1..a4 are only positive values in the range of 10^9 to 10^12...

When I remove the method my input looks like this:

sol = FindMinimum[{Total[eqns^2], a1 >= 50*10^9, a2 >= 100*10^9, a3 >= 70*10^9, a4 >=100*10^9}, {a1, a2, a3, a4}]

And the output:

FindMinimum::eit: The algorithm does not converge to the tolerance of 4.806217383937354`*^-6 in 500 iterations. The best estimated solution, with feasibility residual, KKT residual, or complementary residual of {0.0157055,8.38758*10^-7,0.00491086}, is returned. >>

Increasing the iterations won't deliver good results either (i tried up to 10 000). It only results in a1..a4 which are very close to my starting values:

{1.12792, {a1-> 5.*10^10, a2-> 1.*10^11, a3 -> 1.03486*10^11, a4 -> 1.*10^11}}
{-0.908837, -0.252209, -0.100982, 0.361948, 0.311647}

Do you have any idea how I could get the a1..a4 (or even more)? Is there any elegant way of doing this?

Your help would much be appreciated!

share|improve this question
(1) Possibly NMinimize would work better for this, albeit at cost of run time. (2) You could try adding an explicit penalty term to the objective function. That way you have the possibility of setting method->"LevenbergMarquardt". – Daniel Lichtblau Jun 23 '14 at 16:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.