# Fitting a curve to a decreasing data set undefined at zero

I have several points on a graph. The graph is of a continuous curve that flows through points (0, inf), (11, 5000), and (3, 200000). Can I find the equation for that line?

Let's try this:

I'm looking to find a function that given an input (x) becomes closer to infinity as x grows closer to 0, and closer to 0 the closer x gets to infinity.

The issue with y = log(x) is the scale is to small (#1) and the curve it too pronounced (#2).

For constraints I would say x >= 0 && y >= 0 at all times.

The purpose of this (for those who must know or are simply curious) is as follows:

I have a program that loops through an array of values a certain number of times. The number of times should be dependent on the number of values in the array.

For example, an array with 5000 values should be processed 11 times. An array with 250k values should be processed 3 times.

int y = // Function goes here, given x;
for(int i = 0; i < y; i++)
{
// Process
}


I've been playing with a graph utility

$$\frac{0.3}{\frac{log(x)}{24}} = y$$

Gives me approximately what I'm looking for, though doesn't give a proper values as $x \to 0$ (or > 4 actually). However there has to be a "proper" way to do this. Rather then punch numbers in until it "looks" right.

Looks like the "right" way gives the following:

$$y=\frac{C}{x^n}$$

Solving for $C$ and $n$ gives $C ~= 19.3896$ and $n ~= 0.3522$ using $(5, 11), (200, 3)$ as points for simplicity.

-
(0,inf)? Is that even a valid point? Without insight into where the points came from, or even a plot of the points, any attempt to model those points with an arbitrary equation might as well be voodoo. – J. M. Aug 18 '10 at 1:59
It was also correctly pointed out on MO that there are infinitely many possibilities for such a function seeing that you have not provided any more constraints - i.e. what properties would you like this graph to have? (you can choose from differentiable, continuous, straight-line, polynomial of lowest order, ...) – Tom Stephens Aug 18 '10 at 2:03
A succinct way to summarize Tom's comment: there are far too many ways to connect dots, some wigglier and some stiffer than others. – J. M. Aug 18 '10 at 2:06
let's try this: What is the context of the question? In other words, what behavior is this attempting to describe? (Please answer this as an edit to the main body of your original question.) – Tom Stephens Aug 18 '10 at 2:07
On a less serious note, I think this thread has gotten an unprecedented number of comments... – J. M. Aug 18 '10 at 4:02

If y = 4525365/x^2.83916, that is,

$$y = \frac{4525365}{x^2.83916}$$

then when x = 3, y = 200000.02 and when x = 11, y = 5000.04 and when x = ∞, y = 0, and when x = 0, y = ∞. It also satisfies y ≥ 0 whenever x > 0 and x ≥ 0 whenever y > 0.

This is based on the idea that the longer the array the less times you can afford to scan the array. The amount of work might be equal to x*y, so you want to keep the amount of work constant, x*y = C, or y = C/x. That does not quite fit your points, so I decided to use x^n*y = C instead. I solved for n using:

3^n*200000 = 11^n*5000, so 200000/5000 = 11^n/3^n, so 40 = (11/3)^n, so n = log(40)/log(11/3) ≈ 2.83916.

Then C = 3^2.83916*200000 ≈ 4525365.

-
You know, I can't help but feel there's really not enough information available that won't make all proposals look ad hoc... – J. M. Aug 18 '10 at 3:48
@Josh: That $\uparrow$ is the elegant solution. – Tom Stephens Aug 18 '10 at 3:48
That looks great. I will give it a shot. – Josh K Aug 18 '10 at 14:43
Um, you inverted the values. Though I will solve the other way, for $x=5000$, $y=11$. For $x=200000$, $y=3$. – Josh K Aug 18 '10 at 14:46
I got n=0.3522 and C=19.3896 (using (5, 11) and (200, 3) as points for simplicity. – Josh K Aug 18 '10 at 14:56

As everybody told you, there are infinitely many solutions for your problem. One particularly simple kind of them are functions like:

$$y = \frac{a}{x} + bx \ .$$

You can obtain which constants $a, b$ fit with your pair of data $(11, 5.000)$ and $(3, 200.000)$ imposing them:

\begin{align*} 5.000 &= \frac{1}{11}a + 11b
\\ 200.000 &= \frac{1}{3}a + 3b \end{align*}

You're getting a linear system of equations in which $a,b$ are the unknowns. Since $\frac{3}{11} - \frac{11}{3} \neq 0$, you have a unique solution.

-