# Different inverse for almost equal matrices

**URL:** https://discourse.julialang.org/t/different-inverse-for-almost-equal-matrices/81028
**Category:** General Usage
**Tags:** question, linearalgebra, matrices
**Created:** [May 13, 2022, 3:31pm UTC](https://discourse.julialang.org/t/different-inverse-for-almost-equal-matrices/81028 "2022-05-13T15:31:31Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [May 13, 2022, 8:15pm UTC](https://discourse.julialang.org/t/different-inverse-for-almost-equal-matrices/81028/12 "2022-05-13T20:15:10Z")

</div>

> [@shce](#):
>
> and the condition number is of order `1e9` .

Whenever you multiply by the matrix or its inverse (or equivalent, e.g. `A \ b`), you should generically expect to lose about 9 digits to roundoff errors, which is very close to what you are seeing:

```julia
julia> eps() * 1e9
2.220446049250313e-7

```

> [@shce](#):
>
> I’m afraid I won’t be able circumvent this, right?

Not necessarily, but solving an ill-conditioning problem generally means going back to an earlier step, understanding where the ill-conditioning comes from, and re-arranging your computation to avoid it. (That is, you wouldn’t construct your matrix at all, but instead do some equivalent process from earlier inputs. A classic example of this is solving least-squares [by QR factorization rather than the normal equations.](https://discourse.julialang.org/t/efficient-way-of-doing-linear-regression/31232/33))

---

_[View the full topic](https://discourse.julialang.org/t/different-inverse-for-almost-equal-matrices/81028)._
