#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
const double PI = 3.14159265358979;
int main() {
double b=2*3.1415926, n=6, x=0, y=0,q=0;
double masx[7], masy[7];
for (int i=0; i<=n; i++)
{
x=b/2+b/2*cos((2*i+1)*3.1415926/(2*(n+1)));
y=sin(x)*sin(x);
masx[i]=x;
cout<<"x= "<<masx[i];
masy[i]=y;
cout<<" y="<<masy[i]<<endl;
}
//-----------------
int H=12;
double l=1, x1;
for(int k=0; k<=H; k++)
{x1=b/2+b/2*cos((2*k+1)*3.1415926/(2*(H+1)));
for (int i=0; i<=n; i++)
{l=1;
for (int j=0; j<=n; j++)
{
if(i!=j)
l*=(x1-masx[j])/(masx[i]-masx[j]);
}
q+=masy[i]*l;
}
cout<<"x1="<<x1; cout<<" q="<<q<<endl; q=0;
}
//------------------------------
int p=12; // количетво точек
double node, g=masy[0], F, den;
for(int count=0; count<=p; count++)
{
node = b/2 + b/2 * cos( (2*count - 1) * PI / (2*p) );
for(int i=1;i<n;i++)
{
F=0;
for(int j=0;j<=i;j++)
{
den=1;
for(int k=0;k<=i;k++)
{
if (k!=j)
den*=(masx[j]-masx[k]);
}
F+=masy[j]/den;
}
for(int k=0;k<i;k++) F*=(node-masx[k]);
g+=F;
cout<<"node="<<node; cout<<" res="<<g<<endl; g=0;
}
}
return 0;
}