Qu

solve

Builtin index · Core maths

result = solve(A, b)

Input: A, b · Output: result

What it is

Solves A·x = b for x by LU with partial pivoting (or, for a CMat/CVec A/b, by complex SVD least squares). A is an n×n Mat/CMat, b is a length-n Vec/CVec or an n×k Mat/CMat of multiple right-hand sides.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = solve(A, b)
A Mat, CMat, Vec, or CVecA is an n×n Mat/CMat, b is a length-n Vec/CVec or an n×k Mat/CMat of multiple right-hand sides.
b CMat or CVecSolves A·x = b for x by LU with partial pivoting (or, for a CMat/CVec A/b, by complex SVD least squares).
result Mat or CMat
Returns a Mat/CMat the same shape as b. Prefer it to inv(A) * b: it is faster and numerically better behaved.

Examples

No documentation example calls this form yet. The Core maths chapter is where one belongs.

How it works

solve(A, b) — the solution of A x = b, the named form of the \ operator and the spelling every ported script uses. Square systems go through LU; anything else, or a singular A, falls back to the least-squares solution, which is what a regularised normal-equation fit wants.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.