import numpy as np
import matplotlib.pyplot as plt
from scipy import integrate
from scipy import special

pi = np.pi
x = np.arange(0,1,0.01)
L = len(x)
# print(x)


def f0(t):
    return [t,np.zeros(len (t))]

def t_vect(t):
    return [ np.ones(len (t)) , np.zeros(len (t)) ]

def n_vect(t):
    return [ np.zeros(len (t)) , np.ones(len (t))  ]
"""
def f0(t):
    return [ np.cos(2*pi*t), np.sin(2*pi*t)]

def t_vect(t):
    return [ -1*np.sin(2*pi*t) , np.cos(2*pi*t) ]

def n_vect(t):
    return [ -1*np.cos(2*pi*t) , -1*np.sin(2*pi*t)  ]
"""
graphe_f0 = f0(x)

N = 4
a = 1
r = 1/(special.jv(0,a))
#definition de Gamma

gamma1 = lambda x : np.cos( a*np.cos(2*pi*x)) - special.jv(0,a)
gamma2 = lambda x : np.sin( a*np.cos(2*pi*x))

def Gamma_1(u):
    return integrate.quad(gamma1 , 0, u)[0]
def Gamma_2(u):
    return integrate.quad(gamma2 , 0, u)[0]
#print( Gamma_1(0.1))
G1 = np.zeros( L )
G2 = np.zeros( L )
for i in  range( L):
    G1[i] = Gamma_1(N*x[i])
    G2[i] = Gamma_2(N*x[i])


graphe_f1 = graphe_f0 + r*(1/N)*( G1*t_vect(x) + G2*n_vect(x) )

plt.plot( graphe_f0[0], graphe_f0[1] ) # color='navy'
plt.plot( graphe_f1[0], graphe_f1[1] )
plt.show()



