Re: Recognising parameters in function
- To: mathgroup at smc.vnet.net
- Subject: [mg94560] Re: Recognising parameters in function
- From: "Stuart Nettleton" <Stuart.Nettleton at uts.edu.au>
- Date: Tue, 16 Dec 2008 02:35:27 -0500 (EST)
- Organization: University of Technology, Sydney
- References: <gi5jmt$ppv$1@smc.vnet.net> <49466D8F.3040909@gmail.com>
Hi Jean-Marc, Your thoughts have clarified things. As you have shown, the rule prevents symbolic evaluation of the backsubstitution. However, I need the rule in my real application, which is a computed general equilibrium model where the parameters are matrices. The workaround seems to do the symbolic evaluation outside the function, which means the evaluation of z with the optimum values before invoking a similar function. The new function now has z as its argument (rather than the optimised variable list) and a similar rule which is only changed to match the nature of the new variable. I have provided a simplified version of the test problem below. My immediate issue has been addressed but the need for a second function is somewhat inelegant. I am left with the feeling that the workaround is addressing a symption rather than understanding the cause, which remains: why can FindMinimum use symbolic calculation within the function when a simple direct injection cannot do so? Again, many thanks for your help, Stuart Clear[f, vars1, z, f1]; vars1 = {x, y}; z = (x - 5)^2 + (y - 3)^2; f[vars_] := z*2 /; VectorQ[vars, NumericQ] ; f1[z_] := z*2 /; NumericQ[z] optim = FindMinimum[f[vars1], vars1] optim[[2]] f[vars1] /. optim[[2]] (* causes error *) f1[z] /. optim[[2]] (* evaluating z is ok *) -- 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.