cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

y=A/x+B Formula fitting

Aary
6-Contributor

y=A/x+B Formula fitting

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 
1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

5 REPLIES 5
Werner_E
24-Ruby V
(To:Aary)

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

Fred_Kohlhepp
23-Emerald I
(To:Aary)

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. 

 

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

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.

I am always fascinated by the clever workarounds to find a solution even in Express. Chapeaux!

Top Tags