tinycodinglm / math /math-000.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 15)
b27bfb3 verified
|
Raw History Blame
1.42 kB
opencode trace
System You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing c...

You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies.

User

Explain the key concepts of linear algebra in math, with concrete details and common pitfalls. Include a runnable code example with its expected output.

Assistant

An eigenvalue λ of matrix A satisfies A·v = λ·v for nonzero vector v.

python
import numpy as np

A = np.array([[4, 2], [1, 3]])
eigenvalues, eigenvectors = np.linalg.eig(A)
print('Eigenvalues:', eigenvalues)
print('Eigenvectors:')
print(eigenvectors)

For A = [[4,2],[1,3]], the characteristic polynomial is
λ² - 7λ + 10 = 0, giving λ₁=5, λ₂=2.

The eigenvector for λ=5 is [2,1]ᵀ and for λ=2 is [1,−1]ᵀ.

Key properties:

  • trace(A) = sum of eigenvalues
  • det(A) = product of eigenvalues
  • A is diagonalizable if it has n linearly independent eigenvectors