print 'f(x,y)=x**2-10*x*y+y**2'
a=1
c=1
def f(x,y):
ff=x**2-10*x*y+y**2
return ff
print 'f(1,1)=',f(1,1)
print 'The conditions a>0 and c>0 ensure that f(x,y) is positive on the x and y axes. But this function is negative on the line x=y,because b=-10 overwhelms a and c. '
print 'f(x,y)=2*x**2+4*x*y+y**2'
A=[[2, 2],[2, 1]]
a=1
c=1
b=2
print 'ac=',a*c
print 'b**2=',b**2
print 'Saddle point,as ac<b**2'
print 'f(x,y)=2*x**2+4*x*y+y**2'
A=[[2 ,2],[2, 1]]
a=0
c=0
b=1
print 'ac=',a*c
print 'b**2=',b**2
print 'Saddle point,as ac<b**2'
print 'f(x,y)=x**2+4*x*y+y**2'
a=1
c=1
def f(x,y):
ff=x**2+4*x*y+y**2
return ff
print 'f(0,0)=',f(0,0)
print 'Here 2b=4 it still does not ensure a minimum ,the sign of b is of no importance.Neither F nor f has a minimum at(0,0) because f(1,-1)=-1.'
from scipy.linalg import svd
from numpy import array,transpose
A=transpose(array([[-1, 2, 2]]))
print 'A=',A
ans=svd(A)
U=ans[0]
diagnol=ans[1]
V=ans[2]
print 'U=',U
print 'diagnol=',diagnol
print "V'=",V
print "A=U*diagnol*V'=\n",U*diagnol*transpose(V)
from scipy.linalg import svd
from numpy import mat,array,transpose as tp, zeros
A=mat([[-1, 1, 0],[0, -1, 1]])
print 'A=\n',A
U,diagnl1,V=svd(A)
diagnl=zeros([2,3])
diagnl[0,0]=diagnl1[0]
diagnl[1,1]=diagnl1[1]
U=mat(U)
diagnl=mat(diagnl)
V=mat(V)
print 'U=\n',U
print 'Diagonal=\n',diagnl
print "V'=",tp(V)
print (U*diagnl)
print "A=U*diagonal*V'=\n",((U*diagnl)*tp(V))
from numpy import mat, transpose as tp
from scipy.linalg import svd
A=mat([[1, -2],[3, -1]])
print 'A=\n',A
U,S,V=svd(A)
Q=U*tp(mat(V))
S=V*S*tp(mat(V))
print 'Q=\n',Q
print 'S=\n',S
print 'A=SQ=\n',(Q*S)
from __future__ import division
from numpy import mat, transpose as tp
from scipy.linalg import svd
A=mat([[1, -2],[3, -1]])
print 'A=\n',A
U,diag1,V=svd(A)
Q=U*tp(mat(V))
S=mat([[2, 1],[1, 3]])
print 'Q=\n',Q
print 'S=\n',S
print "A=S'Q=\n",(S*tp(mat(Q)))