In this brief blog post I post a small code that can be used to solve a system of linear equations using SciPy package of Python and in particular the linalg module within the SciPy package.
Documentation: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.linalg.solve.html
The code is pretty much self-explanatory, and there is also a YouTube video where I walk you through the procedure.
CODE:
import numpy as np from scipy import linalg #Solve a system of equations A.X=B #Define the LHS coefficient matrix A A = np.array([ [1, 3, -2], [3, 5, 6], [2, 4, 3] ]) #Print the matrix A print(A) #Define the RHS column vector B B = np.array([ [5, 7, 8] ]) #This is a single row #Transpose it to make a column B = B.T #Print the RHS vector print(B) #Solve the system of equations and store the result in X X = linalg.solve(A, B) #Print the solution print(X)
YouTube Tutorial
I’m a physicist specializing in computational material science with a PhD in Physics from Friedrich-Schiller University Jena, Germany. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT, and Machine Learning related apps and software from time to time. Can code in most of the popular languages. I like to share my knowledge in Physics and applications using this Blog and a YouTube channel.
Hello. Please help sketched the program code that implements the Cramer Method block diagram algorithm (found at the bottom of the article): https://www.mathros.net.ua/rozvjazok-systemy-linijnyh-algebraichnyh-rivnjan-metodom-kramera.html