# Find the max/min of some function given multiple parameters?

Posted 9 months ago
808 Views
|
4 Replies
|
0 Total Likes
|
 Say I have a simple function and I want to find its minimum for different parameters (an optimization problem), how do I do that? http://puu.sh/Adkbi/04dbda4dd3.png This for instance, I don't care about complex roots I want it to show all reals, how to do that? http://puu.sh/AdkcI/5710a78156.png doing it this way says the constraints are wrong even though they are inequalities? If there is a way to make a Hesse's matrix that would work too. This is how it could look like for instance for some a,b,c,d,f > 0 http://puu.sh/AdkeR/a00f325581.png . Now I don't want to plot it, I just want to see the optimums for say 50=>a>=1 etc.Thanks in advance.
4 Replies
Sort By:
Posted 9 months ago
 For simple problems Maximize and Minimize can symbolically handle problems with parameters. Here's an example from the documentation In[1]:= Maximize[a x^2 + b x + c, x] Out[1]= {\[Piecewise] { {c, (b == 0 && a == 0) || (b == 0 && a < 0)}, {-((b^2 - 4 a c)/(4 a)), (b > 0 && a < 0) || (b < 0 && a < 0)}, {\[Infinity], \!$$TagBox["True", "PiecewiseDefault", AutoDelete->False, DeletionWarning->True]$$} }, {x -> \[Piecewise] { {0, (b == 0 && a == 0) || (b == 0 && a < 0)}, {-(b/(2 a)), (b > 0 && a < 0) || (b < 0 && a < 0)}, {Indeterminate, \!$$TagBox["True", "PiecewiseDefault", AutoDelete->False, DeletionWarning->True]$$} }}} 
Posted 9 months ago
 So, the end idea is I want to be able to input a set of parameters and it would output the optimum (a numeric value) . If I understand correctly what that snippet is doing is splitting the function into "pieces" and everything is setup beforehand already. I fail to see how this helps me.EDIT: in fact nothing works at all, putting in a very simple function, Mathematica cant find the minimum no matter what. http://puu.sh/Adm4H/0d8d39eb9d.png stating the function needs to be bounded while it says that nowhere in the docs, also it doesnt say how to bound it. Furthermore a free program like desmos does this but im trying to crawl here before I can walk https://puu.sh/Adm8a/5a21c66585.png . Either theres things im not getting or im stupid, but I have no clue how this software works at all. There seems to be no way to restrict it to Reals only like for example Derive had, there seems to be no way to actually make it oblige the constraints you set, so is this even doable at all?
 NMinimize[{(5 + x^3.5)/x, x > 0}, x] (* Out: {5.742347492053465,{x\[Rule]1.2190136481282579}} *) For negative arguments your function becomes complex valued, so this should be excluded from the search. And the respective constrains refer to the argument and not to any parameters.