# We need to minimize u^TAu+2b^Tu.
# Let us constraining u>=0.
u0=c(3,2,1)  # is an initial guess.

A=matrix(c(2,1,-1,1,3,0,-1,0,4),3,3); b=-c(4,2,1)
A;b

solve(A,-b)

## Solves linear and quadratic programming problems
## but needs a feasible starting value
#
# from example(solve.QP) in 'quadprog'
# 
fQP <- function(u) {t(u)%*%A%*%u+2*t(b)%*%u}
Amat       <- diag(1,3,3)
bvec       <- c(0,0,0)

gQP <- function(u) {A%*%u+b}
####
result=constrOptim(u0, fQP,gQP, ui = Amat, ci = bvec)
result
ur=result$par


 
# https://[Log in to view URL]

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: