Find square root approximation function (tool)

2.7k Views Asked by At

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

5

There are 5 best solutions below

1
On BEST ANSWER

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.

3
On

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".

4
On

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$.

1
On

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
On

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}$.