##################################################### # Solutions to Worksheet from Chap. 10 # # Matrix Operations, Optimization, Integration # ##################################################### # A- A first optimization problem # 10.1- A <- matrix(c(2,3,5,4),nrow=2,ncol=2) myf <- function(x) { res <- det(A-x*diag(2)) return(res) } # 10.2- myf <- function(x) { n <- length(x) res <- rep(NA,n) for (i in 1:n) res[i] <- det(A-x[i]*diag(2)) return(res) } # 10.3- curve(myf,xlim=c(-10,10)) abline(h=0,v=0) # Note that we can use the instruction locator(2)$x to "find" the two roots. # 10.4- uniroot(myf,lower=-5,upper=0)$root uniroot(myf,lower=0,upper=10)$root # 10.5- The polynomial can be written P .x/ D 7 6x C x 2 . Its roots are obtained using: polyroot(c(-7,-6,1)) # 10.6- eigen(A)$values