SharedTaller para el segundo previo.sagewsOpen in CoCalc
#FUNCIÓN PRINCIPAL

t=var('t')
h1(t)=(11*((t)^2)/4)+3;h2(t)=(-2*(t)^2)+4
f=piecewise([[(-pi,0),h1(t)],[(0,pi),h2(t)]])

uta=plot(f(t),(t,-pi,pi))

uta

w1(t)=sin(t)
w2(t)=sin(2*t)
w3(t)=sin(3*t)
s=integral(w1(t),t,0,pi)
s
s1=integral(w2(t),t,0,pi)
s1
s2=integral(w3(t),t,0,pi)
s2

k1=integral(w1(t)*h1(t),t,-pi,0)+integral(w1(t)*h2(t),t,0,pi)
k2=integral(w2(t)*h1(t),t,-pi,0)+integral(w2(t)*h2(t),t,0,pi)
k3=integral(w3(t)*h1(t),t,-pi,0)+integral(w3(t)*h2(t),t,0,pi)
pi 0 0
nor=integral((w1(t))^2,t,-pi,pi)
nor
pi
nor1=integral((w2(t))^2,t,-pi,pi)
nor1
pi
theta1(t)=k1/nor*w1(t)
theta2(t)=k1/nor*w1(t)+k2/nor*w2(t)
theta3(t)=k1/nor*w1(t)+k2/nor*w2(t)+k3/nor*w3(t)
uta1=plot(theta1(t),(t,-pi,pi),color='yellow')
uta2=plot(theta2(t),(t,-pi,pi),color='green')
uta3=plot(theta3(t),(t,-pi,pi),color='purple')
mett=uta+uta1+uta2+uta3
#3(a).LA FUNCION PRINCIPAL ES LA AZUL
#la mas cercana es w1 porque la funcion principal tiene valor de 29.74 al integrarla y al integrar las demas el mayor numero fue el de w1 y ya que la diferencia entre la principal y esta ultima va a ser menor esto quiere decir que es la mas cercana
mett.show()

w1(t)=1
w2(t)=cos(t)
w3(t)=cos(3*t)
w4(t)=cos(5*t)

s3=integral(w1(t),t,0,pi)
s3
s4=integral(w2(t),t,0,pi)
s4
s5=integral(w3(t),t,0,pi)
s5

k1=integral(w1(t)*h1(t),t,-pi,0)+integral(w1(t)*h2(t),t,0,pi)
k2=integral(w2(t)*h1(t),t,-pi,0)+integral(w2(t)*h2(t),t,0,pi)
k3=integral(w3(t)*h1(t),t,-pi,0)+integral(w3(t)*h2(t),t,0,pi)
k4=integral(w4(t)*h1(t),t,-pi,0)+integral(w4(t)*h2(t),t,0,pi)

nor=integral((w1(t))^2,t,-pi,pi)

nor


theta1(t)=k1/nor*w1(t)
theta2(t)=k1/nor*w1(t)+k2/nor*w2(t)
theta3(t)=k1/nor*w1(t)+k2/nor*w2(t)+k3/nor*w3(t)
theta4(t)=k1/nor*w1(t)+k2/nor*w2(t)+k3/nor*w3(t)+k4/nor*w4(t)

uta1=plot(theta1(t),(t,-pi,pi),color='yellow')
uta2=plot(theta2(t),(t,-pi,pi),color='green')
uta3=plot(theta3(t),(t,-pi,pi),color='purple')
uta4=plot(theta4(t),(t,-pi,pi),color='red')

mett=uta+uta1+uta2+uta3+uta4

mett.show()
#3(b).LA FUNCION PRINCIPAL ES LA AZUL
#la mas cercana es w4
pi 0 0 2*pi

w1(t)=1
w2(t)=sin(t)
w3(t)=sin(2*t)
w4(t)=sin(3*t)
w5(t)=cos(t)
w6(t)=cos(3*t)
w7(t)=cos(5*t)


k1=integral(w1(t)*h1(t),t,-pi,0)+integral(w1(t)*h2(t),t,0,pi)
k2=integral(w2(t)*h1(t),t,-pi,0)+integral(w2(t)*h2(t),t,0,pi)
k3=integral(w3(t)*h1(t),t,-pi,0)+integral(w3(t)*h2(t),t,0,pi)
k4=integral(w4(t)*h1(t),t,-pi,0)+integral(w4(t)*h2(t),t,0,pi)
k5=integral(w5(t)*h1(t),t,-pi,0)+integral(w5(t)*h2(t),t,0,pi)
k6=integral(w6(t)*h1(t),t,-pi,0)+integral(w6(t)*h2(t),t,0,pi)
k7=integral(w7(t)*h1(t),t,-pi,0)+integral(w7(t)*h2(t),t,0,pi)


nor=integral((w1(t))^2,t,-pi,pi)

nor


theta1(t)=k1/nor*w1(t)
theta2(t)=k1/nor*w1(t)+k2/nor*w2(t)
theta3(t)=k1/nor*w1(t)+k2/nor*w2(t)+k3/nor*w3(t)
theta4(t)=k1/nor*w1(t)+k2/nor*w2(t)+k3/nor*w3(t)+k4/nor*w4(t)
theta5(t)=k1/nor*w1(t)+k2/nor*w2(t)+k3/nor*w3(t)+k4/nor*w4(t)+k5/nor*w5(t)
theta6(t)=k1/nor*w1(t)+k2/nor*w2(t)+k3/nor*w3(t)+k4/nor*w4(t)+k5/nor*w5(t)+k6/nor*w6(t)
theta7(t)=k1/nor*w1(t)+k2/nor*w2(t)+k3/nor*w3(t)+k4/nor*w4(t)+k5/nor*w5(t)+k6/nor*w6(t)+k7/nor*w7(t)


uta1=plot(theta1(t),(t,-pi,pi),color='yellow')
uta2=plot(theta2(t),(t,-pi,pi),color='green')
uta3=plot(theta3(t),(t,-pi,pi),color='purple')
uta4=plot(theta4(t),(t,-pi,pi),color='red')
uta5=plot(theta4(t),(t,-pi,pi),color='orange')
uta6=plot(theta4(t),(t,-pi,pi),color='brown')
uta7=plot(theta4(t),(t,-pi,pi),color='gold')




mett=uta+uta1+uta2+uta3+uta4+uta5+uta6+uta7

mett.show()
#3(c).LA FUNCIÓN MAS CERCANA ES LA AZUL

2*pi

#INTEGRAL DE LA FUNCIÓN PRINCIPAL.

s=integral(h1(t),t,-pi,0)+integral(h2(t),t,0,pi)
s
7*pi + 1/4*pi^3

nor2=integral((w3(t))^2,t,-pi,pi)
nor2
pi