Re: How can I automate this problem in a mathematica notebook?

*To*: mathgroup at smc.vnet.net*Subject*: [mg74052] Re: How can I automate this problem in a mathematica notebook?*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Thu, 8 Mar 2007 04:29:40 -0500 (EST)*Organization*: The Open University, Milton Keynes, UK*References*: <eslsqe$q5a$1@smc.vnet.net>

tnad wrote: > I was asked to automate the problem below in mathematica: > > I'm using a function called answer[q_] in terms of two parameters alpha and q. > > > answer[q_]:= "a pretty long equation in terms of q and alpha" If you have two parameters, you should have the two parameters define explicitly in the LHS of the definition of your function (otherwise that means that the value of second parameter depends on some global variable, which is poor programming practice). Define answer either as answer[q_, alpha_]:= ... or answer[alpha_][q_]:= ... > > The maximum values of q can be obtained from this: > > Maximize[{answer[q], {0 < q < 1}}, q] Then you use answer as in Maximize[{answer[0.25][q], {0 < q < 1}, q] > > but obviously I need to specify a value for alpha to get a maximum value for q > > So basically I want to plot answer[q] for values of alpha between 0.25 and 1 such that q is maximum in answer[q] (maximum q will be different for a the different alpha values). > > I hope someone can tell me how to code this so that it is automated in mathematica. I'm guessing this should be an easy problem for you people :) > HTH, Jean-Marc