Skip to content

Classical solveยค

We wish to solve the linear system \(Ax = b\). Here we consider the classical case for which the full matrix \(A\) is square, well-posed and materialised in memory.

import jax.random as jr
import lineax as lx


matrix = jr.normal(jr.PRNGKey(0), (3, 3))
vector = jr.normal(jr.PRNGKey(1), (3,))
operator = lx.MatrixLinearOperator(matrix)
solution = lx.linear_solve(operator, vector)
print(f"A=\n{matrix}\nb={vector}\nx={solution.value}")
A=
[[-0.3721109   0.26423115 -0.18252768]
 [-0.7368197   0.44973662 -0.1521442 ]
 [-0.67135346 -0.5908641   0.73168886]]
b=[ 0.17269018 -0.64765567  1.2229712 ]
x=[-2.7321298 -8.52878   -7.7226872]