Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168754
Image: ubuntu2004
from numpy import * from numpy.linalg import solve # 4 * x0 - 16 * x1 = 9 # 13 * x0 - 8 * x1 = 23 a = array( [[4,-16], [16,-8]] ) b = array( [9, 23 ] ) x = solve( a, b ); x print x t=dot( a, x ) print t
[ 1.32142857 -0.23214286] [ 9. 23.]
# 6 * x0 + 20 * x1 = -22,4 # -5 * x0 - 0,12 * x1 = 1 c = array( [[6,20], [5,0.12]] ) d = array( [-22.4, 1 ] ) x = solve( c, d ); x print x s=dot( c, x ) print s
[ 0.22852538 -1.18855761] [-22.4 1. ]
from numpy import * from numpy.linalg import solve from numpy.linalg import inv # -7 * x0 - 3 * x1 + 12 * x2 = 15 # 6 * x0 + 31 * x1 + 4 * x2 = 0,4 # 11 * x0 - 2 * x1 + 5 * x2 = 3 e = array( [[-7, -3, 12], [6,31,4], [11,-2,5] ] ) f = array( [15, 0.4, 3 ] ) x = solve( e, f ); x print x z=dot( e, x ) print z
[-0.23794058 -0.08178631 1.09075475] [ 15. 0.4 3. ]
# 1 * x0 - 4 * x1 + 2 * x2 = 1 # -2 * x0 - 3 * x1 + 5 * x2 = 4 # 3 * x0 +6 * x1 +7 * x2 = 5 g = array( [[1, -4, 2], [-2,-3,5], [3,6,7] ] ) h = array( [1, 4, 5 ] ) x = solve( g, h ); x print x u=dot( g, x ) print u
[-0.22543353 0.06936416 0.75144509] [ 1. 4. 5.]