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