Below is a script illustrating a possible solution:
Rene Brun
{
gROOT->Reset();
TFile f("hsimple.root"); //assume a file with histogram named hpx
Int_t ncx = hpx->GetNbinsX();
TH1F hnew = *hpx; //copy hpx to hnew
hnew.Reset();
TFormula f1("f1","x*x*x");
for (Int_t bin=1;bin<=ncx;bin++) { //fill hnew with function values
Float_t x = hnew.GetBinCenter(bin);
hnew.Fill(x, f1.Eval(x));
}
TH1F hresult = hnew*(*hpx); //make result histogram
//you could also do directly
TH1F hresult = h1 -hnew*(*hpx);
hresult.Draw();
}