# L = 4, 2a = 4, a = 2
norma = integral((2**2 - x**2)*(2**2 - x**2),x,-2,2)
print(norma)
normb = integral(sin(pi*x)*sin(pi*x),x,-1,1)
print(normb)
functie_even(x,n,a) = (a)**(-1/2)*sin((n)*pi*x/(2*a))
functie_oneven(x,n,a) = (a)**(-1/2)*cos((n)*pi*x/(2*a))
f1(x) = piecewise([[(-4,-2),0], [[-2,2],functie_oneven(x,1,2)], [(2,4),0] ] )
f2a(x) = piecewise([[(-4,-2),0], [[-2,2],functie_even(x,2,2)], [(2,4),0]])
f1b(x) = piecewise([[(-4,-2),0], [[-2,2],functie_oneven(x,3,2)], [(2,4),0] ] )
f2(x) = piecewise([[(-4,-2),0], [[-2,2],functie_even(x,4,2)], [(2,4),0]])
f3(x) = piecewise([[(-4,-2),0], [[-2,2],(2**2 - x**2)/sqrt(norma)],[(2,4),0]])
f4(x) = piecewise([[(-4,-1),0],[[-1,1],sin(pi*x)/sqrt(normb)],[(1,4),0]])
g = Graphics()
g = plot( f1(x), (x,-4, 4),color='green',linestyle="-",legend_label='functie n=1' )
g += plot (f2a(x), (x,-4, 4), color= 'green',linestyle="--", legend_label = 'functie n=2' )
g += plot (f1b(x), (x,-4, 4), color= 'green',linestyle="-.", legend_label = 'functie n=3' )
g += plot (f2(x), (x,-4, 4), color= 'green', linestyle=":",legend_label = 'functie n=4' )
g += plot (f3(x), (x,-4, 4), color= 'blue', legend_label = 'trial functie 1')
g += plot (f4(x), (x,-4,4), color='red', legend_label= 'trial functie 2')
g.show()