analiza 2

1650 days ago by ps347232

x = PolynomialRing(RationalField(), 'x').gen() f = (x+1)*(x+2)*(x+3)*(x+4)*(x+5) # wielomian przy A print f.coeffs() f = x*(x+2)*(x+3)*(x+4)*(x+5) # wielomian przy B print f.coeffs() f = x*(x+1)*(x+3)*(x+4)*(x+5) # wielomian przy C print f.coeffs() f = x*(x+1)*(x+2)*(x+4)*(x+5) # wielomian przy D print f.coeffs() f = x*(x+1)*(x+2)*(x+3)*(x+5) # wielomian przy E print f.coeffs() f = x*(x+1)*(x+2)*(x+3)*(x+4) # wielomian przy F print f.coeffs() 
       
[120, 274, 225, 85, 15, 1]
[0, 120, 154, 71, 14, 1]
[0, 60, 107, 59, 13, 1]
[0, 40, 78, 49, 12, 1]
[0, 30, 61, 41, 11, 1]
[0, 24, 50, 35, 10, 1]
# TWORZĘ MACIERZ Z KOLUMN POWYŻEJ A = matrix([ [120, 0, 0, 0, 0, 0], [274, 120, 60, 40, 30, 24], [225, 154, 107, 78,61, 50], [85, 71, 59, 49, 41, 35], [15, 14, 13, 12, 11, 10], [1, 1, 1,1, 1, 1]]) b = vector([1,0,0,0,0,0]) rozwiazanie = A.solve_right(b) print rozwiazanie 
       
(1/120, -1/24, 1/12, -1/12, 1/24, -1/120)
literki = ['A', 'B', 'C', 'D', 'E', 'F'] for (literka, i) in zip(literki, rozwiazanie): print literka, i 
       
A 1/120
B -1/24
C 1/12
D -1/12
E 1/24
F -1/120
wynik = sum([ 1 / n for n in range(1,6) ])/120 - sum([ 1 / n for n in range(2,5) ])/24 + 1/36 
       
print wynik 
       
1/600