jump to navigation

Guess the function! January 15, 2009

Posted by dorigo in mathematics, personal, physics, science.
Tags: ,

I have a problem today -actually I’ve fiddled with it for a couple of days now. So, since it does not involve particles (at least not directly), I figured I’d bounce it off the mathematically inclined among you: maybe I get an answer before I can figure my problem out by myself!

The problem is simple: find a functional form that can be a good fit, with suitable parameters, to the following graph:

(This is a residual of a Z lineshape fit to a relativistic Breit-Wigner function by the way, but you need not bother with these unnecessary details).

As you can see, we have a negative asymptote and a positive asymptote that have different values, and a central wiggling which has different “width” for the negative and positive component. I have been trying several combinations like f(x) = atan(h(x))*g(x), where g(x) is a gaussian and h(x) some kind of “warping factor” with a different slope in the negative and positive side (with respect to x=91)… But I am getting nowhere. I am sure there is somebody out there that has a good advice, so please shoot!

UPDATE: Marius suggests a function in the comments thread below. I thank him for his input, but as is, the function f(x)=A atan(x)+ B atan(x+C) +D does not work well: see the best fit below (parameters in the upper right legend are A,B,C,D as in the function suggested by Marius):

Maybe with suitable modifications this might work, though. Hmmmm…

UPDATE: Using the hint by Marius that the addition of another arctangent could account for the different height of the two asymptotes, I have cooked up a better fit:

This is better, but I am really not satisfied. The function has 11 degrees of freedom -which is not too troublesome since there are 300 points in the graph to fit anyway; but the function is UGLY:

p_o atan[(p_1-x) e^{-((x-p_3)/p_4)^2}] + p_5 atan[p_6(p_7-x)] + p_8 e^{-((x-p_9)/p_{10})^2}

Any further idea on how to improve it ?

Hmmm, and I should add that having 11 parameters is a curse for me, because what I am going to do after I have a reasonable functional form is to study the parameters as a function of Z rapidity (which modifies the original graph), and parameterize those 11 dependencies… I already have a headache!

UPDATE: Lubos makes a very good attempt with a simple ratio of polynomials in the comments thread, offering f(x) = p_0 ( x-p_1)/(p_2x^2 + p_3 x+p_4) (he even offers some eyeballed parameters). Nice try, but the problem is that the function seems to be very irregular. If one fits the center region, Lubos’ function obtains a good fit (see upper plot below); if one tries to extend the fit further out on the tails, however, the fit rapidly worsens (lower plot).

Despite the shortcomings, I think I will investigate some ways to fix the function offered by Lubos -it has the potential of describing with few parameters the whole shape, once tweaked a bit…

UPDATE: Lubos tried to mend himself the function he proposed above, by adding a hyperbolic tangent. The function fits better the whole range, but it still fails to catch the subtleties of the slopes… Here is a fit using his suggested parameters:

I think I will remove the hyperbolic tangent and work on some warping of the polynomial…

UPDATE: warping the x values above 91 GeV from Lubos’ polynomial with a function f(x)=-p_0+p_1 x +\sqrt{(p_1-1)^2 x^2 + p_0^2} seems to work. The result is below:

The fit is not extremely precise, but these are residuals from a Breit-Wigner, so I guess that the multiplication of this function by the original shape will give a more than adequate parametrization, for my goals. Next up is obtaining 50 different fits like the one above, one per each interval in Z rapidity from 0 to 5.0, and parametrizing each of the seven parameter of the fits…


1. marius - January 15, 2009

maybe $f(x) = A \atan(x) + B \atan(x+C) + D$ with
$-B > A > 0$

2. Massimiliano - January 15, 2009

I’m only a humble high-school student and I can’t help but… I’m curious: the fact that in the [60-90] range the original graph is clearly convex, whereas the suggested function is concave… is so irrelevant? Why?

3. Danny - January 15, 2009

I tried looking at the derivative and got, with suitable calibration, $f'(x)=(1/x)(e^{-(x-5)^{2}})(\arctan(x))$. Unfortunately the erf function makes an appearance and so I couldn’t integrate.

4. bob - January 15, 2009

Isn’t that the derivative of some sort of asymmetric gaussian?

5. dorigo - January 15, 2009

Massimiliano, a high-school student (if in the later years) should know the functions involved better than I do… Anyway, I do not understand your comment. The concavity depends on the value of the parameters, and the fit chooses them freely -in fact, Marius suggested a different ordering in size of A and B than what my fitter wants…

Danny, what function did you derive, the one given by Marius ? Where does the “5” in the gauss factor come from ?


6. dorigo - January 15, 2009

Hi Bob,

in a sense the answer is yes, but what can I do with that information ? I am indeed trying erfs and arctangents, but it is harder than it looks!


7. estraven - January 15, 2009

To me it looks like there’s a vertical asintote at x=91 (with both limits being minus infty). Could this be or it’s ruled out by physical reasons?

8. marius - January 15, 2009

if you compute $f(-infty) = -(\pi/2)(A+B) + D$. This is greater
than $f(+\infty) = (\pi/2)(A+B) +D$ because $A+B A > 0$.

Also, if $(A+B)^{2} + ABC^{2} < 0$ (meaning that $B$ has to be negative and $C$ is big enough)
then the function $f$ has a maximum followed by a minimum, as you need.

Take A=1, B=-2, C=1 and see what it looks like. The parameter D
moves the graph vertically, so it is not very important at this stage.

9. Massimiliano - January 15, 2009

Ok, I thought that the concavity could depend on the parameters but I couldn’t figure out their influence on the shape.

About knowing the functions involved… inverse trigonometric functions, at least at my school, are not studied as well as exponentials, gaussians, etc. But having studied them at school does not imply an ability in manipulating them… or in finding fits to graphs… but I’m a bit off topic 🙂

Anyway… good luck!

10. dorigo - January 15, 2009

Estraven, there is no asymptote… These are residuals with respect to a breit-wigner shape, and refer to the Z cross section at LHC. A negative asymptote would mean a negative cross section, which would be a funny thing -removing Z particles from the vacuum ?

Marius, I understand – but the function you propose just does not have enough features to match the data points. Anyway, you gave me an important input with the sum of the two atan() functions, and I am now using it… While I wait for some smarter idea!


11. singlino - January 15, 2009

I can’t help, but I beleive that there must be a book published somewhere, sometime, which has lots and lots of plots and their functions, something like a plot dictionary…..there are lots of integral tables for all kinds of integrals, there must be something similar for functions and their plots…..If you found smething like that please let us know


dorigo - January 15, 2009

Thanks singlino, I have a friend who uses mathematica, I’ll ask him.

Eirik, that sounds like a very good advice, but I guess I’ve long forgotten all my differential calculus capabilities 😦
To be fair, I probably could do it, but it looks like work and I am becoming lazy. Or as they say, “old dog learns no new tricks”…

12. singlino - January 15, 2009

hmmmm, just a thought, Mathematica has packages for data analysis and statistics, that functions library to find the best/simplest fit for the data, may be that would be the best solution if you are looking for the best fit with the smallest number of parameters

13. estraven - January 15, 2009

“there is no asymptote… These are residuals with respect to a breit-wigner shape”

So there is some physics in it after all :-).

14. Eirik - January 15, 2009

It looks like a derivative of a peak, probably cause it is a residual. Maybe it would be easier to find a function for the integral of this residual?

Another thing empirical people do, is to plot derivatives of different order to each other. If you find a simple relationship between some derivatives, you may then solve the resulting differential equation analytically and get your function.

15. Luboš Motl - January 15, 2009

What does it have to do with ARCTAN? Isn’t the function simply this?

-11*10^8*(x – 90)/(x^2 – 182 x + 8290)

Best, Lubos

16. Daniel de França MTd2 - January 15, 2009

Hi tommaso,

I cannot plot right now, but what you posted looks like a cubic equation, dumped by a gaussians and a constant :
g_a(x)= cubic_a(x)*exp(-cx^2)

f(x) = g_a + g_b + d

11 degrees of freedom.



17. Luboš Motl - January 15, 2009

Oh, I see, you also want other asymptotes, so it’s

-11.05121973*10^8*(x – 90)/(x^2 – 182 x + 8290) +
20*10^6*(1 – Tanh[(x – 90)/5])

Parameters: -11e8 normalization at the beginning (the rest of the figure is my birthday), 90 (which I believe is common in both brackets), 182, 8290, 20e6 normalization of the asymmetric twist.

Five parameters. I suppose that the asymptotic value at +infinity is zero.

18. Luboš Motl - January 15, 2009

Oh, sorry, i forgot the “5” parameter in the tanh, so it has six parameters. Because the asymptotic value at infinity is zero, “1” before tanh is not an adjustable parameter.

19. dorigo - January 15, 2009

Wait Lubos, you’re going too fast. Your polynomial was simple and I liked it, now these other functions are more complex…
I will now try adding the tanh part, but first let me play on with the simpler one.

Daniel, I’ll try plotting yours too.


20. dorigo - January 15, 2009

Daniel, nice try, but the cubic does not address the problem that the negative asymptote is higher than zero. Also, there just are too few degrees of freedom in the function to account for the slopes of the two bumps.


21. Daniel de França MTd2 - January 15, 2009

Just a remark, what I proposed is valid for something that tries to mimic a general cubic near (0,0). Aesteticaly speaking that looks like a cubic of the kind ax^3 +bx^2, so that give in the end 6 free parameters.

22. Daniel de França MTd2 - January 15, 2009

Sorry, I overlooked the different assymptotics. What I said will not work.

23. mfrasca - January 15, 2009

Hi Tommaso,

This one seems to fit the bill rather well


but I have got the values from your graph with engauge and so some error may enter. The fit has been done with Labfit, an internet downloaded tool and the errors on the coefficients are

SIGMAA = 0.42217386271E-04
SIGMAB = 0.97722520956E-05



24. dorigo - January 15, 2009

Marco, thank you for your hint. I think the fit does not catch the negative asymptote, which is higher than zero. Anyway tomorrow I will try working on this shape a bit more…


25. Daniel de França MTd2 - January 15, 2009

But wouldnt that spoil near 0? It goes too fast toward to 0. How about this one: (A*x^3 + B*x)*(exp(C^2))*(1/(1-exp(x))

that is

and where x=axix X + Dconstant.

26. Daniel de França MTd2 - January 15, 2009

Jut to be clear, in
x=axix X + Dconstant.

I use that to centralize…

Sorry if that is complicated, but looking at the funcition I see 3 different things. 2 different assymptotes, with constant values. It makes me remember the bose eistein solution. The dumping of the fluctuation near the center, by the gaussian. And the cubic function, or whatever that looks like.

27. Cormac O'Raifeartaigh - January 15, 2009

My first thought is that the curve looks like a typical derivative absorption signal you get from the lock-in amp in Electron Spin Resonance experiments (or similar techniques).

As I recall, the challenge of such traces for experimentalists is not so much a good fit, because there are many such fits. Instead, the challenge is to get the best fit using a minimum number of parameters, and parameters that make sense in the context of the physical origin of the signal (e.g. environment of the dangling bond). In short, I would venture that it’s a question of physics as well as mathematics as the shape is fairly simple…
Btw, it looks more Lorentzian than Gaussian to me, but it’s been a while….

28. milkshake - January 15, 2009

I am just an industry pharma chemist, with no experience in curve fitting (except maybe for simple log value plots of linearized stuff) but it seems to me that this kind of shape can be obtained by dividing two related asymptomatic functions one with another, provided that the function in denominator diverges faster and its values stay positive – I think squaring the denominator can do just that.

I suppose you can take an asymptotic function of a suitable shape, such as A+arctangent(x), and then divide it with a similar squared function, such as (B+C acrtang(x))^2

Best luck!

29. Juan - January 16, 2009

This looks much like the inverse of a time-reversed pulse out of a shaping amp, before fixing the pole zero. I would look up one of the many papers on analog filter theory, find the functional form and apply the two operations. A bit arduous, but you should end up with a good fit (and much less than 11 parameters).

30. Doug - January 16, 2009

Hi Tommaso,

Lubos probably has the best answer.

As you are “… obtaining 50 different fits like the one above, one per each interval in Z rapidity from 0 to 5.0, and parametrizing each of the seven parameter of the fits …”, I do begin to wonder if this may be some type of Polygamma Function .

dorigo - January 16, 2009

Hi Doug,
yes, Lubos gave me the best advice, and in fact I have now managed to fit all the different histograms with a family of curves using as a nucleus his polynomial, after translating it and warping it, and then multiplying it by a second order polynomial.

The polygamma function you point at might work, but today I finished some interpolations with the shape I have and I am satisfied with the result…


31. Doug - January 20, 2009

Hi Tomasso,

I stumbled across this Casio Calculator sqrt(keisan), for high presision calculation.

The Breit–Wigner is not present but the non-relativistic Cauchy distribution is.

I do not know if this website could help with your present graph, but this may be useful in the future since it seems to be very powerful with over 70 applications. It was last updated 9 JAN 2009.

dorigo - January 20, 2009

Hi Doug,

your comment is number 10000 here, congratulations 🙂

anyway, thank you for this link.

32. 10,000 comments « A Quantum Diaries Survivor - January 21, 2009

[…] internet, personal. Tags: blog, comments, statistics trackback Congratulations to Doug, who left comment number 10,000 on this blog yesterday.The number is subtracted of all the spam comments and of the extremely few […]

33. maarten boonekamp - January 21, 2009


I understand we should avoid talking physics here 🙂 but you would be faster and more reliable in coding just the photon-Z interference term, which is exactly what your curve is.

it is of this form:
– (x^2 – 91^2) / ((x^2 – 91^2)^2 + 91^2*2.5^2)
you could maybe let the 91 and 2.5 as free parameters.


dorigo - January 22, 2009

Hi Maarten,

the problem is that the shape you suggest fits well only the low-mass part, but it does not work on the high-mass part. It seems that the combination of QED and PDF effects makes it hard to parametrize it as a simple interference term…


34. Luboš Motl - January 27, 2009

Dear Tommaso, this is the first time I look at this post, since the day I wrote the idea essentially called the Pade approximation


I would have been unable to refine it as well as you did, using the tools I had. With Mathematica, you can do cool things. So for example, I stole your graph (image) and extracted the data points out of the image, trying to fit them myself.

The most difficult part was to get rid of the “false points” on the image that didn’t actually belong to the graph. But it could be a good idea for Wolfram to include some intelligent routines that could steal graphs (and temperature maps etc.) more directly, even though I have written some semi-helpful software to do this job.

35. Luboš Motl - January 27, 2009

Otherwise you (Tommaso) surely win the contest for the best description of a smooth step function.

I was so deformed by the arctan guesses that my tanh was the only improvement. You’re surely better. If I simplify, your smoothened step function is

step(x) = x / sqrt(1+x^2)

Well done, I didn’t get this one. 😉 Obviously, the function above would be more natural to appear in an actual theoretical calculation of such quantities.

Arctan seemed too far-fetched to me, but tanh was reasonable because it is really a ratio of functions like (exp(x)+1) which could appear in some thermal (Bose-Einstein) distributions etc. At any rate, yours is the most natural way to achieve the different asymptotes.

36. Luboš Motl - January 27, 2009

I meant Fermi-Dirac, not Bose-Einstein, sorry.

By the way, when one accepts that the (much more slowly converging) x/sqrt(1+x^2) is the superior, more accurate, and more physical approximation of the step functions to correct the polynomials, then arctan is much closer to this “truth” than my tanh (which approaches the asymptotes exponentially).

37. dorigo - January 27, 2009

Well, thanks Lubos. Surely you’ve seen the results in the other post ? There is a complete form for the fitting function, as well as the 24 fits to the rapidity-binned lineshapes.


38. thiguideofede - April 10, 2009

Looking for Florida university sport? Funny fantasy sport names is here http://blogprosport.com/ !
Most actual news about 11 9 cover deception media tower up and Wheel cover http://blogprowatches.com/ .

Sorry comments are closed for this entry

%d bloggers like this: