Skip to main content
added 1 characters in body
Source Link
Stefan Hansen
  • 25.7k
  • 7
  • 59
  • 93

I am cammingcoming from Stack overflow, where they closeclosed my question because of being "mathemathical and nothing of programming", please, I know that in this forums usually mathemathical questions are more complex and elaborated, but I have nowhere else to go!

I am trying to fit some points to an inverse parabola, in of the form of F(x)=1/(ax^2+bx+c)$F(x)=1/(ax^2+bx+c)$.

My objective is to program a function in c++ that would take a set of 10-30 points and fit them to the inverse parabola.

I started trying to get an analytical expresion using Least squares, but I can't reach to get a result. I tried by hand (little crazy) and then I tried to solve analytically the expressions for a,b and c, but mupad doesn't give me a result (I am pretty new to Matlab's mupad so maybe i am not doing it correctly). i don't know anymore how to approach the problem.

Can I get a anallytical expresion for this specific problem? I have also seen algorithms for general least squares fitting but I don't need a so complicated algorithm, I just need it for this equation. If not, how would StackOverflow people approach the problem?

If needed I can post the equations, and the small Mupad code I've tried, but I think is unnecessary.

EDIT: some example

Im sorry the image is a little bit messy but it is the thing i need. The data is in blue (this data is particularly noisy). I need to use only the data that is between the vertical lines (a bunch of data in the left and another one in the right).

The result of the fit is in de red line.

all this has been made with matlab, but I need to make it in c++.

I'll try to post some data...

![enter image description here][1]

Edit 2: I actually did the fitting in Matlab as follows (not the actual code):

 create linear system Ax = b, with 
 A = [x²  x  1]
 x = [a; b; c]
 b = 1/y;

It should work, shouldn it? I can solve then using Moore-Penrose pseudoinv calculated with SVD. Isn't it? [1]: https://i.sstatic.net/e18NU.png

I am camming from Stack overflow, where they close my question because of being "mathemathical and nothing of programming", please, I know that in this forums usually mathemathical questions are more complex and elaborated, but I have nowhere else to go!

I am trying to fit some points to an inverse parabola, in the form of F(x)=1/(ax^2+bx+c).

My objective is to program a function in c++ that would take a set of 10-30 points and fit them to the inverse parabola.

I started trying to get an analytical expresion using Least squares, but I can't reach to get a result. I tried by hand (little crazy) and then I tried to solve analytically the expressions for a,b and c, but mupad doesn't give me a result (I am pretty new to Matlab's mupad so maybe i am not doing it correctly). i don't know anymore how to approach the problem.

Can I get a anallytical expresion for this specific problem? I have also seen algorithms for general least squares fitting but I don't need a so complicated algorithm, I just need it for this equation. If not, how would StackOverflow people approach the problem?

If needed I can post the equations, and the small Mupad code I've tried, but I think is unnecessary.

EDIT: some example

Im sorry the image is a little bit messy but it is the thing i need. The data is in blue (this data is particularly noisy). I need to use only the data that is between the vertical lines (a bunch of data in the left and another one in the right).

The result of the fit is in de red line.

all this has been made with matlab, but I need to make it in c++.

I'll try to post some data...

![enter image description here][1]

Edit 2: I actually did the fitting in Matlab as follows (not the actual code):

 create linear system Ax = b, with 
 A = [x²  x  1]
 x = [a; b; c]
 b = 1/y;

It should work, shouldn it? I can solve then using Moore-Penrose pseudoinv calculated with SVD. Isn't it? [1]: https://i.sstatic.net/e18NU.png

I am coming from Stack overflow, where they closed my question because of being "mathemathical and nothing of programming", please, I know that in this forums usually mathemathical questions are more complex and elaborated, but I have nowhere else to go!

I am trying to fit some points to an inverse parabola of the form of $F(x)=1/(ax^2+bx+c)$.

My objective is to program a function in c++ that would take a set of 10-30 points and fit them to the inverse parabola.

I started trying to get an analytical expresion using Least squares, but I can't reach to get a result. I tried by hand (little crazy) and then I tried to solve analytically the expressions for a,b and c, but mupad doesn't give me a result (I am pretty new to Matlab's mupad so maybe i am not doing it correctly). i don't know anymore how to approach the problem.

Can I get a anallytical expresion for this specific problem? I have also seen algorithms for general least squares fitting but I don't need a so complicated algorithm, I just need it for this equation. If not, how would StackOverflow people approach the problem?

If needed I can post the equations, and the small Mupad code I've tried, but I think is unnecessary.

EDIT: some example

Im sorry the image is a little bit messy but it is the thing i need. The data is in blue (this data is particularly noisy). I need to use only the data that is between the vertical lines (a bunch of data in the left and another one in the right).

The result of the fit is in de red line.

all this has been made with matlab, but I need to make it in c++.

I'll try to post some data...

![enter image description here][1]

Edit 2: I actually did the fitting in Matlab as follows (not the actual code):

 create linear system Ax = b, with 
 A = [x²  x  1]
 x = [a; b; c]
 b = 1/y;

It should work, shouldn it? I can solve then using Moore-Penrose pseudoinv calculated with SVD. Isn't it? [1]: https://i.sstatic.net/e18NU.png

Source Link

Algorithm to get inverse parabola fitting

I am camming from Stack overflow, where they close my question because of being "mathemathical and nothing of programming", please, I know that in this forums usually mathemathical questions are more complex and elaborated, but I have nowhere else to go!

I am trying to fit some points to an inverse parabola, in the form of F(x)=1/(ax^2+bx+c).

My objective is to program a function in c++ that would take a set of 10-30 points and fit them to the inverse parabola.

I started trying to get an analytical expresion using Least squares, but I can't reach to get a result. I tried by hand (little crazy) and then I tried to solve analytically the expressions for a,b and c, but mupad doesn't give me a result (I am pretty new to Matlab's mupad so maybe i am not doing it correctly). i don't know anymore how to approach the problem.

Can I get a anallytical expresion for this specific problem? I have also seen algorithms for general least squares fitting but I don't need a so complicated algorithm, I just need it for this equation. If not, how would StackOverflow people approach the problem?

If needed I can post the equations, and the small Mupad code I've tried, but I think is unnecessary.

EDIT: some example

Im sorry the image is a little bit messy but it is the thing i need. The data is in blue (this data is particularly noisy). I need to use only the data that is between the vertical lines (a bunch of data in the left and another one in the right).

The result of the fit is in de red line.

all this has been made with matlab, but I need to make it in c++.

I'll try to post some data...

![enter image description here][1]

Edit 2: I actually did the fitting in Matlab as follows (not the actual code):

 create linear system Ax = b, with 
 A = [x²  x  1]
 x = [a; b; c]
 b = 1/y;

It should work, shouldn it? I can solve then using Moore-Penrose pseudoinv calculated with SVD. Isn't it? [1]: https://i.sstatic.net/e18NU.png