# Some iterative solvers in LinearSolve ignore the initial conditions

**URL:** https://discourse.julialang.org/t/some-iterative-solvers-in-linearsolve-ignore-the-initial-conditions/118903
**Category:** General Usage
**Tags:** linearalgebra, linearsolve
**Created:** [September 1, 2024, 8:50am UTC](https://discourse.julialang.org/t/some-iterative-solvers-in-linearsolve-ignore-the-initial-conditions/118903 "2024-09-01T08:50:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![c\_sell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c_sell/32/38854_2.png) [@c\_sell](https://discourse.julialang.org/u/c_sell)
#### Post date: [September 1, 2024, 8:50am UTC](https://discourse.julialang.org/t/some-iterative-solvers-in-linearsolve-ignore-the-initial-conditions/118903/1 "2024-09-01T08:50:34Z")

</div>

Hello,  
I think I might be doing something wrong, but it seems that none of the Krylov methods in `LinearSolve` are using the initial guess I provide. (In the small example below, the initial guess is the true solution.)

```julia
import LinearSolve as LS 
using SparseArrays
using Random

rng = Random.MersenneTwister(123)
_A = sprand(rng,10,10,0.3)
A = _A * _A'
rhs = rand(rng,10)

# get an "initial guess"
prob1 = LS.LinearProblem(A,rhs)

u0 = LS.solve(prob1,LS.KrylovJL_GMRES())
residual = A * u0 - rhs

# use the initial guess 
prob2 = LS.LinearProblem(A,rhs;u0 = u0)

LS.solve(prob2,LS.KrylovJL_GMRES(),verbose = true)

```

Thanks for your help

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [September 1, 2024, 2:44pm UTC](https://discourse.julialang.org/t/some-iterative-solvers-in-linearsolve-ignore-the-initial-conditions/118903/2 "2024-09-01T14:44:56Z")

</div>

Sounds like a bug. Would you mind filing an issue to make it easy for us to track? (Also @ChrisRackauckas this definitely could explain some of the non-determinism I’ve been running into).

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [September 1, 2024, 2:57pm UTC](https://discourse.julialang.org/t/some-iterative-solvers-in-linearsolve-ignore-the-initial-conditions/118903/3 "2024-09-01T14:57:32Z")

</div>

No, this is not a bug. It’s a property of GMRES. We currently zero the values because of the extensive literature on this, see [Better initial guesses for reinitialized iterative solvers · Issue #70 · SciML/LinearSolve.jl · GitHub](https://github.com/SciML/LinearSolve.jl/issues/70). There are ways to do non-zero guesses, but rand like this is not necessarily convergent so it’s not a good idea to just accept it. We’d have to renormalize it or something, again see the papers linked in the issue.

> [@Oscar\_Smith](#):
>
> (Also @ChrisRackauckas this definitely could explain some of the non-determinism I’ve been running into).

No, 0 is deterministic.
