# Problem with lyap(Q,R)

**URL:** https://discourse.julialang.org/t/problem-with-lyap-q-r/64745
**Category:** General Usage
**Created:** [July 16, 2021, 12:36pm UTC](https://discourse.julialang.org/t/problem-with-lyap-q-r/64745 "2021-07-16T12:36:19Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [July 16, 2021, 12:55pm UTC](https://discourse.julialang.org/t/problem-with-lyap-q-r/64745/2 "2021-07-16T12:55:26Z")

</div>

Welcome! In order to make it easier to help you, please wrap your code in triple backtickes (```) to format it as code. For more information, please read [Make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757). Please also make sure you’re aware of the [Differences from MATLAB](https://docs.julialang.org/en/v1/manual/noteworthy-differences/#Noteworthy-differences-from-MATLAB).

I’m not sure why this works in MATLAB in the first place - `B'` has negative complex conjugate eigen values, which are forbidden per the dosctring of `lyap` (or I’m misunderstanding something about the dosctring):

```julia
julia> eigvals(B')                         
16-element Vector{ComplexF64}:             
 -0.6761400549933252 - 0.978143841175781im 
 -0.6761400549933252 + 0.978143841175781im 
 -0.5754555540509579 - 1.6824830146993683im
 -0.5754555540509579 + 1.6824830146993683im
 -0.5000999500060193 - 50.007504436433635im
 -0.5000999500060193 + 50.007504436433635im
  -0.500099870149834 - 50.027497437709776im
  -0.500099870149834 + 50.027497437709776im
  0.5000998701498371 - 50.027497437709776im
  0.5000998701498371 + 50.027497437709776im
  0.5000999500060104 - 50.00750443643361im 
  0.5000999500060104 + 50.00750443643361im 
  0.5754555540509454 - 1.6824830146993628im
  0.5754555540509454 + 1.6824830146993628im
   0.676140054993325 - 0.9781438411758407im
   0.676140054993325 + 0.9781438411758407im

help?> lyap                                                                                                                                                                                 
search: lyap displayable                                                                                                                                                                    
                                                                                                                                                                                            
  lyap(A, C)                                                                                                                                                                                
                                                                                                                                                                                            
  Computes the solution X to the continuous Lyapunov equation AX + XA' + C = 0,
  where no eigenvalue of A has a zero real part and no two eigenvalues are
  negative complex conjugates of each other.                                                                                                                                                                                    

```

---

_[View the full topic](https://discourse.julialang.org/t/problem-with-lyap-q-r/64745)._
