TF1 using formula vs. TF1 using real function

I tried to use an expression including TMath::BetaIncomplete in a TF1. For some reason the function did not behave as expected. And after some hours of debugging, I finally got this example, which illustrates what happened:

#include "TCanvas.h"
#include "TF1.h"
#include "TMath.h"

Double_t BetaFunc(Double_t *x, Double_t *p);

void functest()
  new TCanvas("func1","func1");
  TF1* func1 = new TF1("func1",
		       "TMath::BetaIncomplete(.5, x, 11-x )",

  new TCanvas("func2","func2");
  TF1* func2 = new TF1("func2",&BetaFunc,0.,10.,0);

Double_t BetaFunc( Double_t *x, Double_t *par)
  return TMath::BetaIncomplete(.5, x[0], 11-x[0]);

Both functions should be the same, but func2 is corretct while func1 is just wrong.

Why can’t I use TMath::BetaIncomplete in a formula string to define a function?

Cheers, J.

I do not understand what you are trying to do with TMath::BetaIncomplete.
The signature of thgis function is

The first argument being the variable, a and b two parameters.


this particular example is just to illustrate that there is a difference between the two way’s to declare the function. As far I can see the both methods should lead to the same function. Nevertheless if one executes the example script, the function plots (and TF1::Eval) differ for both functions. Did I miss a difference in the function definition? Why do the results differ?

Cheers, J.
functest.C (486 Bytes)

It looks like you did not read my mail carefully.


To answer you question precisely:
I want to draw TMath::BetaIncomplete as a function of e certain combination of parameters.

Combinations that are not too interesting from the mathematical point of view work as expected, if I define the function via the string:

TF1* func1 = new TF1("func1","TMath::BetaIncomplete(.5,x,5)",0.,20.)


TF1* func1 = new TF1("func1","TMath::BetaIncomplete(.5,x,x)",0.,20.)

What is the difference of my example to these examples?

Cheers, J.

PLEASE go back to my mail. Tmath::BetaIncomplete has 3 parameters
ONLY the first one is the variable x, the two others are parameters. It does not make any sense to declare BetaIncomplete(0.5,x,10-x)