def solve(y0,h,T,theta):
A = np.matrix([[-100.0, 1.0], [0.0, -0.1]])
A1 = np.eye(2) - h*theta*A
A1 = np.linalg.inv(A1)
A2 = np.eye(2) + (1.0-theta)*h*A
M = A1.dot(A2)
N = int(T/h)
y = np.ndarray((N,2))
t = np.zeros(N)
y[0,:]=y0
t[0] = 0.0
for i in range(N-1):
y[i+1,:] = M.dot(y[i,:])
t[i+1] = t[i] + h
plt.figure(figsize=(9,4))
plt.subplot(1,2,1)
plt.plot(t,y[:,0])
plt.xlabel('t')
plt.title('First component')
plt.subplot(1,2,2)
plt.plot(t,y[:,1])
plt.xlabel('t')
plt.title('Second component')
# Initial condition
y0 = np.array([10.0/999.0,1.0])
# Final time
T = 25.0