# Non-deterministic behavior of eigs

**URL:** <https://discourse.julialang.org/t/non-deterministic-behavior-of-eigs/3801>\
**Category:** General Usage\
**Created:** [May 19, 2017, 6:46am UTC](https://discourse.julialang.org/t/non-deterministic-behavior-of-eigs/3801 "2017-05-19T06:46:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rleegates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rleegates/32/1029_2.png) [@rleegates](https://discourse.julialang.org/u/rleegates)\
**Post date:** [May 19, 2017, 6:46am UTC](https://discourse.julialang.org/t/non-deterministic-behavior-of-eigs/3801/1 "2017-05-19T06:46:54Z")

</div>

Is this the intended behavior? I would expect the ritz vectors to be the canonical basis in R^8 and I would expect them to stay constant throughout multiple runs (eigenvalues are always `ones(3)` as expected). Can anyone fill me in on what is going on here?

```julia
julia> eigs(speye(8), nev=3, ritzvec=true, which=:SM)[2]
8×3 Array{Float64,2}:
 -0.552044 0.10732 0.578923 
 -0.138011 -0.227993 0.144731 
 -0.585306 -0.452005 -0.163411 
  0.0730166 0.142816 -0.371052 
  0.389231 -0.490191 -0.0481029
 -0.418483 0.0958366 -0.690552 
  0.0 0.549401 0.0      
 -0.0407031 0.400604 -0.0184778

julia> eigs(speye(8), nev=3, ritzvec=true, which=:SM)[2]
8×3 Array{Float64,2}:
  0.00775152 0.736026 0.505057 
 -0.320627 -0.309745 0.0776387
 -0.237798 0.184377 0.198084 
  0.675444 -0.342876 0.225129 
 -0.406029 -0.366182 0.312641 
  0.206851 0.148876 -0.182258 
 -0.263908 -0.167436 0.419491 
 -0.327217 0.162716 -0.584836 

julia> eigs(speye(8), nev=3, ritzvec=true, which=:SM)[2]
8×3 Array{Float64,2}:
 -0.398514 -0.160118 0.478223 
  0.308472 -0.852963 0.0919957
 -0.699164 -0.334796 -0.31761  
  0.0798313 -0.320225 -0.0133081
 -0.129924 -0.0860299 -0.650589 
  0.407973 -0.00212213 -0.458479 
  0.0556911 0.119012 0.0370779
 -0.253781 0.103025 -0.164142 

julia> eigs(speye(8), nev=3, ritzvec=true, which=:SM)[2]
8×3 Array{Float64,2}:
 -0.734486 -0.570433 0.108706 
 -0.0151101 0.245278 0.524546 
 -0.141446 -0.0494962 0.4738   
  0.0 3.46945e-18 0.3506   
  0.0899482 -0.296473 -0.337316 
 -0.267319 0.225752 -0.491867 
 -0.129436 -0.272222 -0.0622161
 -0.586508 0.631688 -0.0777291

```

---

<div class="post-metadata">

**Author:** ![antoine-levitt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-levitt/32/4008_2.png) [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)\
**Post date:** [May 19, 2017, 7:10am UTC](https://discourse.julialang.org/t/non-deterministic-behavior-of-eigs/3801/2 "2017-05-19T07:10:02Z")

</div>

Eigenvectors of degenerate eigenvalues are not well-defined, and any linear combination is an acceptable solution. Interestingly, the results are not deterministic even when ARPACK is initialized with a deterministic v0. My guess is that, since the Krylov space spanned by v0 is just span(v0), ARPACK needs to enrich the subspace in some way, and it does so with random vectors.
