[Python] Row Echelon form of matrix using python coding without using any inbuilt functions

Discussão em 'Python' iniciado por Stack, Abril 1, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to write a code for the row Echelon form of \ matrix using Python without using any inbuilt functions. But I'm getting an error for last column.

    A=[[1,2,3],[4,5,6],[7,8,9]]

    j=0;k=0

    print("Input matrix",A)


    for i in range(3):

    a=A
    while j < 3:
    A[j]=A[j]/a
    j=j+1
    j=1
    b=A[j][k]
    while k < 3:
    if k < 3 and j < 3:
    A[j][k]=A[j-1][k]*b-A[j][k]
    k=k+1
    j=1
    k=1
    print("output matrix",A)


    output:

    Input matrix [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

    output matrix [[1.0, 2.0, 3.0], [0.0, 1.0, 2.0], [7, 0.888888, 1.0]]




    the last row first element and second element should be zero.

    Continue reading...

Compartilhe esta Página