If the highest power is 1, then we call it a linear model. On the other hand, if the highest power is 2, we call it a quadratic function. The R optim() function can be used to find a solution for a minimization problem. For example, we have the following objective function:

Since there is only one variable, we can solve it manually. Take the first-order derivative and set it to:
x<-seq(-10,10,0.1) a<--2 b<-10 c<-5 y<-a*x^2+b*x+c plot(x,y,type='l')
The related graph is shown here:

From the graph, we know that we could get a maximum y value when x is zero:
y<-20-3.5*x^2 a<--2 b<-10 c<-5 f<-function(x)-(a*x^2+b*x+c)
In the preceding formula, we use a negative function since the R optim() function would get a minimum value instead of a maximum one:
> optim(0.3,f) $par [1] 2.500078 $value [1] -17.5 ...