Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Im trying to solve a matrix where: a= [[2 0], [0 2], [1 1]] b= [[0], [0], [0]] I am using numpy to solve this

image text in transcribed

Im trying to solve a matrix where:

a= [[2 0], [0 2], [1 1]]

b= [[0], [0], [0]]

I am using numpy to solve this matrix. The matrix is supposed to balance a chemical equation in this case it is H2 + O2 ---> H2O

My main error is last 2 dimensions of the array must be square

Traceback (most recent call last): File "/Users/parsa/Desktop/A2/Reactiont.py", line 152, in bal = balance(lhsList, rhsList), File "/Users/parsa/Desktop/A2/Reactiont.py", line 108, in balance x = lin.solve(a,b) File "<_array_function_ internals>", line 6, in solve File "/usr/local/Cellar/python/3.7.3/Frameworks/Python. framework/Versions/3.77 lib/python3.7 site-packagesumpy _assert_stacked_square(a) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packagesumpy/ raise LinAlgError('Last 2 dimensions of the array must be square'), numpy. linalg.LinAlgError: Last 2 dimensions of the array must be square Traceback (most recent call last): File "/Users/parsa/Desktop/A2/Reactiont.py", line 152, in bal = balance(lhsList, rhsList), File "/Users/parsa/Desktop/A2/Reactiont.py", line 108, in balance x = lin.solve(a,b) File "<_array_function_ internals>", line 6, in solve File "/usr/local/Cellar/python/3.7.3/Frameworks/Python. framework/Versions/3.77 lib/python3.7 site-packagesumpy _assert_stacked_square(a) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packagesumpy/ raise LinAlgError('Last 2 dimensions of the array must be square'), numpy. linalg.LinAlgError: Last 2 dimensions of the array must be square

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago