tinycodinglm / math /math-0176.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 16)
d517dc9 verified
|
Raw History Blame Contribute Delete
953 Bytes
opencode trace
System You are an expert mathematician and programmer.

You are an expert mathematician and programmer.

User

Explain matrix operations for programming

Assistant

Matrix mult: (AB){ij} = sum(A{ik}*B_{kj}). O(n^3).
Matrix exponentiation: A^n in O(n^3 log n) via binary exponentiation.

Fibonacci O(log n): [[1,1],[1,0]]^n = [[F(n+1),F(n)],[F(n),F(n-1)]].
General: linear recurrence a_n = c1a_{n-1}+...+cka_{n-k} uses k x k companion matrix.

Gaussian elimination O(n^3): solve Ax=b, find determinant. Row reduce to upper triangular, back-substitute.

Applications: linear recurrences, graph paths (A^k[i][j] = paths i to j length k), Markov chains, system of equations, determinant (matrix tree theorem).