Numpy's matrix_power function giving wrong results for large exponents [duplicate]
问题 This question already has an answer here : Numpy matrix exponentiation gives negative value (1 answer) Closed 2 years ago . I'm working on an implementation of the Fibonacci sequence in Numpy using the Q-Matrix method. The results are fine up till n = 47. At this point, the matrix_power function is returning incorrect results. Any explanation about why this is happening? import numpy def fibonacci(n): qmatrix = numpy.matrix([[1, 1], [1, 0]]) (a,b,c,d) = numpy.linalg.matrix_power(qmatrix,n)