Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168695
Image: ubuntu2004
#example of swamping #taken from Timothy Sauer's Numerical Analysis page 98
#a swamping problem #using double precision arithmetic m = matrix([[10.0^-20,1.0],[1.0,2.0]]) b = vector([1.0,4.0]) x = m.solve_right(b) #answer should be close to (2,1) #"swamping" problem occurs due to very small numbers used for pivot in Gaussian Elimination #10^20 + 1 ~= 10^20 in Gaussian Elimination print x
(0.000000000000000, 1.00000000000000)
#now first swap rows, then calculate m = matrix([[1.0,2.0],[10.0^-20,1.0]]) b = vector([4.0,1.0]) x = m.solve_right(b) #answer should be close to (2,1) print x print "ta dah"
(2.00000000000000, 1.00000000000000) ta dah