% Returns the time derivative of the system of differential equations.
function deriv = discreteVector(t, y)
m = size(y, 1);
dx = 1 / (m + 1);

deriv = zeros(m, 1);
deriv(1) = (y(2) + leftBoundary(t) - 2 * y(1)) / (dx * dx) + g(dx, y(1));
deriv(m) = (y(m - 1) + rightBoundary(t) - 2 * y(m)) / (dx * dx) + g(m * dx, y(m));
for i = 2:(m - 1)
    deriv(i) = (y(i - 1) + y(i + 1) - 2 * y(i)) / (dx * dx) + g(i * dx, y(i));
end