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 ...