#include"TH1D.h" #include "TF1.h" double X[100]; double Y[100]; int n=10; //i nodi sono n+1 double fteorica(double x) { double y=(x*x*x)*cos(x); return y; } double Lagrange(double x, int i) { double y=1.; for(int j=0; jSetLineColor(kRed); ptfteorica->Draw(); X[0]=a; X[n]=b; double passo=(X[n]-X[0])/n; cout<< "al passo i=0, X="<SetLineColor(kBlue); pfinterpol->SetLineStyle(2); pfinterpol->Draw("same"); TF1 *resto= new TF1("rest","fteorica(x)-ginterpol(x)",a,b); TCanvas *c2=new TCanvas("c2","c2", 800,600); resto->Draw(); }