Say I have a function that I've obtained as a fit of a certain data set. I want to make that function go through two different points that it doesn't currently go through, while making it so the rest of the function adapts to that change and keeps its shape. Something like this:

enter image description here

Right now I have a rational fit with 9 coefficients (5th power numerator and 5th power denominator, 5 coefficients in the numerator and 4 coefficients in the denominator while the coefficient of x^5 in the denominator is 1). I can, however, choose a different fit (polynomial, sum of sines etc.) if it would help here.

I have tried changing two coefficients at random to force the function to fit the two new points, but it produces something that doesn't make sense.

Here's what I have:

enter image description here

enter image description here

This is a rational fit to a set of Excel data produced with Matlab cftool:

p1 = 0.09503;
p2 = 0.8033;
p3 = 2.654;
p4 = 4.375;
p5 = 3.691; 
p6 = 1.221;  
q1 = 6.399;
q2 = 21.65;  
q3 = 34.98;  
q4 = 29.02; 
q5 = 9.704;  
m = (x - 0.9857)./0.1235;
y = (p1*m.^5 + p2*m.^4 + p3*m.^3 + p4*m.^2 + p5*m + p6) ./ (m.^5 + q1*m.^4 + q2*m.^3 + q3*m.^2 + q4*m + q5);

I need to make the function go through points (0.78; 0.002) and (1.05473536553; 9.869964329717e-2), while keeping the shape.

  • 1
    $\begingroup$ A rational function like the one you describe may not "keep its shape" when you tinker with the coefficients. If the problem suggests a particular shape (as in the picture, increasing to a maximum from $0$ where it is nearly flat, then decreasing (perhaps asymptotically to a limit) then you should try to fit a function from that family. If you edit the question to show us some real data (a scatter plot and a curve) and describe the shape perhaps we can help. Tell us about the problem, and tell us why and where you need the exact fit. $\endgroup$ Sep 7, 2021 at 21:23
  • $\begingroup$ @EthanBolker Thanks for the reply. I just edited the question with more details. $\endgroup$ Sep 7, 2021 at 21:38
  • 1
    $\begingroup$ Those two points are very far under the blue curve. I have no idea how to help you at this point. I suspect that if you add those two points to your data set the curve from the Matlab tool will have a very different shape. Show us a scatter plot of the raw data and the two special points (marked as such). $\endgroup$ Sep 7, 2021 at 22:14
  • 1
    $\begingroup$ If I saw these data and that requirement in a question I was studying I would suspect some underlying problem in the source of the data or the requirement. I would stop trying to fit the numbers and explore their source. I think only domain knowledge, not mathematics, can help. $\endgroup$ Sep 7, 2021 at 22:29
  • 1
    $\begingroup$ OK that makes sense. You might try reparameterizing the vertical axis in a way that fixes the top and bottom and shrinks the distance between tick marks near the bottom and expands it at the top. Some kind of exponential transform to start with. $\endgroup$ Sep 7, 2021 at 22:43


You must log in to answer this question.

Browse other questions tagged .