scipy.linalg solve array output in one line in python

You can use the scipy.linalg.solve function to solve an array output in one line in Python. Here's an example:

main.py
import numpy as np
from scipy.linalg import solve

A = np.array([[2, 1], [1, 1]])
b = np.array([1, 2])

x = solve(A, b)
print(x)
129 chars
9 lines

This will output the solution x for the linear equation Ax = b.

related categories

gistlibby LogSnag