Ask Your Question

SageUserNick's profile - activity

2024-03-01 21:32:57 +0200 received badge  Good Question (source)
2024-02-23 20:04:18 +0200 received badge  Famous Question (source)
2023-01-30 18:53:34 +0200 received badge  Notable Question (source)
2023-01-30 18:53:34 +0200 received badge  Popular Question (source)
2022-06-01 11:28:32 +0200 received badge  Nice Question (source)
2022-02-14 21:34:58 +0200 commented answer Why specifying `stylesheet` parameter in plot function causes error?

Thanks, that helps.

2022-02-14 21:34:26 +0200 commented answer Why specifying `stylesheet` parameter in plot function causes error?

Thank you for an answer. That's a good workaround, but unfortunately still requires too much typing. Also, I can't figur

2022-02-14 21:31:04 +0200 commented answer Why specifying `stylesheet` parameter in plot function causes error?

Thank you for an answer. That's a good workaround, but unfortunately still requires too much typing.

2022-02-13 12:45:42 +0200 received badge  Editor (source)
2022-02-13 12:45:42 +0200 edited question Why specifying `stylesheet` parameter in plot function causes error?

Why specifying `stylesheet` parameter in plot function causes error? I'm disappointed by how the default plot style look

2022-02-13 12:44:24 +0200 asked a question Why specifying `stylesheet` parameter in plot function causes error?

Why specifying `stylesheet` parameter in plot function causes error? I'm disappointed by how the default plot style look

2021-10-07 19:01:14 +0200 received badge  Nice Question (source)
2021-10-07 11:45:38 +0200 commented answer Diagonalize matrix numerically over $\mathbb{C}$

Is there a way to display the numerically-looking numbers the way sympy does it? I.e. sqrt(2) instead of 1.414213562373

2021-10-07 11:45:23 +0200 commented answer Diagonalize matrix numerically over $\mathbb{C}$

Is there a way to display the numerically-looking numbers the sympy does it? I.e. sqrt(2) instead of 1.414213562373?

2021-10-07 11:42:28 +0200 commented answer Diagonalize matrix numerically over $\mathbb{C}$

Thank you for a good answer, I accepted it. My mistake was I didn't try other fields. I should have googled for algebrai

2021-10-07 11:41:19 +0200 received badge  Supporter (source)
2021-10-07 11:38:38 +0200 marked best answer Diagonalize matrix numerically over $\mathbb{C}$

Suppose I have a matrix m:

$$ m = \left(\begin{array}{rr} 2 & -3 \\ 1 & 0 \end{array}\right). $$ It is diagonalizable and has complex eigenvalues. I now want to diagonalize it, but get an error:

In [20]: m = matrix([[2, -3], [1, 0]]); m.diagonalization()  
...   
ValueError: matrix entries must be from a field

When I specify the field m = matrix(CDF, [[2, -3], [1, 0]]), I get ValueError: base field must be exact, but Complex Double Field is not. Specifying ComplexLazyField() instead of CDF raises NotImplementedError.

So, apparently, Sage is trying to diagonalize the matrix symbolically, i.e. exactly. But what if I don't care about exactness and just want a straightforward numerical answer?

This is how I would do it with sympy:

In [22]: import sympy as sp  
          ...: m = sp.Matrix([[2, -3], [1, 0]])  
          ...: m.diagonalize()  
Out[22]:  
(Matrix([    
 [1 - sqrt(2)*I, 1 + sqrt(2)*I],    
 [            1,             1]]),   
 Matrix([     
 [1 - sqrt(2)*I,             0],    
 [            0, 1 + sqrt(2)*I]]))

Notice that the output is actually exact. I know I can run this same Python code in Sage, but I assume there's a more native way to do it.

To sum up, how do I get Sage to diagonalize a matrix over $\mathbb{C}$? How do I change the code if I only need the numerical answer?

2021-10-07 11:38:38 +0200 received badge  Scholar (source)
2021-10-07 11:12:54 +0200 received badge  Student (source)
2021-10-07 11:02:56 +0200 asked a question Diagonalize matrix numerically over $\mathbb{C}$

Diagonalize matrix numerically over $\mathbb{C}$ Suppose I have a matrix m: $$ m = \left(\begin{array}{rr} 2 & -3 \