Ask Your Question
4

General power of a matrix?

asked 2016-11-19 17:21:33 +0100

Thrash gravatar image

updated 2023-01-09 23:59:41 +0100

tmonteil gravatar image

Is there a way to compute a general power of a matrix? For example:

((2,-1),(1,0))^k = ((k+1,-k),(k,1-k))

WolframAlpha: https://is.gd/8cseex

Is Sage able to compute that?

edit retag flag offensive close merge delete

Comments

3 Answers

Sort by Β» oldest newest most voted
7

answered 2016-11-20 20:34:33 +0100

mforets gravatar image

updated 2016-11-21 12:02:01 +0100

My answer elaborates on using the Jordan normal form to implement a broad class of matrix functions, the matrix power included. It relies on the jordan_form() method, available for exact rings.

The mathematical preliminaries can be found in extending scalar function for matrix functions and in the excellent book Functions of Matrices by N. Higham.

Failure of a straightforward approach

(using πš‚πšŠπšπšŽπ™ΌπšŠπšπš‘πšŸπšŽπš›πšœπš’πš˜πš—πŸ½.𝟺,πšπšŽπš•πšŽπšŠπšœπšŽπ™³πšŠπšπšŽ:𝟸𝟢𝟷𝟼⎯𝟷𝟢⎯𝟷𝟾)

Let

sage: A = matrix(QQ, [[2, -1], [1,  0]])
sage: var('k')
sage: A^k

we get

sage: NotImplementedError: non-integral exponents not supported

Function of a matrix using Jordan normal form

The code below implements $f(A)$ using the Jordan normal form of $A$, see [N. Higham, Functions of Matrices, Sec. 1.2] for details.

def matrix_function_Jordan(A, f):

    # returns jordan matrix J and invertible matrix P such that A = P*J*~P
    [J, P] = A.jordan_form(transformation=True)

    fJ = zero_matrix(SR, J.ncols())
    num_Jordan_blocks = 1+len(J.subdivisions()[0])
    fJ.subdivide(J.subdivisions())

    for k in range(num_Jordan_blocks):

        # get Jordan block Jk
        Jk = J.subdivision(k, k)    

        # dimension of Jordan block Jk
        mk = Jk.ncols();

        fJk = zero_matrix(SR, mk, mk)

        # compute the first row of f(Jk)
        vk = [f.derivative(x, i)(Jk[i][i])/factorial(i) for i in range(mk)]

        # insert vk into each row (above the main diagonal)
        for i in range(mk):
            row_Jk_i = vector(SR, zero_vector(SR, i).list() + vk[0:mk-i])
            fJk.set_row(i, row_Jk_i)

        fJ.set_block(k, k, fJk)

    fA = P*fJ*~P

    return fA

Application: computing $A^k$

First, we define our matrix function:

sage: var('k'); pow_sym(x) = x^k

Let's consider the OP's example, a $2\times 2$ matrix with one Jordan block of size $2$:

sage: A = matrix(QQ, [[2, -1], [1,  0]])

This matrix is not diagonalizable.

sage: A.is_diagonalizable()
sage: False

Calling our function,

sage: matrix_function_Jordan(A, pow_sym)

gives $\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} k + 1 & -k \\ k & -k + 1 \end{array}\right)$.

Pitfalls

A limitation of this approach is that we need the Jordan form. Notice that it is only implemented for exact rings (the Jordan form is unstable for inexact rings). Moreover, the spectrum should belong to the same ring. Consider for instance:

sage: A = matrix(QQ, [[0,4,1],[-1,1,5],[2,0,-89]]);
sage: [J, P] = A.jordan_form(transformation=True)

gives: RuntimeError: Some eigenvalue does not exist in Rational Field.

This is not a piece of cake for WolframAlpha either: we get Standard computation time exceeded...

edit flag offensive delete link more

Comments

2

Thanks for this good answer ! I have some comments and improvements, but they are too big to enter as a comment so i made a new answer. On this problem, Sage shows a better behaviour than WolframAlpha ;)

tmonteil gravatar imagetmonteil ( 2016-11-20 22:06:12 +0100 )edit

What answer shall I choose as correct? Both are correct.

Thrash gravatar imageThrash ( 2016-11-22 14:46:42 +0100 )edit

Don't worry about that, i am happy that @mforets get the karma.

tmonteil gravatar imagetmonteil ( 2016-11-22 17:58:18 +0100 )edit

Note that this answer is now not necessary, since the other answer shows how to do it in Sage itself! See here.

kcrisman gravatar imagekcrisman ( 2018-03-19 18:28:30 +0100 )edit
4

answered 2016-11-19 23:15:54 +0100

castor gravatar image

In many cases the following works:

A=matrix(SR,[[1,2],[2,1]])
D,P=A.eigenmatrix_right()
n=var('n')
An=P*matrix(SR,[[D[0,0]^n,0],[0,D[1,1]^n]])*P.inverse()
An

Here one obtains An as follows:

[1/2*3^n + 1/2*(-1)^n 1/2*3^n - 1/2*(-1)^n]
[1/2*3^n - 1/2*(-1)^n 1/2*3^n + 1/2*(-1)^n].

It does not work if the given matrix is not similar to a diagonal matrix.

edit flag offensive delete link more

Comments

Thanks, but unfortunately your method does not work in my case. I cannot imagine that the mighty Sage is not able to manage such easy calculations. Where are the Sage experts?

Thrash gravatar imageThrash ( 2016-11-20 18:17:24 +0100 )edit

Well, this is not so bad, as it shows us the direction to look at, since Jordan form can be seen as a generalization of diagonalization !

tmonteil gravatar imagetmonteil ( 2016-11-20 22:39:05 +0100 )edit

You are right, of course.

Thrash gravatar imageThrash ( 2016-11-22 13:26:34 +0100 )edit
4

answered 2016-11-20 21:53:27 +0100

tmonteil gravatar image

updated 2017-03-06 01:49:55 +0100

EDIT : this feature should be soon part of Sage, see trac ticket 22523 !

Let me complement @mforets answer.

First, we can bypass the pitfall by working in the field of algebraic numbers, QQbar, which is both exact and algebraically closed:

sage: A = matrix(QQ, [[2,1],[1,1]])
sage: matrix_function_Jordan(A, pow_sym)
RuntimeError: Some eigenvalue does not exist in Rational Field.

But:

sage: A = A.change_ring(QQbar)
sage: matrix_function_Jordan(A, pow_sym)
[0.7236067977499790?*2.618033988749895?^k + 0.2763932022500211?*0.3819660112501051?^k 0.4472135954999580?*2.618033988749895?^k - 0.4472135954999580?*0.3819660112501051?^k]
[0.4472135954999580?*2.618033988749895?^k - 0.4472135954999580?*0.3819660112501051?^k 0.2763932022500211?*2.618033988749895?^k + 0.7236067977499790?*0.3819660112501051?^k]

Second, you may not be happy with such a representation of the result, whose entries belong to the symbolic ring bundled with algerbraic numbers (written in a non-symbolic form).

However, some algebraic numbers have a symbolic representation by radicals. So we can use that representation of algebraic entries of the jordan form before mixing them with symbolic expressions. Let me propose the following change in @mforets code (my comments begin with ##):

def matrix_function_Jordan(A, f):

    # returns jordan matrix J and invertible matrix P such that A = P*J*~P
    ## We change the matrix into a matrix on the field of algebraic numbers
    [J, P] = A.change_ring(QQbar).jordan_form(transformation=True);

    fJ = zero_matrix(SR, J.ncols())
    num_Jordan_blocks = 1+len(J.subdivisions()[0])
    fJ.subdivide(J.subdivisions());

    for k in range(num_Jordan_blocks):

        # get Jordan block Jk
        Jk = J.subdivision(k, k)

        # dimension of Jordan block Jk
        mk = Jk.ncols();

        fJk = zero_matrix(SR, mk, mk);

        # compute the first row of f(Jk)
        ## Before applying a symbolic function to the coefficients of J, we change them into symbolic expressions 
        vk = [f.derivative(x, i)(Jk[i][i].radical_expression())/factorial(i) for i in range(mk)]

        # insert vk into each row (above the main diagonal)
        for i in range(mk):
            row_Jk_i = vector(SR, zero_vector(SR, i).list() + vk[0:mk-i])
            fJk.set_row(i, row_Jk_i)

        fJ.set_block(k, k, fJk)

    ## We change the entries of P and P^-1 into symbolic expressions
    Psym = P.apply_map(AlgebraicNumber.radical_expression)
    Psyminv = (~P).apply_map(AlgebraicNumber.radical_expression)
    fA = Psym*fJ*Psyminv

    return fA

Now, we have:

sage: A = matrix(QQ, [[2,1],[1,1]])
sage: matrix_function_Jordan(A, pow_sym)
 [                            1/10*(1/2*sqrt(5) + 3/2)^k*(sqrt(5) + 5) - 1/10*(-1/2*sqrt(5) + 3/2)^k*(sqrt(5) - 5)                                           1/5*sqrt(5)*(1/2*sqrt(5) + 3/2)^k - 1/5*sqrt(5)*(-1/2*sqrt(5) + 3/2)^k]
 [1/20*(1/2*sqrt(5) + 3/2)^k*(sqrt(5) + 5)*(sqrt(5) - 1) + 1/20*(-1/2*sqrt(5) + 3/2)^k*(sqrt(5) + 1)*(sqrt(5) - 5)             1/10*sqrt(5)*(-1/2*sqrt(5) + 3/2)^k*(sqrt(5) + 1) + 1/10*sqrt(5)*(1/2*sqrt(5) + 3/2)^k*(sqrt(5) - 1)]

Typeset:

$\left(\begin{array}{rr} \frac{1}{10} {\left(\frac{1}{2} \sqrt{5} + \frac{3}{2}\right)}^{k} {\left(\sqrt{5} + 5\right)} - \frac{1}{10} {\left(-\frac{1}{2} \sqrt{5} + \frac{3}{2}\right)}^{k} {\left(\sqrt{5} - 5\right)} & \frac{1}{5} \sqrt{5} {\left(\frac{1}{2} \sqrt{5} + \frac{3}{2}\right)}^{k} - \frac{1}{5} \sqrt{5} {\left(-\frac{1}{2} \sqrt{5} + \frac{3}{2}\right)}^{k} \\ \frac{1}{20} {\left(\frac{1}{2} \sqrt{5} + \frac{3}{2}\right)}^{k} {\left(\sqrt{5} + 5\right)} {\left(\sqrt{5} - 1\right)} + \frac{1}{20} {\left(-\frac{1}{2} \sqrt{5} + \frac{3}{2}\right)}^{k} {\left(\sqrt{5} + 1\right)} {\left(\sqrt{5} - 5\right)} & \frac{1}{10} \sqrt{5} {\left(-\frac{1}{2} \sqrt{5} + \frac{3}{2}\right)}^{k} {\left(\sqrt{5} + 1\right)} + \frac{1}{10} \sqrt{5} {\left(\frac{1}{2} \sqrt{5} + \frac{3}{2}\right)}^{k} {\left(\sqrt{5} - 1\right)} \end{array}\right)$

The function also works with matrix(QQ, [[0,4,1],[-1,1,5],[2,0,-89]]) but the result is so huge that your browser will not like it:

$\left(\begin{array}{rrr} -\frac{1}{106517166} {\left(53258583 {\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{-1154521 i \sqrt{3} + 1154521}{{\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}}} - 35505722\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} - \frac{1}{106517166} {\left(53258583 {\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{1154521 i \sqrt{3} + 1154521}{{\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}}} - 35505722\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} + \frac{1}{53258583} {\left({\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} + \frac{8005}{9 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(53258583 {\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}} + \frac{1154521}{{\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}}} + 17752861\right)} & -\frac{1}{319551498} {\left(159775749 {\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{2 {\left(32133662 i \sqrt{3} - 32133662\right)}}{{\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}}}\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} - \frac{1}{319551498} {\left(159775749 {\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{2 {\left(-32133662 i \sqrt{3} - 32133662\right)}}{{\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}}}\right)} {\left({\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} + \frac{8005}{9 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} + \frac{1}{159775749} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(159775749 {\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}} - \frac{64267324}{{\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}}}\right)} & -\frac{1}{319551498} {\left(159775749 {\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-188329 i \sqrt{3} + 188329}{{\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}}}\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} - \frac{1}{319551498} {\left(159775749 {\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{188329 i \sqrt{3} + 188329}{{\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}}}\right)} {\left({\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} + \frac{8005}{9 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} + \frac{1}{159775749} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(159775749 {\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}} - \frac{188329}{{\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}}}\right)} \\ \frac{1}{9394814041200} {\left(53258583 {\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{-1154521 i \sqrt{3} + 1154521}{{\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}}} - 35505722\right)} {\left(44100 {\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{188329 i \sqrt{3} + 188329}{{\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}}} - 194460\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} - \frac{1}{4697407020600} {\left(53258583 {\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{1154521 i \sqrt{3} + 1154521}{{\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}}} - 35505722\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(44100 {\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}} + \frac{188329}{{\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}}} + 97230\right)} - \frac{1}{4697407020600} {\left(44100 {\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{-188329 i \sqrt{3} + 188329}{{\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}}} - 194460\right)} {\left({\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} + \frac{8005}{9 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(53258583 {\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}} + \frac{1154521}{{\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}}} + 17752861\right)} & \frac{1}{28184442123600} {\left(159775749 {\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{2 {\left(32133662 i \sqrt{3} - 32133662\right)}}{{\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}}}\right)} {\left(44100 {\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{188329 i \sqrt{3} + 188329}{{\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}}} - 194460\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} + \frac{1}{28184442123600} {\left(44100 {\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{-188329 i \sqrt{3} + 188329}{{\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}}} - 194460\right)} {\left(159775749 {\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{2 {\left(-32133662 i \sqrt{3} - 32133662\right)}}{{\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}}}\right)} {\left({\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} + \frac{8005}{9 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} + \frac{1}{7046110530900} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(44100 {\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}} + \frac{188329}{{\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}}} + 97230\right)} {\left(159775749 {\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}} - \frac{64267324}{{\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}}}\right)} & \frac{1}{28184442123600} {\left(159775749 {\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-188329 i \sqrt{3} + 188329}{{\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}}}\right)} {\left(44100 {\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{188329 i \sqrt{3} + 188329}{{\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}}} - 194460\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} + \frac{1}{28184442123600} {\left(44100 {\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{-188329 i \sqrt{3} + 188329}{{\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}}} - 194460\right)} {\left(159775749 {\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{188329 i \sqrt{3} + 188329}{{\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}}}\right)} {\left({\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} + \frac{8005}{9 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} + \frac{1}{7046110530900} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(44100 {\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}} + \frac{188329}{{\left(\frac{1}{1225} \sqrt{2536123} \sqrt{7} + \frac{87716917}{9261000}\right)}^{\frac{1}{3}}} + 97230\right)} {\left(159775749 {\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}} - \frac{188329}{{\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}}}\right)} \\ \frac{1}{2348703510300} {\left(11025 {\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{16066831 i \sqrt{3} + 16066831}{{\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}}} + 841260\right)} {\left(53258583 {\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{1154521 i \sqrt{3} + 1154521}{{\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}}} - 35505722\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} - \frac{1}{1174351755150} {\left(53258583 {\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{-1154521 i \sqrt{3} + 1154521}{{\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}}} - 35505722\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(11025 {\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}} + \frac{16066831}{{\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}}} - 420630\right)} - \frac{1}{1174351755150} {\left(11025 {\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{-16066831 i \sqrt{3} + 16066831}{{\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}}} + 841260\right)} {\left({\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} + \frac{8005}{9 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(53258583 {\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}} + \frac{1154521}{{\left(\frac{14048645297}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{3668486}{479327247}\right)}^{\frac{1}{3}}} + 17752861\right)} & \frac{1}{7046110530900} {\left(11025 {\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{-16066831 i \sqrt{3} + 16066831}{{\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}}} + 841260\right)} {\left(159775749 {\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{2 {\left(-32133662 i \sqrt{3} - 32133662\right)}}{{\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}}}\right)} {\left({\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} + \frac{8005}{9 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} - \frac{1}{3523055265450} {\left(159775749 {\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{2 {\left(32133662 i \sqrt{3} - 32133662\right)}}{{\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}}}\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(11025 {\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}} + \frac{16066831}{{\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}}} - 420630\right)} - \frac{1}{3523055265450} {\left(11025 {\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{16066831 i \sqrt{3} + 16066831}{{\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}}} + 841260\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(159775749 {\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}} - \frac{64267324}{{\left(\frac{515211235568}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{7608369}\right)}^{\frac{1}{3}}}\right)} & \frac{1}{7046110530900} {\left(11025 {\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} + \frac{-16066831 i \sqrt{3} + 16066831}{{\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}}} + 841260\right)} {\left(159775749 {\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{188329 i \sqrt{3} + 188329}{{\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}}}\right)} {\left({\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} + \frac{8005}{9 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} - \frac{1}{3523055265450} {\left(159775749 {\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-188329 i \sqrt{3} + 188329}{{\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}}}\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(i \sqrt{3} + 1\right)} - \frac{-8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(11025 {\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}} + \frac{16066831}{{\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}}} - 420630\right)} - \frac{1}{3523055265450} {\left(11025 {\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} + \frac{16066831 i \sqrt{3} + 16066831}{{\left(\frac{1}{3675} \sqrt{2536123} \sqrt{7} - \frac{64401404446}{1157625}\right)}^{\frac{1}{3}}} + 841260\right)} {\left(-\frac{1}{2} {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}} {\left(-i \sqrt{3} + 1\right)} - \frac{8005 i \sqrt{3} + 8005}{18 {\left(\frac{2}{3} \sqrt{17752861} - \frac{720217}{27}\right)}^{\frac{1}{3}}} - \frac{88}{3}\right)}^{k} {\left(159775749 {\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}} - \frac{188329}{{\left(\frac{87716917}{21580961113270008463041} \sqrt{114184979435291050069} - \frac{40}{2536123}\right)}^{\frac{1}{3}}}\right)} \end{array}\right)$

edit flag offensive delete link more

Comments

Thanks @tmonteil for sharing this very interesting improvement!

mforets gravatar imagemforets ( 2016-11-20 23:43:27 +0100 )edit

Very great! Thanks @tmonteil and @mforets!

Thrash gravatar imageThrash ( 2016-11-22 14:05:42 +0100 )edit

Great answer so far, but is there a way to deal with matrices containing non algebraic numbers like pi? What about {{pi,-1},{1,0}}^k?

Thrash gravatar imageThrash ( 2016-11-22 14:37:19 +0100 )edit

@Tommy Angelo: Notice that such matrix can be dealt with the original matrix_function_Jordan(A, f) but with A = matrix(SR, [[pi, -1],[1, 0]]) (just use SR instead of QQ). My observation is that although this trick works quite generally (even so when the matrix has complex eigenvalues), the quality of the answer by @tmonteil's approach will be far better than using "plain" SR (and with wolframalpha, as you can check with some toy examples). Here by quality I mean simplified formulas (as well as a smaller computational time), so this is crucial in practice.

mforets gravatar imagemforets ( 2016-11-22 18:58:05 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-11-19 17:21:33 +0100

Seen: 3,148 times

Last updated: Mar 06 '17