TF1::GetMinimumX and GetMaximumX

hi all

i’m using ROOT version 5.27/06b and i have a TF1 defined in an x-range and would like to use the GetMinimumX and GetMaximumX functions to get that range. i see an unexpected behaviour: if i run the following macro:

// begin
#include “TF1.h”
#include

void test() {
TF1* f1 = new TF1(“test”, “[0] + [1]*x”, 20., 670.);
std::cout << "min: " << f1->GetMinimumX() << " max: " << f1->GetMaximumX() << std::endl;
}
//end

i would expect to get 20 and 670, instead it returns:

root [0] .L test.C+
root [1] test()
min: 26.5657 max: 26.5657

i have tried other functions and see different but still puzzling behaviours:

if i use the function: TF1* f1 = new TF1(“test”, “(1.22179*((1+(-0.000946228x))+(7.37821e-06(xx))))+(-4.8451e-08(x*(x*(x/(1+(0.0047976*x))))))”, 20., 670.);

i get them swapped:

root [0] .L test.C+
root [1] test()
min: 670 max: 20

am i doing something wrong, or have i misunderstood how the methods should work?

f

[quote]am i doing something wrong, or have i misunderstood how the methods should work?
[/quote]
both ::slight_smile:

First, in your first example, you must set the values of the parameters.
Then, you should read the documentation that says

Double_t TF1::GetMinimumX(Double_t xmin, Double_t xmax, Double_t epsilon, Int_t maxiter, Bool_t logx) const { // Returns the X value corresponding to the minimum value of the function // on the (xmin, xmax) interval

If you simply want to return the axis limits, use f1->GetXmin(), f1->GetXmax() respectively.

Rene

See: http://root.cern.ch/root/html/TF1.html#TF1:GetMinimumX and http://root.cern.ch/root/html/TF1.html#TF1:GetMaximumX
BTW. in your fist example, you need to set both parameters of your TF1:
TF1* f1 = new TF1(“test”, “[0] + [1]*x”, 20., 670.);
f1->SetParameter(0, value_first_parameter);
f1->SetParameter(1, value_second_parameter);