You will multiply matrices with plain Python, raise a matrix to a power, and test the formula
for many values of . The lesson proves it by induction.
The idea. A matrix is a list of two rows, such as [[3, -4], [1, -1]]. The entry in row i and column j of a product is the sum of P[i][t] * Q[t][j] over t = 0, 1.
Your tasks.
mult(P, Q). Return the product of two matrices.power(A, n). Start from the identity matrix [[1, 0], [0, 1]] and multiply by A exactly n times.formula(n). Return the matrix of the formula above.Run your code once to unlock the worked solution.
Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…