1
$\begingroup$

first I have to apologize for any uncorrect naming or categorisation of my question, as I am an electrical engineer rather than a mathematican.

I try to find a simple solution for my problem:

I have a given number of data points (x,y) that "look like" they could be approximated by an easy function. As this will be used in a simulation many times, calculation time quite matters and therefore I can't implement it as a lookup table. Also, some error isn't a problem at all.

There are some online tools, that do what I want:

Nevertheless, my data looks pretty much like -sqrt(x). So do you now any tools that includes regressions by (square?) roots? Because a sqrt() function isn't approximated very well by polynomial equations for values near the x axis.

Thank you very much!

Edit: It rather looks like sqrt(-x), I added an image.

graph

  • 0
    I see now, this is a valid scenario of course.2012-03-14

5 Answers 5

1

For the record, an answer not yet posted:

Use the CurveFitting Toolbox of Matlab. It has way more regressions build in than the online tools mentioned above. I get pretty good results by playing around with the regression functions for each curve.

  • 0
    I just implemented the functions and used Matlab CurveFitting Toolbox to calculate the coefficients for a 4-grade polynomial function. I hope accept my own answer isn't supposed to be rude or something?2012-03-16
3

The keyword is Curve Fitting. You are trying to fit a known curve that is close to the data points that you have. (http://en.wikipedia.org/wiki/Curve_fitting). You are posting the question probably not in the right group.

Check https://stackoverflow.com/questions/878200/java-curve-fitting-library if you find answers. If you don't find it yet you will find in the programming language choice of yours by doing just a web search with keyword "Curve Fitting".

  • 0
    @KirthiRaman, the link is good. Thanks.2012-03-14
2

I am sure there are better ways to do this, but this is the only one I know. Since you accept some error in the y-values, Looking at your original curve, I noticed that you could approximate the values by using 3 lines and an ellipse.

for x between 0 and 500 use: $y= -0.05x+50$

for x between 501 and 640 use: $y=-0.07x+61.04$

for x between 641 and 700 use: $y=-0.1x+80.19$

for x between 701 and 720, use $y=0.25\sqrt{400-(700-x)^2}$

enter image description here

  • 0
    I thought about splitting the data into intervalls, too. Could be worth a try.2012-03-14
1

Do a linear regression on the $\log$ of the data. If $\log y\approx a\log x+b$, then $y\approx b\,x^a$. If $\sqrt{\quad}$ fits the data, you should get $a\approx .5$.

  • 0
    Problem is, I don't have a clue what function is behind the data points. (To be more precise, which functions, because the data is defined section by section. I tried '(log x, log y)' but the error is quite the same.2012-03-15
1

You can test your guess that there is a square root behind the data by plotting $x$ against the square of $y$; if your guess is correct than that would be a straight line. That also gives you a tool to do regression: assuming you know how to do linear regression (how to find a line $y=ax+b$ through data points), you can do linear regression to the data points $(x,y^2)$ and get a relation of the form $y^2 = ax+b$ or $y = \sqrt{ax+b}$.