kindly help and guide me how i can correct this code, my target is to find x1,x2,x3 but when the matrix is positive definite i do get the solution correctly as you can see from the code but when the matrix is indefinite we dont get the solution . i want know how i can correct this problem if there is any method that can correct it thanks #Q<-matrix(c(0.2,0.5,.05,0.1),2,2)#####Indefinite #b<-rbind(0.1,0.2) Q<-matrix(c(2.97,-2.47,-2.47,3.97),2,2)###positive definite b<-rbind(-1.99,0.99) #Q<-matrix(c(5,-3,-3,2),2,2) #b<-rbind(0,1) H0<-diag(2) x0<-rbind(0,0) d0<-b g0<--b a0<--(t(g0)%*%d0)/(t(d0)%*%Q%*%d0) x1<-x0+a0[,1]*d0 dx0<-x1-x0 g1<-Q%*%x1-b dg0<-g1-g0 exp0<-t(dg0)%*%dx0 exp1<-(1+((t(dg0)%*%H0%*%dg0)/(exp0[,1])))####first step result exp2<-t(dx0)%*%dg0 exp3<-(exp1[,1]*(dx0%*%t(dx0)))/exp2[,1]########second step result exp4<-t(dg0)%*%dx0 exp5<-(dx0%*%t(dg0)%*%H0+H0%*%dg0%*%t(dx0))/exp4[,1]#######third step H1<-H0+exp3-exp5 d1<--H1%*%g1 a2<--(t(g1)%*%d1)/(t(d1)%*%Q%*%d1) x2<-x1+a2[,1]*d1 g2<-Q%*%x2-b dg1<-g2-g1 dx1<-x2-x1 exp6<-t(dg1)%*%dx1 exp7<-(1+((t(dg1)%*%H1%*%dg1)/(exp6[,1])))####first step result exp8<-t(dx1)%*%dg1 exp9<-(exp7[,1]*(dx1%*%t(dx1)))/exp8[,1]########second step result exp10<-t(dg1)%*%dx1 exp11<-(dx1%*%t(dg1)%*%H1+H1%*%dg1%*%t(dx1))/exp10[,1]#######third step H2<-H1+exp9-exp11 d2<--H2%*%g2 a3<--(t(g2)%*%d2)/(t(d2)%*%Q%*%d2) x3<-x2+a3[,1]*d2 g3<-Q%*%x3-b [[alternative HTML version deleted]]