least square for 6 variables

*To*: mathgroup at smc.vnet.net*Subject*: [mg28183] least square for 6 variables*From*: Stefan.Schenderlein at ferring.de*Date*: Tue, 3 Apr 2001 02:38:01 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Hi, using FindMinimum[] with Method->LevenbergMarquardt I did not understand why I had to expand the equations manually. When I work with the simplified version the algorithm stops in a local minimum or something without meaning. For sure I have checked with Mathematica whether the expansion / simplification was really the same. (There are some parts of the notebook below. I will send the complete code, if necessary.) I do not have a problem with that since the expanded version now gives me the solutions I was looking for. But in a discussion with Visual Numerics Germany they told me that their IMSL Math Library would rather like the simplified equations. I did not find much about correct using of FindMinimum in the manual and FAQ. My guess is that I run into the trouble due to the extensive use of subscripts. Perhaps someone could give me a hint. Thanks. stefan.schenderlein at ferring.de Chemical potential for the polymer poor phase: (example for component1) This is what i would like to use In[79]:= \!\(\(\[Mu]\_A1 := Log[\[Phi]\_A1] + 1 - \[Phi]\_A1 - \(\[Nu]\_1\/\[Nu]\_2\) \[Phi]\_A2 - \ \(\[Nu]\_1\/\[Nu]\_3\) \[Phi]\_A3 + \((\[Chi]\_12\ \[Phi]\_A2\ + \[Chi]\_13\ \ \[Phi]\_A3\ )\) \((\[Phi]\_A2 + \[Phi]\_A3)\) - \(\[Nu]\_1\/\[Nu]\_2\) \[Chi]\ \_23\ \[Phi]\_A2\ \[Phi]\_A3;\)\) This is what works. \!\(\(\[Mu]\_A1 := Log[\[Phi]\_A1] + 1 - \[Phi]\_A1 - \(\[Nu]\_1\/\[Nu]\_2\) \[Phi]\_A2 - \ \(\[Nu]\_1\/\[Nu]\_3\) \[Phi]\_A3 + \[Chi]\_12\ \[Phi]\_A2\ \[Phi]\_A2 + \ \[Chi]\_12\ \(\[Phi]\_A2\) \[Phi]\_A3 + \[Chi]\_13\ \[Phi]\_A3\ \[Phi]\_A2 + \ \[Chi]\_13\ \[Phi]\_A3\ \[Phi]\_A3 - \(\[Nu]\_1\/\[Nu]\_2\) \[Chi]\_23\ \ \[Phi]\_A2\ \[Phi]\_A3;\)\) If the phases are in equilibrium the chemical potential must be equal for any component in both phases. In[85]:= \!\(\(f\_1 := \((\[Mu]\_A1 - \[Mu]\_B1)\);\)\[IndentingNewLine] \(f\_2 := \((\[Mu]\_A2 - \[Mu]\_B2)\);\)\[IndentingNewLine] \(f\_3 := \((\[Mu]\_A3 - \[Mu]\_B3)\);\)\) The material balances have to be fulfilled in each phase. In[88]:= \!\(\(f\_4 := 1 - \((\[Phi]\_A1 + \[Phi]\_A3 + \[Phi]\_A2)\);\)\[IndentingNewLine] \(f\_5 := 1 - \((\[Phi]\_B1 + \[Phi]\_B3 + \[Phi]\_B2)\);\)\) The objective function is formulated as as sum of squares. In[90]:= \!\(\(F = f\_1\^2 + f\_2\^2 + f\_3\^2 + f\_4\^2 + f\_5\^2;\)\) In[91]:= \!\(F := f\_1\^2 + f\_2\^2 + f\_4\^2 + f\_5\^2\) In[115]:= \!\(\[Nu]\_1 = 20000; \[Nu]\_2 = 63.6; \[Nu]\_3 = 150000. ; \[Chi]\_12 = .4; \[Chi]\_13 = 5; \[Chi]\_23 = 0.4; \[Phi]\_B3 = 0; \[Phi]\_A2 = .01; init = \ \(solution = \[IndentingNewLine]FindMinimum[ F, \[IndentingNewLine]{\[Phi]\_A1, .01}, {\[Phi]\_A3, .8}, \ \ {\ \[Phi]\_B1, .98}, {\[Phi]\_B2, .0135}, WorkingPrecision \[Rule] 16, \[IndentingNewLine]Method \[Rule] LevenbergMarquardt, MaxIterations \[Rule] 350]\)\)