Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News Sign UpSign In
| Download
Project: Numerik 11
Views: 70
#Version 2 1 Schritt des CG B = Matrix([[-1,0,1], [0,-1,1], [1,0,1], [0,1,1], [-1,0,1]]) A = B.transpose()*B c = vector([0,0,2,2,0]) # <- changed to vector b = B.transpose()*c C= B.transpose() show(C) k1=C.norm(1) show(k1) k2=c.norm(1) show(k2) k3=b.norm(1) show(k3) show(A) show(B) #Input x = vector([1,0,1]) # <- changed to vector r = b-A*x p = r k1=A.norm(1) show(k1) k2=x.norm(1) show(k2) k3=(A*x).norm(1) show(k3) print "x" show(x) print "r" show(r) print "p" show(p) print '(r norm ^2' show((r.norm())^2) print 'p*A*p' show(p*A*p) a = ((r.norm())^2)/(p*A*p) x1 = x+a*p r1 = r - a*A*p b1 = (norm(r1)^2)/(norm(r)^2); p1 = r1+b1*p; print "a" show(a) print "x1" show(x1) print "r1" show(r1) print "b1" show(b1) print "p1" show(p1) print "norm(b-Ax)" show(norm(b-A*x1)) s2e7681b1-19ec-4a26-adc6-bde279e7e55e
2.0\displaystyle 2.0
4\displaystyle 4
8\displaystyle 8
(301020105)\displaystyle \left(\begin{array}{rrr} 3 & 0 & -1 \\ 0 & 2 & 0 \\ -1 & 0 & 5 \end{array}\right)
(101011101011101)\displaystyle \left(\begin{array}{rrr} -1 & 0 & 1 \\ 0 & -1 & 1 \\ 1 & 0 & 1 \\ 0 & 1 & 1 \\ -1 & 0 & 1 \end{array}\right)
6.0\displaystyle 6.0
2\displaystyle 2
6\displaystyle 6
x
(1,0,1)\displaystyle \left(1,\,0,\,1\right)
r
(0,2,0)\displaystyle \left(0,\,2,\,0\right)
p
(0,2,0)\displaystyle \left(0,\,2,\,0\right)
(r norm ^2
4\displaystyle 4
p*A*p
8\displaystyle 8
a
12\displaystyle \frac{1}{2}
x1
(1,1,1)\displaystyle \left(1,\,1,\,1\right)
r1
(0,0,0)\displaystyle \left(0,\,0,\,0\right)
b1
0\displaystyle 0
p1
(0,0,0)\displaystyle \left(0,\,0,\,0\right)
norm(b-Ax)
0\displaystyle 0