0

I have these values.these are inputs and outputs of a function.I want to find rule of function.input is N.

    N             f(N)
   512           0.000
   1024          0.001
   2048          0.003
   4096          0.011
   8192          0.042
   16348         0.154
   32768         0.572
   65536         2.134
   131072        7.864
   262144        29.190
   524288        108.301
   1048576       400.578
   2097152       1482.995
maryam
  • 119

2 Answers2

2

I observe that the left column is obviously exponential, and the right column seemingly so. (Each item in the right column is somewhat more than three times the previous item.) So it makes sense to construct a log-log plot of the data:

log-log plot of data

The $x$-axis is the logarithm of the left-hand column, and the $y$-axis is the logarithm of the right-hand column.

At this point it is obvious that the relationship between the logarithms of $x$ and $y$ is linear, so $\log y = m\log x + b$ where $m$ and $b$ are the slope and $y$-intercept of the plotted line. Linear regression gives $m\approx 1.88$ and $b\approx -20.086$:

log-log plut with regression line

So we can write $$\begin{align}y & = e^{1.88\log x - 20.086}\\ & = \frac{x^{1.88}}{529108792}\end{align}$$

Checking $x=65536$ we get $y=2.145$ which is close to the $2.134$ in the table; had I rounded off the $1.88$ more carefully we might have gotten a more accurate result. The apparent zero value for $x=512$ is actually around $0.00023$.

For the linear regression I used a tiny program that I wrote in Perl a few years ago, but any handheld scientific or financial calculator will do it. I explained it in detail in this post.

MJD
  • 67,568
  • 43
  • 308
  • 617
  • The x-axis is the logarithm of the left-hand column, and the y-axis is the logarithm of the right-hand column.what is the base of logarithm?10 or 2 – maryam Oct 16 '14 at 17:56
  • I used base $e$, but it doesn't matter which you use; all logarithms are really the same function, with a different scale. The graph would look the same and have the same slope if I had used base 10 or base 2, and the slope of the line would have been the same. Notice how the base of the logarithm disappears from the relationship between $x$ and $y$ in the formula $\frac{x^{1.88}}{529108792}$. – MJD Oct 16 '14 at 18:54
0

you can use cftool in MatLab to interpolate, the function that you want.

CLAUDE
  • 2,449