Time consuming calculation

Goodmorning everyboby,
I’m Domenico and I’m new of this forum.
I’ve installed Python and sympy in order to solve parametric matrices. Firstly I tested the software with sample cases, i.e. a 2 x 2 matrix, then I imput a 9 x 9 matrix and I asket the software to calculate the determinant. However, Python didn’t give me any result or error message. I don’t understand what appened. Is there a limit in the dimentions of the matrix?
Thankyou!

If Python “didn’t give me any result or error message”, what did it do?
It doesn’t help us to know what didn’t happen, we need to know what
actually happened.

My guess is that the calculation just didn’t finish, and you got sick
of waiting for the result and either used Ctrl-C to interrupt it or
closed the Python window, stopping the interpreter.

Calculating the determinant is hard. Depending on the method that
sympy uses, it could increase by the factorial of the matrix order.

So a 9x9 matrix could take approximately 181440 times longer than a 2x2
matrix. (That’s using the Laplace expansion method; other methods are
faster, but even the fastest known method has worse than quadratic
behaviour.) If the 2x2 matrix took 1 second to complete, the 9x9 matrix
would take two days.

Hopefully Sympy is a bit faster than that, but one way or another it is
going to be time consuming. I would absolutely expect calculating the
determinant of a 9x9 matrix to be slow. Exactly how slow is hard to
tell: it depends on the algorithm used by sympy, and the speed of your
computer.

Try gradually increasing the size of the matrix, and see how the time
increases:

  • 2x2
  • 3x3
  • 4x4
  • 5x5

You can time the operations with a function like this:

import timeit

def tester(matrix):
    t = timeit.default_timer()()
    d = sympy.determinant(matrix)  # or something like this?
    return timeit.default_timer() - t

If you post the first four or five times here, we may be able to help
you predict how long the 9x9 matrix will take.