I have a quadratic function f where, f = function (x) {2+.1*x+.23*(x*x)}
. Let's say I have another quadratic fn g where g = function (x) {3+.4*x-.60*(x*x)}
Now, I want to maximize f given the constraints 1. g>0
and 2. 600<x<650
I have tried the packages optim
,constrOptim
and optimize
. optimize
does one dim. optimization, but without constraints and constrOptim
I couldn't understand. I need to this using R. Please help.
P.S. In this example, the values may be erratic as I have given two random quadratic functions, but basically I want maximization of a quadratic fn given a quadratic constraint.