Skip to main content
8-Gravel
May 5, 2023
Solved

y=A/x+B Formula fitting

  • May 5, 2023
  • 2 replies
  • 1746 views
Hello everyone, Here I need a help in formula fitting. x=[0.2;0.3;0.4;0.5;0.6;0.7;0.8;0.9;1.0] y=[0.25;0.51;0.78;1.15;1.5;1.87;2.35;2.85;3.4] I want to fit formula y=A/x+B  , how can I calculate the paramaters of A and B using Mathcad. Thank you 
Best answer by Werner_E

So you think he wanted to to ask for a linear regression and it should read y=A*x+B and he just accidentally wrote y=A/x+B ?

Possible. I thought he would like to fit a hyperbola and as I already indicated I think a hyperbola would at least need some sort of horizontal displacement (B) and better also some vertical displacement (C) - and of course scaling (A).

Werner_E_0-1683289842028.png

 

But a polynomial fit of order 2, a parabola, seems to do a good job as well

Werner_E_1-1683289985715.png

 

Comparing the sum of squared errors we see that the hyperbola offers just a very slightly better fit

Werner_E_2-1683290462347.png

 

Attached sheet uses the y-values provided by Fred and is in P9 format

2 replies

25-Diamond I
May 5, 2023

You may either set up a solve block with "minerr" , minimizing the sum of squared errors, or, more convenient, use the "genfit" function. Look the latter up in he help.

If you need more help, come back here and don't forget to attach your worksheet with the data.
In case you are using Prime, you should also mention which version you are using.

 

P.S.: I don't think that the function type you have in mind would result in a suitable fit

Rather use y=A/(x+B) or even better y=A/(x+B)+C

23-Emerald I
May 5, 2023

If you have a full (paid) version of Mathcad Prime, there is a built-in function:

Fred_Kohlhepp_0-1683287966813.png

For those of us muddling along with the free Express version, you can easily do least squares fits of any order polynomial.  Two Prime 4.0 files attached. 

 

Werner_E25-Diamond IAnswer
25-Diamond I
May 5, 2023

So you think he wanted to to ask for a linear regression and it should read y=A*x+B and he just accidentally wrote y=A/x+B ?

Possible. I thought he would like to fit a hyperbola and as I already indicated I think a hyperbola would at least need some sort of horizontal displacement (B) and better also some vertical displacement (C) - and of course scaling (A).

Werner_E_0-1683289842028.png

 

But a polynomial fit of order 2, a parabola, seems to do a good job as well

Werner_E_1-1683289985715.png

 

Comparing the sum of squared errors we see that the hyperbola offers just a very slightly better fit

Werner_E_2-1683290462347.png

 

Attached sheet uses the y-values provided by Fred and is in P9 format

23-Emerald I
May 5, 2023

Sorry, I've got to learn to read more carefully.

 

Attached is my least squares fit to a parabola.  The hyperbola fit is included but fails.  (Well, you get a fit but if you look a Werner's function you can see why there's no success--I've got the wrong form of expression.  Adjusting the formula (and stealing Werner's value for B) has been included.

 

File is Prime 4, readable  in any Prime  greater than or equal to 4.