If $x^3 + ax^2 -x + b$ has $\left(x - 2\right)$ as a factor and leaves a remainder $3$ when divided by $\left(x - 3\right)$, find $a$ and $b$.
Let $f \left(x\right) = x^3 + ax^2 -x + b$
$\because \;$ $\left(x - 2\right)$ is a factor of $f \left(x\right)$,
$\therefore \;$ by factor theorem $f \left(2\right) = 0$
Now, $\;$ $f \left(2\right) = 2^3 + a \times 2^2 - 2 + b = 8 + 4a -2 + b = 6 + 4a + b$
$\therefore \;$ $f \left(2\right) = 0$ $\implies$ $6 + 4a + b = 0$
i.e. $\;$ $4a + b = -6$ $\;\;\; \cdots \; (1)$
$\because \;$ $f \left(x\right)$ when divided by $\left(x - 3\right)$ leaves a remainder of $3$,
$\therefore \;$ by remainder theorem $f \left(3\right) = 3$
Now, $\;$ $f \left(3\right) = 3^3 + a \times 3^2 -3 + b = 27 + 9a -3 + b = 24 + 9a + b$
$\because \;$ $f \left(3\right) = 3$ $\implies$ $24 + 9a + b = 3$
i.e. $\;$ $9a + b = -21$ $\;\;\; \cdots \; (2)$
Solving equations $(1)$ and $(2)$ simultaneously gives
$5a = -15$ $\implies$ $a = -3$
and $\;$ $b = -6 - 4a = -6 -4 \times \left(-3\right) = 6$
$\therefore \;$ $a = -3, \; b = 6$