0

I have this code:

import numpy as np
a = np.array([[1, -0.15],[-0.1,1]])
b = np.array([10000, 18000])
print(np.linalg.solve(a,b))

It gives me these value outputs which are correct:

[12893.40101523 19289.34010152]

I need a code that will add these two values together.

perennial_noob
  • 459
  • 3
  • 14

2 Answers2

3

Use the following program to compute the sum:

print(sum(np.linalg.solve(a,b)))
Felix
  • 1,837
  • 9
  • 26
0

You can use numpy.sum which is faster for numpy arrays.

import numpy as np
a = np.array([[1, -0.15],[-0.1,1]])
b = np.array([10000, 18000])
print(np.linalg.solve(a,b).sum())

Output: 32182.7411168

Diogo Rocha
  • 9,759
  • 4
  • 48
  • 52