import numpy as np
import matplotlib.pyplot as plt
import monedo as mo



VN=(1.3)**np.arange(10,32)
#a=np.floor((1.4)**np.arange(7,25))
VN=VN.astype(int)



def f(t,x):
    return 1/t

def y(t):
    return np.log(t)

err1=mo.erreur(mo.euler_all,f,1,2,0,VN,y)
err2=mo.erreur(mo.ptmilieu_all,f,1,2,0,VN,y)
err3=mo.erreur(mo.heun_all,f,1,2,0,VN,y)
err4=mo.erreur(mo.myrk4_all,f,1,2,0,VN,y)
p1, =plt.plot(VN,err1,'+')#,label='Euler')
p2, =plt.plot(VN,err2,'*')#label='Pt au milieu')
p3, =plt.plot(VN,err3,'o')#label='Heun')
p4, = plt.plot(VN,err4,'x')#label='Runge Kutta 4')
q1, = plt.plot(VN,1/VN,label="1/N")
q2, = plt.plot(VN,1/(VN**2))#,label="1/N^2")
q3, = plt.plot(VN,1/(VN**4))#,label="1/N^4")

l1 = plt.legend([p1 , p2, p3, p4], ["Euler", "Pt au milieu", "Heun", "Runge Kutta 4"],loc=3)
l2 = plt.legend([q1, q2, q3],["1/N", "1/N^2", "1/N^4"],loc=1)
plt.gca().add_artist(l1)
plt.xscale('log')
plt.yscale('log')
#plt.legend()
plt.show()
#a=np.floor((1.4)**np.arange(7,25))
#a.astype(np.int64)

