(a) To expand \((1 + 3x)^6\) up to the term in \(x^2\), we use the binomial theorem:
\((1 + 3x)^6 = \sum_{k=0}^{6} \binom{6}{k} (1)^{6-k} (3x)^k\)
Calculating the first three terms:
\(\text{Term in } x^0: \binom{6}{0} (1)^6 (3x)^0 = 1\)
\(\text{Term in } x^1: \binom{6}{1} (1)^5 (3x)^1 = 18x\)
\(\text{Term in } x^2: \binom{6}{2} (1)^4 (3x)^2 = 135x^2\)
Thus, the expansion up to \(x^2\) is \(1 + 18x + 135x^2\).
(b) To find the coefficient of \(x^2\) in \((1 - 7x + x^2)(1 + 3x)^6\), we consider the relevant terms:
1. \(x^2\) term from \((1 + 3x)^6\) is \(135x^2\).
2. \(x^1\) term from \((1 + 3x)^6\) is \(18x\), and multiplying by \(-7x\) from \((1 - 7x + x^2)\) gives \(-126x^2\).
3. \(x^0\) term from \((1 + 3x)^6\) is \(1\), and multiplying by \(x^2\) from \((1 - 7x + x^2)\) gives \(x^2\).
Adding these contributions: \(135x^2 - 126x^2 + x^2 = 10x^2\).
Therefore, the coefficient of \(x^2\) is 10.