# How to ensure orthogonality of eigenvectors

**URL:** https://discourse.julialang.org/t/how-to-ensure-orthogonality-of-eigenvectors/6924
**Category:** General Usage
**Tags:** question
**Created:** [November 7, 2017, 2:04am UTC](https://discourse.julialang.org/t/how-to-ensure-orthogonality-of-eigenvectors/6924 "2017-11-07T02:04:15Z")
**Posts on this page:** 5
**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 7, 2017, 2:04am UTC](https://discourse.julialang.org/t/how-to-ensure-orthogonality-of-eigenvectors/6924/1 "2017-11-07T02:04:15Z")

</div>

I have a Hermitian matrix `A`. Due to numerical errors, `(A'-A)/2` is around `10^-17` and `eig` returns nonorthogonal eigenvectors. I don’t see a `eigh` function (from numpy) counterpart in julia. How can I ensure orthogonality of eigenvectors of `A`?

---

<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 7, 2017, 3:29am UTC](https://discourse.julialang.org/t/how-to-ensure-orthogonality-of-eigenvectors/6924/2 "2017-11-07T03:29:10Z")

</div>

eig(Hermitian(A))

---

<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 7, 2017, 6:52am UTC](https://discourse.julialang.org/t/how-to-ensure-orthogonality-of-eigenvectors/6924/3 "2017-11-07T06:52:00Z")

</div>

Thank you. Although it is a little bit inconvenient when A has imaginary part in its diagonal axis due to floating point error.

---

<div class="post-metadata">

### Author: ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)
#### Post date: [November 7, 2017, 7:46am UTC](https://discourse.julialang.org/t/how-to-ensure-orthogonality-of-eigenvectors/6924/4 "2017-11-07T07:46:00Z")

</div>

You can rewrite the matrix by keeping only the upper part and copy this upper part to the lower part. This will be exactly symmetric.

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [November 7, 2017, 8:03am UTC](https://discourse.julialang.org/t/how-to-ensure-orthogonality-of-eigenvectors/6924/5 "2017-11-07T08:03:53Z")

</div>

> [@Chong\_Wang](#):
>
> Although it is a little bit inconvenient when A has imaginary part in its diagonal axis due to floating point error.

See [Avoid checking the diagonal for non-real elements when constructing Hermitians by andreasnoack · Pull Request #17367 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/17367)
