Re: FindMinimum var specification
- To: mathgroup at smc.vnet.net
- Subject: [mg8875] Re: [mg8828] FindMinimum var specification
- From: seanross at worldnet.att.net
- Date: Tue, 30 Sep 1997 20:16:40 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Bernd Gehrmann wrote:
>
> Hello,
>
> why does the following not work (and how can
> I make it work)?
>
> vars := Sequence[{x[1],0.1},{x[2],0.1}];
>
> ...
>
> FindMinimum[x[1]^2 + x[2]^2, vars];
>
> Bernd.
The error message about HoldForm gives you the clue. := is a delayed
assignment. Putting a delayed assignment into a function argument gives
it the attribute HoldForm, so it never gets assigned. The way around
this is to use delayed assignment and then use Evaluate to make sure
that the delayed equals gets evaluated before being passed on to the
function.
vars := Apply[Sequence,{{x,0.1},{y,0.1}}]; OR
vars := Sequence[{x,0.1},{y,0.1}]; OR
vars = Sequence[{x,0.1},{y,0.1}];
FindMinimum[x^2 + y^2, Evaluate[vars]] works just fine.
my question is why an immediate assignment
vars=Sequence[{x,0.1},{y,0.1}]; still needs to have an Evaluate wrapped
around it.