Definition of successive descent method:
- For a given set of equations, use the formula:
where k is the number of iterations (k=0,1,2,... )
The method of finding approximate solution by stepwise generation is called iterative method
- If it exists (recorded as), it is said that this iterative method converges, obviously is the solution of the equations, otherwise called this iterative method divergence.
- Study the convergence of {}. Introducing Error Vectors:
Get:
Recursion gets:
To investigate the convergence of {}, we should study the conditions of B.
The following gives the Python implementation
#-*-Coding:utf-8-*-
Import NumPy as NP
From numpy Import *
From common_libs Import *
Import Matplotlib.pyplot as Plt
#消元发求解方程组的解
#求解元方程
Def method_nomal ():
A=mat ([[8,-3,2],
[4,11,-1],
[6,3,12]])
B=mat ([20,33,36])
Result=linalg.solve (A,B.T)
Print result
#迭代法进行计算
def interationmethod (n,b0,f):
Error = 1.0e-6 # iteration Threshold
steps = 100 # Number of iterations
Xk=zeros ((n,1))
Errorlist=[]
For I in range (steps):
Xk_1=xk
Xk=b0*xk+f
Errorlist.append (Linalg.norm (XK_1-XK))
If Errorlist[-1]<error:
Print i+1
Break
Print XK
Return i,errorlist
Method_nomal ()
B0=mat ([[0.0,3.0/8,-2.0/8],
[ -4.0/11,0.0,1.0/11],
[ -6.0/12,-3.0/12,0.0]])
Print (B0)
F=mat ([20.0/8,33.0/11,36.0/12])
[K,errorlist]=interationmethod (3,b0,f)
# Plot Scatter plots
matpts= Zeros ((2,k+1))
Matpts[0]=linspace (1,k+1,k+1)
Print Matpts[0]
Matpts[1]=array (errorlist)
Drawscatter (plt,matpts)
Plt.show ()
Machine learning successive descent method (machine learning algorithm principle and practice) Zheng Jie