       evaluating functions within Findminimum

• To: mathgroup at smc.vnet.net
• Subject: [mg100123] evaluating functions within Findminimum
• From: Alberto Maydeu <amaydeu at ub.edu>
• Date: Mon, 25 May 2009 06:18:34 -0400 (EDT)

```Greetings to all,

I'm using

FindMinimum[Evaluate[e . Inverse[NormalAcov[sigma]]. e], Evaluate[Sequence @@ startval]]

NormalAcov[sigma] is a symbolic function. FindMinimum evaluates Inverse[NormalAcov[sigma]] symbolically then plugs in the numeric starting values and proceeds. This is obviously very slow for large problems.

How can I get FindMinimum to first plug in the numeric starting values and perform Inverse[NormalAcov[sigma]] numerically as opposed to symbolically?

In case my question is unclear, here's a toy example

sigma = {{l1^2 + ps1, l1* l2, l1*l3}, {l1* l2, l2^2 + ps2, l2 l3}, {l1 l3, l2 l3, l3^2 + ps3}};
startval = {{l1, .8}, {l2, .7}, {l3, .6}, {ps1, 1}, {ps2, 1}, {ps3, 1}};
e = {1.7 - l1^2 - ps1, .5 - l1*l2, 1.6 - l2 - ps2, 1.5 - l1^2 - l3, .8 - l2*l3, 1.8 - l3^2 - ps3};
FindMinimum[Evaluate[e . Inverse[NormalAcov[sigma]]. e], Evaluate[Sequence @@ startval]]

with

NormalAcov[matrix_List] := Module[{l1, l, c},
l1 = Length[matrix];
l = Binomial[l1 + 1, 2];
c = Join @@ Table[{i, j}, {i, l1}, {j, 1, i }];
Table[matrix[[c[[i, 1]], c[[j, 1]]]]*matrix[[c[[i, 2]], c[[j, 2]]]] + matrix[[c[[i, 1]], c[[j, 2]]]]*matrix[[c[[i, 2]], c[[j, 1]]]]
, {i, l}, {j, l}]];