solve(a, b)
Computes the "exact" solution, x
, of the well-determined, i.e., full rank, linear matrix equation :None:None:`ax = b`
.
Broadcasting rules apply, see the numpy.linalg
documentation for details.
The solutions are computed using LAPACK routine _gesv
.
a
must be square and of full-rank, i.e., all rows (or, equivalently, columns) must be linearly independent; if either is not true, use lstsq
for the least-squares best "solution" of the system/equation.
Coefficient matrix.
Ordinate or "dependent variable" values.
If a
is singular or not square.
Solution to the system a x = b. Returned shape is identical to b
.
Solve a linear matrix equation, or system of linear scalar equations.
scipy.linalg.solve
Similar function in SciPy.
Solve the system of equations x0 + 2 * x1 = 1
and 3 * x0 + 5 * x1 = 2
:
>>> a = np.array([[1, 2], [3, 5]])
... b = np.array([1, 2])
... x = np.linalg.solve(a, b)
... x array([-1., 1.])
Check that the solution is correct:
>>> np.allclose(np.dot(a, x), b) TrueSee :
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them