import numpy as np
import matplotlib.pyplot as plt

A= 1
w=6.8
c=1

def onde(x,t):                                # Fonction d'onde
    return(A*np.cos(w*t)*np.cos(w*x/c))
    
x=np.linspace(0,5,1000)

for t in np.arange(0,2,0.025):

    plt.clf()
    plt.axis([0,5,-1.5,1.5])
    plt.xlabel('abscisse x')
    plt.ylabel("fonction d'onde s")  
    plt.plot(x,onde(x,t))
    for k in range(0,11):
        plt.plot((k+0.5)*3.1416*c/w,onde((k+0.5)*3.1416*c/w,t),'or')   # Tracé des noeuds
        plt.plot(k*3.1416*c/w,onde(k*3.1416*c/w,t),'og')               # Tracé des ventres
    plt.grid()
    plt.pause(0.01)
