Re: Recognising parameters in function
- To: mathgroup at smc.vnet.net
- Subject: [mg94563] Re: [mg94523] Recognising parameters in function
- From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
- Date: Tue, 16 Dec 2008 02:36:02 -0500 (EST)
- References: <200812151247.HAA26383@smc.vnet.net>
Hi, because the line f[vars1]/.optim[[2]] isn't working like you expect it. f[vars1] is evaluated to f[{x,y}] and not more because {x,y} is not a Numeric vector! Replacing now the x and y with the values in optim[[2]] gives f[{5,3}] and makes it to a numeric vector which is then evaluated to z/2. If you want to fill in your values you can write f[vars1] /. optim[[2]] /. optim[[2]] which is definitely not intuitive. Can you explain why you are using a function which ignores the value of its parameters? Your function f is similar to g[_?(VectorQ[#, NumericQ] &)] := 1/2 (x - 5)^2 + (y - 3)^2; I really don't see the reason for that. If you can tell that, I can explain why the FindMinimum-line works. Cheers Patrick On Mon, 2008-12-15 at 07:47 -0500, 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]] > > -- > UTS CRICOS Provider Code: 00099F > DISCLAIMER: This email message and any accompanying attachments may contain > confidential information. If you are not the intended recipient, do not > read, use, disseminate, distribute or copy this message or attachments. If > you have received this message in error, please notify the sender > immediately and delete this message. Any views expressed in this message > are those of the individual sender, except where the sender expressly, and > with authority, states them to be the views the University of Technology, > Sydney. Before opening any attachments, please check them for viruses and > defects. >
- References:
- Recognising parameters in function
- From: "Stuart Nettleton" <Stuart.Nettleton@uts.edu.au>
- Recognising parameters in function