# How to ensure normalization of generalized eigenvalue problem

**URL:** <https://discourse.julialang.org/t/how-to-ensure-normalization-of-generalized-eigenvalue-problem/7221>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 21, 2017, 3:22pm UTC](https://discourse.julialang.org/t/how-to-ensure-normalization-of-generalized-eigenvalue-problem/7221 "2017-11-21T15:22:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Post date:** [November 21, 2017, 3:22pm UTC](https://discourse.julialang.org/t/how-to-ensure-normalization-of-generalized-eigenvalue-problem/7221/1 "2017-11-21T15:22:09Z")

</div>

I have a Hermitian matrix `H` and a Hermitian and positive definite matrix `S`. I want the solutions to the following generalized eigenvalue problem Hx=\lambda Sx and want `x` to be properly normalized. In scipy, there’s an `eigh` function that guarantees the normalization ([scipy.linalg.eigh — SciPy v0.19.1 Reference Guide](https://docs.scipy.org/doc/scipy-0.19.1/reference/generated/scipy.linalg.eigh.html)). How do I do this in julia? Does `H=Hermitian(H)` and `S=Hermitian(S)` guarantee this?

---

<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:** [November 21, 2017, 6:29pm UTC](https://discourse.julialang.org/t/how-to-ensure-normalization-of-generalized-eigenvalue-problem/7221/2 "2017-11-21T18:29:39Z")

</div>

Yes, if you do `λ, X = eig(Hermitian(H), Hermitian(S))`, then `X` is “properly” normalized in the sense that `X'*S*X` is approximately `I`. Similarly for `eigfact` etcetera.

(Actually, `eig` will check whether its arguments are Hermitian and do this automatically, but explicitly telling it that you have Hermitian matrices is a good practice.)

---

<div class="post-metadata">

**Author:** ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Post date:** [November 22, 2017, 3:35am UTC](https://discourse.julialang.org/t/how-to-ensure-normalization-of-generalized-eigenvalue-problem/7221/3 "2017-11-22T03:35:23Z")

</div>

`X'*S*X` is approximately `I`? Why not exactly?

---

<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:** [November 22, 2017, 4:34am UTC](https://discourse.julialang.org/t/how-to-ensure-normalization-of-generalized-eigenvalue-problem/7221/4 "2017-11-22T04:34:47Z")

</div>

> [@Chong\_Wang](#):
>
> `X'*S*X` is approximately I? Why not exactly?

Roundoff errors.

---

<div class="post-metadata">

**Author:** ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Post date:** [November 22, 2017, 5:44am UTC](https://discourse.julialang.org/t/how-to-ensure-normalization-of-generalized-eigenvalue-problem/7221/5 "2017-11-22T05:44:06Z")

</div>

Thank you for reply. I always think detailed documentation of some functions are lacking.

---

<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:** [November 22, 2017, 1:12pm UTC](https://discourse.julialang.org/t/how-to-ensure-normalization-of-generalized-eigenvalue-problem/7221/6 "2017-11-22T13:12:06Z")

</div>

> [@Chong\_Wang](#):
>
> I always think detailed documentation of some functions are lacking.

Documentation patches are always welcome and are quite easy. (Just search on the [julia github](https://github.com/JuliaLang/julia) for a phrase from the docstring to find out where it is in the source. You can [edit the file directly in your web browser](https://help.github.com/articles/editing-files-in-your-repository/) to submit a patch.)
