I have bunch of x,y data that at first seem to be fittable with a logarithmic function. My current plot looks like this:

attempted fit

As you can see, the logarithmic fit using f(x,a,b,c) = a*log(b*x) +c doesn't work for high values of x_applied.

My guess is that the function that I need to fit these points is basically a half of a diamond shape (that's the name I googled for that shape). This is what the fit would (not really) look like. with diamond

I didn't know how to make a nice and symmetrical diamond in GIMP using the paths tool, so just imagine the the blue curve is symmetrical and doesn't have a dent in the middle.

So my question is: Is there a typical function for fitting data that looks like this? Fitting one half of a "diamond shape"? I think I remember similar graphs from the fractional distillation of azeotropes, but I couldn't find the exact thing I was looking for.

EDIT: I know the visible points can be fitted well with a quadratic function, but I know due to the chemical background knowledge that it cannot be a simple quadratic. If I use that as a fitting function, the last point will be fitted apporximately as the maximal turning point of the quadratic function. It has to be a diamond shape between 0 and 1. I could try to explain why that is, but it would be difficult...


This is the numerical data I am trying to fit:

x_applied   x_found
0.009   0.02
0.012   0.03
0.016   0.05
0.024   0.07
0.047   0.12
0.069   0.17
0.13    0.24
0.25    0.35
  • $\begingroup$ A first step is to represent your data with a log-scale on the ordinate axis and attempt to make a fit on this representation. Besides, which software are you using for your plots ? $\endgroup$
    – Jean Marie
    Jun 27 at 9:45
  • $\begingroup$ I am using scipy.optimize for curve fitting. The data is a mole fraction of a ligand you put in during synthesis and the mole fraction of that ligand in the crystal once the synthesis is done. At low mole fraction and high mole fractions, you would expect that the mole fraction of the reagents and inside the crystal lattice are identical. but if you go in the 50/50 split range, the deviation between x_applied and x_found should be largest. $\endgroup$
    – J.Doe
    Jun 27 at 10:28
  • $\begingroup$ Can you joint to your question an example of data (numerical, not graphical). $\endgroup$
    – JJacquelin
    Jun 28 at 8:02
  • $\begingroup$ I've added the data. Hope that helps @JJacquelin $\endgroup$
    – J.Doe
    Jun 28 at 11:32

1 Answer 1


The diamond shape is a particular case of superellipse : https://mathworld.wolfram.com/Superellipse.html

If we choose the equation of superellipse as model the result is shown below. $$\left|\frac{x-x_0}{a}\right|^p +\left|\frac{y-y_0}{b}\right|^p=1 \tag 1$$ The condition for the vertexes be $(0,0)$ and $(1,1)$ implies $x_0=-1$ , $y_0=0$ , $a=b=1$. The equation becomes : $$|x-1|^p+|y|^p=1 \tag 2$$ We consider the arc of superellipse in the range $0<x<1$ and $0<y<1$. The equation is : $$(1-x)^p+y^p=1 \tag 3$$ Thanks to any software for nonlinear regression the result (with criteria of fitting LMSE wrt Eq.3 ) is:

enter image description here

The fitting is not very good with equation $(3)$. This is due to the conditions specified for the vertexes.

With the more general equation $(1)$ the accuracy is much better. But the shape isn't as expected on your second graph :

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .