Cannot find function address

I am trying to launch a macro

TF1 *test(float a, float b) {
   crap = new TF1("crap","([0]*sin(x))  + (TMath::E()*[1]", 0,b,2);
   crap ->SetParameters(a,3);
}

with this error
Error in TF1::TF1: can not find any function at the address 0x837407c. This function requested for crap

Hi,

When using a formula you should not (can not!) also expressed the number of parameters as an argument (this makes the compiler use the wrong constructor). Simply use:crap = new TF1("crap","([0]*sin(x)) + (TMath::E()*[1])", 0,b);

Cheers,
Philippe.