-1

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.

Wolfie
  • 27,562
  • 7
  • 28
  • 55
Egumus
  • 3
  • 1

1 Answers1

-2

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

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Sembei Norimaki
  • 745
  • 1
  • 4
  • 11
  • 2
    Please don't do people's homework for them. Your comment telling OP to search for documentation is a much better response. – ChrisGPT was on strike Dec 22 '22 at 13:31
  • well yes, but in tutorials usually they put systems with complete equations. In this case the OP was asking how to solve for systems with missing unknowns, which I explained that is solved by setting the coeff to 0 and gave an example. – Sembei Norimaki Dec 22 '22 at 13:38