#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 24 14:48:09 2024

@author: sam
"""

import numpy as np
from scipy import linalg as la

A = np.random.rand(20,20) # creates a 20x20 matrix A of random numbers
b = np.random.rand(20,1) # creates a 20x1 vector b of random numbers

c = la.inv(A) # creates variable c, equal to the inverse of the matrix A

x = c @ b # solves for x by left matrix multiplying the inverse of A by b

print(x) # prints x

print(A @ x) # prints matrix product of A and x, which should solve for b

print((A @ x) - b) # prints the difference between that and b to check they are the same