a1=-3; a2=-2.5;a3=-1.5; a4=-0.5;a5=0.5; a6=1.5; a7=2.5;a8=3; y1=1; y2=0; y3=2; y4=3; y5=3; y6=1; y7=-2; y8=4 P(x) = (x-a1)*(x-a2)*(x-a3)*(x-a4)*(x-a5)*(x-a6)*(x-a7)*(x-a8) P1(x) = (x-a2)*(x-a3)*(x-a4)*(x-a5)*(x-a6)*(x-a7)*(x-a8) P2(x) = (x-a1)*(x-a3)*(x-a4)*(x-a5)*(x-a6)*(x-a7)*(x-a8) P3(x) = (x-a1)*(x-a2)*(x-a4)*(x-a5)*(x-a6)*(x-a7)*(x-a8) P4(x) = (x-a1)*(x-a2)*(x-a3)*(x-a5)*(x-a6)*(x-a7)*(x-a8) P5(x) = (x-a1)*(x-a2)*(x-a3)*(x-a4)*(x-a6)*(x-a7)*(x-a8) P6(x) = (x-a1)*(x-a2)*(x-a3)*(x-a4)*(x-a5)*(x-a7)*(x-a8) P7(x) = (x-a1)*(x-a2)*(x-a3)*(x-a4)*(x-a5)*(x-a6)*(x-a8) P8(x) = (x-a1)*(x-a2)*(x-a3)*(x-a4)*(x-a5)*(x-a6)*(x-a7) dP(x) = P1(x)+ P2(x)+ P3(x)+ P4(x)+ P5(x) + P6(x)+ P7(x)+ P8(x) set xrange [a1-0.5:a8+0.5] set arrow from a1,0 to a1,y1 nohead set arrow from a2,0 to a2,y2 nohead set arrow from a3,0 to a3,y3 nohead set arrow from a4,0 to a4,y4 nohead set arrow from a5,0 to a5,y5 nohead set arrow from a6,0 to a6,y6 nohead set arrow from a7,0 to a7,y7 nohead set arrow from a8,0 to a8,y8 nohead plot P(x),dP(x),0 pause -2 "Aperte enter para continuar ou terminar " f(x) = y1*P1(x)/dP(a1) + y2*P2(x)/dP(a2) + y3*P3(x)/dP(a3) +\ y4*P4(x)/dP(a4) + y5*P5(x)/dP(a5)+\ y6*P6(x)/dP(a6) + y7*P7(x)/dP(a7)+y8*P8(x)/dP(a8) set title "Polinomio de Lagrange interpolando pontos do plano" ## set term postscript portrait color enhanced print "Polinomio de Lagrange interpolando pontos do plano" ## set output "exer05.01.03.eps" plot f(x),0 pause -2