Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
restrepo
GitHub Repository: restrepo/ComputationalMethods
Path: blob/master/homework/Homework_2018_1_08_1032478036.ipynb
934 views
Kernel: Python 3

Utilizar una función de Numpy para obtener la matriz aumentada del sistema lineal ax=bax=b

import numpy as np import sympy sympy.init_printing()

Se define la matriz MM con las componentes dadas en clase, al igual que el vector bb que completa el sistema lineal

M=np.matrix([[5,-4,0],[-4,7,-3],[0,-3,5]]) b=[1,0,-2] sympy.Matrix(M)
[540473035]\left[\begin{matrix}5 & -4 & 0\\-4 & 7 & -3\\0 & -3 & 5\end{matrix}\right]

Utilizando la función columnstackcolumnstack se obtiene la matriz aumentada MaMa

Ma=np.column_stack((M,b)) sympy.Matrix(Ma)
[540147300352]\left[\begin{matrix}5 & -4 & 0 & 1\\-4 & 7 & -3 & 0\\0 & -3 & 5 & -2\end{matrix}\right]