# Underdetermined Linear System General Solution

**URL:** <https://discourse.julialang.org/t/underdetermined-linear-system-general-solution/37865>\
**Category:** Numerics\
**Created:** [April 19, 2020, 6:20pm UTC](https://discourse.julialang.org/t/underdetermined-linear-system-general-solution/37865 "2020-04-19T18:20:30Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [April 19, 2020, 6:47pm UTC](https://discourse.julialang.org/t/underdetermined-linear-system-general-solution/37865/2 "2020-04-19T18:47:26Z")

</div>

So you have Ax=b where A\in \mathbb{R}^{m\times n} with m\<n? Then let x\_1 be one particular solution, say, found by `x1 = A\b`. Then, any other value x\_1 + x\_0 is also a solution if x\_0 solves Ax\_0=0. All possible vectors x\_0 solving Ax\_0=0 are linear combinations of basis vectors in the _nullspace_ of A, i.e., x\_0 \in {\cal N}(A).  
Example:

```julia
julia> using LinearAlgebra

julia> A = rand(-9:9,2,3)
2×3 Array{Int64,2}:
 -7 -9 -7
 -8 -8 -1

julia> rank(A)
2

julia> b = [1,2]
2-element Array{Int64,1}:
 1
 2

julia> x1 = A\b
3-element Array{Float64,1}:
 -0.1637895602137279
 -0.10583641594739004
  0.1570078092889437

julia> N = nullspace(A)
3×1 Array{Float64,2}:
 -0.673770210645276
  0.7024412834386926
 -0.22936858234732868

julia> x0 = 0.5*N[:]
3-element Array{Float64,1}:
 -0.336885105322638
  0.3512206417193463
 -0.11468429117366434

julia> A*(x1+x0)
2-element Array{Float64,1}:
 0.9999999999999996
 1.9999999999999971

julia> b
2-element Array{Int64,1}:
 1
 2

```

So… by doing `N = nullspace(A)`, you find a matrix `N` containing basis vectors for the nullspace (kernel) of `A`. Then, with `x1 = A\b`, `x1` is one solution to `Ax=b`, but `x1+N*z` is also a solution to `Ax+b` for any vector `z`.

---

_[View the full topic](https://discourse.julialang.org/t/underdetermined-linear-system-general-solution/37865)._
