# Seeking Feedback on Robust Solution for Consistent but ill-conditioned Linear System with Real Symmetric Positive Semidefinite Matrices

**URL:** <https://discourse.julialang.org/t/seeking-feedback-on-robust-solution-for-consistent-but-ill-conditioned-linear-system-with-real-symmetric-positive-semidefinite-matrices/111957>\
**Category:** New to Julia\
**Tags:** linearsolve\
**Created:** [March 22, 2024, 2:22am UTC](https://discourse.julialang.org/t/seeking-feedback-on-robust-solution-for-consistent-but-ill-conditioned-linear-system-with-real-symmetric-positive-semidefinite-matrices/111957 "2024-03-22T02:22:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![swanchristmas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swanchristmas/32/202550_2.png) [@swanchristmas](https://discourse.julialang.org/u/swanchristmas)\
**Post date:** [March 22, 2024, 2:22am UTC](https://discourse.julialang.org/t/seeking-feedback-on-robust-solution-for-consistent-but-ill-conditioned-linear-system-with-real-symmetric-positive-semidefinite-matrices/111957/1 "2024-03-22T02:22:17Z")

</div>

Hello everyone,

I’m currently grappling with a challenging problem involving a linear system that’s consistent but ill-conditioned due to the nature of the matrices involved. I’ve devised a potential solution, but I’m seeking feedback and alternative approaches from the community to ensure robustness and efficiency.

Problem Overview:  
I’m dealing with a linear system represented as ( M\*A = B ), where matrices ( A ) and ( B ) are both real symmetric positive semi-definite, and the condition number of B guaranteed to be no less than that of A.  
(The nullspace of A and B should match **in theory** but not sure if the round-off error will be introduced since the linear system is just a small step within a set of complicate odes.)

Proposed Approach:  
To address the ill-conditioning while preserving consistency, I’ve devised the following approach:

```julia
M = nullspace(B) |> x -> (cholesky(Symmetric(A + x*x'))/B)'

```

Thank you!

---

<div class="post-metadata">

**Author:** ![swanchristmas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swanchristmas/32/202550_2.png) [@swanchristmas](https://discourse.julialang.org/u/swanchristmas)\
**Post date:** [March 27, 2024, 2:45am UTC](https://discourse.julialang.org/t/seeking-feedback-on-robust-solution-for-consistent-but-ill-conditioned-linear-system-with-real-symmetric-positive-semidefinite-matrices/111957/2 "2024-03-27T02:45:18Z")

</div>

Let’s denote v as the nullvector of B: `B*v = 0;`  
Then, `(A+v*v')^{-1} = ((A+v*v')^{-1}*A)*A^{-1} = A^{-1} - (A+v*v')^{-1}*(v*v')*A^{-1}`  
where v\*v’ constructs the nullspace of B which can’t traverse to the leftmost unless it commutes with A.
