Problem with lyap(Q,R)

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. Please also make sure you’re aware of the 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> 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.