Hi all,

I was wondering if it is possible to produce animations
like

http://www.math.uh.edu/~josic/nonautonomous/

with pylab ?

Further information is available in a recent paper
by K. Josic and R. Rosenbaum published in SIAM Review.
        
See http://dx.doi.org/10.1137/060677057

Cheers,
         Nils
from scipy.integrate import odeint
from scipy.linalg import eig
from pylab import plot, show, legend, xlabel, ylabel
from numpy import zeros, linspace, dot, sin, cos, exp
#
#   K. Josic, R. Rosenbaum
#   Unstable solutions of nonautonomous linear differential equations
#   SIAM Review Vol. 50 No. 3 (2008) pp. 570--584
#
def A(t):

    tmp = zeros((2,2),float)
    tmp[0,0] = -1-9*(cos(6*t))**2+12*sin(6*t)*cos(6*t)
    tmp[0,1] = 12*(cos(6*t))**2+9*sin(6*t)*cos(6*t)
    tmp[1,0] = -12*(sin(6*t))**2+9*sin(6*t)*cos(6*t)
    tmp[1,1] = -1-9*(sin(6*t))**2-12*sin(6*t)*cos(6*t)
    return tmp

def func(x,t):

    return dot(A(t),x)

x_0 = zeros(2,float) # Initial conditions
x_0[0] = -2.44
x_0[1] =  1.23

x_0[0] =  5.0  
x_0[1] =  0.0 

T = linspace(0,3,300)

x = odeint(func,x_0,T)
#
# Analytical solution of Vinograds example
#
y_1 =  exp(2*T)*(cos(6*T)+2*sin(6*T))+2*exp(-13*T)*(2*cos(6*T)-sin(6*T))  
y_2 =  exp(2*T)*(2*cos(6*T)-sin(6*T))-2*exp(-13*T)*(cos(6*T)+2*sin(6*T))  

plot(T,x[:,0])
plot(T,x[:,1])
plot(T,y_1,'r.')
plot(T,y_2,'g.')
xlabel(r'Time $t$[s]')
legend((r'$x_1$',r'$x_2$',r'$y_1$',r'$y_2$'))

for t in T:

   w, vr = eig(A(t))
   print vr[:,0], vr[:,1]

show()
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to