import math
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D

def sin(x) :
    return math.sin(x)

Pi=np.pi

def f(x):

    if x>Pi:
        return f(x-2*Pi)
    elif x<-Pi:
        return f(x+2*Pi)
    elif x<0:
        return -f(-x)
    elif x>Pi/2:
        return f(Pi-x)
    elif x>Pi/4:
        return 2*f(x/2)*np.sqrt(1-f(x/2)**2)
    else:
        return x-x**3/6+x**5/120-x**7/5040


def Trac1(): # "vrai" sinus
    X = np.arange(-10,20 , 0.001)
    print(len(X))
    Y = [ sin(x) for x in X ]
    plt.plot(X, Y)
    plt.show()

def Trac2(): # "mon" sinus
    X = np.arange(-10,20, 0.001)
    Y = [ f(x) for x in X ]
    plt.plot(X, Y)
    plt.show()

def Trac3():
    X = np.arange(-10,20, 0.001)
    Y= [ sin(x) for x in X ]
    Z = [ f(x) for x in X ]
    plt.plot(X, Y)
    plt.plot(X, Z)
    plt.show()

def Trac4():
    X = np.arange(-10,20, 0.001)
    Y= [ 10**6*(sin(x)-f(x)) for x in X ]
    plt.plot(X, Y)
    plt.show()


