Ask Your Question

tobiasBora's profile - activity

2021-11-26 04:09:44 +0100 received badge  Popular Question (source)
2021-02-15 01:48:38 +0100 received badge  Famous Question (source)
2020-08-05 13:56:27 +0100 received badge  Popular Question (source)
2019-06-26 12:21:03 +0100 asked a question Compute the square root of a complex matrix


I can't find how to compute the square root of a complex matrix... I tried m.sqrt(), sqrt(m) (display only symbolic sqrt), sqrt(m).n()... None of them work. What is the regular way to compute the root of a complex matrix? (you can assume the matrix is self-adjoint if needed).


def test():
    phi = matrix(CC, [[1/sqrt(2)],[i]])
    m = phi * phi.C.T
    print("Matrix: {}".format(m))
    s = sqrt(m).n() # Does not work: AttributeError: 'ComplexField_class_with_category' object has no attribute 'complex_field'
    #s = m^(1/2) # Does not work either, NotImplementedError: non-integral exponents not supported
    # s = m.sqrt() # Does not work either, no attribute sqrt
    print("Sqrt: {}".format(s))
    print("s*s: {}".format(s*s))
    if s*s == m:
        print("Nope :(")

EDIT: For now I'm using the numpy backend with manual diagonalisation, but I'd like to know if there is a better way to proceed...

 phi = matrix(CDF, [[1/sqrt(2)],[i]])
 D, P = m.eigenmatrix_right()
 s = P*diagonal_matrix([sqrt(x) for x in D.diagonal()])*P^-1
2018-05-22 04:11:21 +0100 received badge  Notable Question (source)
2018-04-16 09:57:45 +0100 asked a question Square root of polynomial modulo another irreducible polynomial


If I'm not wrong, it is always possible to compute the square root of a polynomial $P$ modulo an irreducible polynomial $g$ when the base field is in $GF(2^m)$, i.e. find $Q \in GF(2^m)$ such that $Q^2 \equiv P \mod g$. Indeed, the operation $Q \rightarrow Q^2 \pmod g$ should be linear (because we are in $GF(2^m)$) so an idea would be to compute the matrix $T$ that perform this operation, and then invert it, but I'd like to find an embedded operation in sage. I tried the sagemath $P.sqrt()$ method, but the problem is that because it does not take into account the modulo, it fails most of the time when the polynomial has some terms with odd power of $X$.

Any idea?


2018-04-16 09:46:43 +0100 received badge  Scholar (source)
2018-04-16 09:46:40 +0100 received badge  Supporter (source)
2018-04-16 09:46:37 +0100 commented answer Map a matrix to a block matrix

Ok, thank you for your help !

2018-04-11 00:15:48 +0100 asked a question Map a matrix to a block matrix


I have a function that maps an element $x$ into a $1\times n$ matrix, say for example $[x,x,x]$. I would like to map this function to a matrix and consider the resulting matrix as a "block matrix". E.g: change matrix([[1,2],[3,4]]) into matrix([[1,1,1,2,2,2],[3,3,3,4,4,4]]).

For now, I use a trick that basically converts back the matrix to a a list using something like:

block_matrix([[f(elt) for elt in row] for row in M.rows()])

but it looks quite dirty so I would like to know if there are some better way to proceed.

Thank you!

2016-07-26 21:14:24 +0100 received badge  Popular Question (source)
2013-06-11 09:15:52 +0100 received badge  Student (source)
2013-06-10 17:19:31 +0100 received badge  Editor (source)
2013-06-10 17:02:53 +0100 asked a question Choose the viewpoint in plot3d


I would like to display lots of spheres (about 6000) in jmol but when I've to many points it crashs.

If I try to run the interactive mode (even If don't have any picture) I've this error : "Jmol Applet #2 is having trouble loading. Will retry once."

How could I do to get a picture of my work ?

--- EDIT ---

I found the function save('filename') and now I've a display, but I'd like to change the point of view. Is it possible ?