Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to solve 3 equations in Python without matrix?

Hi I have 3 simple equation that I wanted to solve in python.

5x+9y=23 2x+3z=11 7x+5y+6z=35

first I wanted to solve with np.array but first two equation has 2 different unknowns. I can’t find similar problems in internet and I don’t know what should I use to solve this.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use np.linalg.solve and assign a coefficient of 0 to the missing unknowns

import numpy as np

A = np.array([[5, 9, 0], [2, 0, 3], [7, 5, 6]])
b = np.array([23, 11, 35])
x = np.linalg.solve(A, b)

print(x)
[1., 2., 3.]

So the solution is x=1, y=2, z=3

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading