0% found this document useful (0 votes)
29 views3 pages

Sebastián Alejandro Peralta Solís

This document contains code for performing matrix operations in NumPy including matrix multiplication, inversion, and solving systems of linear equations. Multiple examples are shown of creating and manipulating matrices to solve various problems.

Uploaded by

SebasAx24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Sebastián Alejandro Peralta Solís

This document contains code for performing matrix operations in NumPy including matrix multiplication, inversion, and solving systems of linear equations. Multiple examples are shown of creating and manipulating matrices to solve various problems.

Uploaded by

SebasAx24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

18/10/22, 20:32 Untitled9.

ipynb - Colaboratory

SEBASTIÁN ALEJANDRO PERALTA SOLÍS

from math import*


import numpy as np
from matplotlib import pyplot

np.eye(3)

array([[1., 0., 0.],


[0., 1., 0.],
[0., 0., 1.]])

A=np.array([[2,-1],[3,5]],float)
B=np.array([[1,-1],[2,0]],float)
print("A=",A)
print("B=",B)

A= [[ 2. -1.]
[ 3. 5.]]
B= [[ 1. -1.]
[ 2. 0.]]

x1=np.dot(np.linalg.inv(B-3*np.eye(2)),np.dot(A,np.dot(B,np.linalg.inv(A))))
x=np.round(x1,decimals=2)
print(x)

[[ 0.54 0.18]
[-1.54 -0.06]]

import numpy as np
a=np.array([[1,2,3],[2,5,-1],[-1,2,1]],float)
b=np.array([[10],[20],[6]],float)
print("La matriz A es:",a)
print("La matriz B es:",b)
x=np.linalg.solve(a,b)
print("x=",x)

La matriz A es: [[ 1. 2. 3.]


[ 2. 5. -1.]
[-1. 2. 1.]]
La matriz B es: [[10.]
[20.]
[ 6.]]
x= [[1.5]
[3.5]
[0.5]]

import numpy as np
a=np.array([[1,2,3],[2,5,-1],[-1,2,1]],float)
https://colab.research.google.com/drive/1bIBYeb_2_MOHxdfWaZQ9fwhD_pDn5k9N#scrollTo=NckWtwSKu21w&printMode=true 1/3
18/10/22, 20:32 Untitled9.ipynb - Colaboratory

b=np.array([[10],[20],[6]],float)
print("La matriz A es:",a)
print("La matriz B es:",b)
y=np.linalg.inv(a).dot(b)
print("y=",y)

La matriz A es: [[ 1. 2. 3.]


[ 2. 5. -1.]
[-1. 2. 1.]]
La matriz B es: [[10.]
[20.]
[ 6.]]
y= [[1.5]
[3.5]
[0.5]]

import numpy as np
a=np.array([[2,1,-3],[5,-4,1],[1,-1,-4]],float)
b=np.array([[7],[-19],[4]],float)
print("La matriz A es:",a)
print("La matriz B es:",b)
x=np.linalg.solve(a,b)
print("x=",x)

La matriz A es: [[ 2. 1. -3.]


[ 5. -4. 1.]
[ 1. -1. -4.]]
La matriz B es: [[ 7.]
[-19.]
[ 4.]]
x= [[-1.]
[ 3.]
[-2.]]

import numpy as np
a=np.array([[2,1,-3],[5,-4,1],[1,-1,-4]],float)
b=np.array([[7],[-19],[4]],float)
print("La matriz A es:",a)
print("La matriz B es:",b)
y=np.linalg.inv(a).dot(b)
print("y=",y)

La matriz A es: [[ 2. 1. -3.]


[ 5. -4. 1.]
[ 1. -1. -4.]]
La matriz B es: [[ 7.]
[-19.]
[ 4.]]
y= [[-1.]
[ 3.]
[-2.]]

https://colab.research.google.com/drive/1bIBYeb_2_MOHxdfWaZQ9fwhD_pDn5k9N#scrollTo=NckWtwSKu21w&printMode=true 2/3
18/10/22, 20:32 Untitled9.ipynb - Colaboratory

Productos de pago de Colab - Cancelar contratos

check 0 s completado a las 19:53

https://colab.research.google.com/drive/1bIBYeb_2_MOHxdfWaZQ9fwhD_pDn5k9N#scrollTo=NckWtwSKu21w&printMode=true 3/3

You might also like