• Kramer usulini ishlatib yechimlarni hisoblash solution = kramer_method(coefficients, constants) print("x =", solution[0], ", y =", solution[1])
  • determinant of Matrix def determinantOfMatrix(mat): ans = (mat[0][0] * (mat[1][1] * mat[2][2] - mat[2][1] * mat[1][2])
  • This function finds the solution of system of linear equations using cramers rule def findSolution(coeff): Matrix d using coeff as given in
  • Amaliy mashg‘ulot ishi – 1




    Download 351,4 Kb.
    bet2/3
    Sana02.01.2024
    Hajmi351,4 Kb.
    #129594
    1   2   3
    def determinant(matrix):
    # Matritsa determinantini hisoblash
    # Sizning determinatni hisoblash funktsiyangiz bo'lishi kerak


    def kramer_method(coefficients, constants):
    n = len(coefficients)
    det_main = determinant(coefficients) # Asosiy determinant


    results = [] # Yechimlar ro'yxati


    for i in range(n):
    temp = [row[:] for row in coefficients] # Kofaktorlar uchun foydalanish uchun ko'pilyatsiya qilamiz
    for j in range(n):
    temp[j][i] = constants[j] # i-te o'zgaruvchi uchun bir necha joyda o'rnatingan burchak
    det_temp = determinant(temp) # Temp determinatini hisoblash
    results.append(det_temp / det_main) # Yechimlarni hisoblash va ro'yxatga joylash


    return results


    # Masalaning koeffitsiyentlar va tesiriy ko'nikmalari
    coefficients = [[3, 5], [4, 3]]
    constants = [9, 16]


    # Kramer usulini ishlatib yechimlarni hisoblash
    solution = kramer_method(coefficients, constants)
    print("x =", solution[0], ", y =", solution[1])


    2 masala
    # Python3 program to calculate
    # solutions of linear equations
    # using cramer's rule
    # This functions finds the
    # determinant of Matrix
    def determinantOfMatrix(mat):
    ans = (mat[0][0] * (mat[1][1] * mat[2][2] -
    mat[2][1] * mat[1][2]) -
    mat[0][1] * (mat[1][0] * mat[2][2] -
    mat[1][2] * mat[2][0]) +
    mat[0][2] * (mat[1][0] * mat[2][1] -
    mat[1][1] * mat[2][0]))
    return ans
    # This function finds the solution of system of
    # linear equations using cramer's rule
    def findSolution(coeff):
    # Matrix d using coeff as given in

    Download 351,4 Kb.
    1   2   3




    Download 351,4 Kb.