Re: Recognising parameters in function
- To: mathgroup at smc.vnet.net
- Subject: [mg94552] Re: Recognising parameters in function
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Tue, 16 Dec 2008 02:33:56 -0500 (EST)
On 12/15/08 at 7:47 AM, Stuart.Nettleton at uts.edu.au (Stuart
Nettleton) wrote:
>Hi, would someone be able to suggest why FindMinimum will recognise
>parameters in the following function but the backsubstitution will
>not. Thanks for any help, Stuart
>Clear[f, vars1, z];
>vars1 = {x, y};
>z = (x - 5)^2 + (y - 3)^2;
>f[vars_] := Module[{a},
>a = z/2;
>Return[a]
>] /; VectorQ[vars, NumericQ];
>optim = FindMinimum[Join[{f[vars1]}, Thread[vars1 >= 0]], vars1]
>optim[[2]]
>f[vars1] /. optim[[2]]
Did you look at the result you get when you type f[vars1] ?
Notice this returns f[x,y] since you have defined f only for
numeric inputs. If you redefine f as:
f[vars_] := Module[{a},
a = z/2;
Return[a]
] /; VectorQ[vars]
Things will work as you expected. Note, since FindMinimum is
intended to work with symbols, there is no need to restrict the
values to numeric input.
- Follow-Ups:
- Re: Re: Recognising parameters in function
- From: "Stuart Nettleton" <Stuart.Nettleton@uts.edu.au>
- Re: Re: Recognising parameters in function