2
$\begingroup$

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.

  • 1
    (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.2010-08-18
  • 0
    @J. Man: I'm not good at explaining this I guess. At `x=0` `y` is not calculable. It's a J curve on a graph.2010-08-18
  • 1
    It was also correctly [pointed out on MO](http://mathoverflow.net/questions/35918/how-can-i-figure-out-a-function-closed) 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, ...)2010-08-18
  • 0
    Even with that restriction, there are far too many functions that are singular at the origin, the reciprocal and logarithm functions being two examples. Again, without a plot or knowledge of where said points came from, there is no useful answer we can give.2010-08-18
  • 4
    A succinct way to summarize Tom's comment: there are far too many ways to connect dots, some wigglier and some stiffer than others.2010-08-18
  • 1
    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.)2010-08-18
  • 1
    @Tom: Alright, I'm working with it. :) Let me know how this sounds now.2010-08-18
  • 0
    Could you elaborate "scale is too small" and "curve is too pronounced"? Again, where did these points come from? As an aside, reciprocal powers $cx^{-n}$ satisfy "becomes closer to infinity as x grows closer to 0, and closer to 0 the closer x gets to infinity."2010-08-18
  • 0
    @J.Man: I need the distribution to satisfy (5000, 11) and (200k, 3) as points. With a (logrithmic?) decline between them. Heck I'll even take (5, 11) and (200, 3) as applicable points.2010-08-18
  • 0
    @Josh: can we get one more pair of points?2010-08-18
  • 0
    @Tom: I think so. Lets say say (1, 15), (5, 11), (200, 3) because in reality I can just zero off the 1000 with division.2010-08-18
  • 1
    Hmm... if you say (5000, 11) and (5, 11), and (200,3) and (200000,3) are points on the curve you want, it looks very unlikely you'll have a nicely decreasing curve; it would wiggle a bit!2010-08-18
  • 0
    @J. Man: No, I mean either or. ;) I simply removed 1000 (via division) from the `x` values.2010-08-18
  • 1
    @Josh: You've used the word "curve", "line", and "distribution". Please be aware that *they are not interchangeable*. In this context, "line" would mean a function of the form f(x)=ax+b; "curve" would mean a continuous function, and "distribution" would mean a specific kind of function that is used in probability.2010-08-18
  • 1
    @Arturo: I guess I mean *curve* then rather then *line*.2010-08-18
  • 0
    @Tom: Why remove your answer?2010-08-18
  • 1
    @Josh: It was so horribly wrong that I couldn't look at it anymore. I am still trying to find something that comes close. J. Mangaldan is right about this thing being ugly.2010-08-18
  • 0
    @Josh: yes, there is a proper way: analysing the complexity of your process in terms of the input http://en.wikipedia.org/wiki/Complexity_analysis2010-08-18
  • 0
    Josh, I misunderstood, so you *rescaled* the dependent variable. Now, probably the question I should have asked after you gave pertinent information: how did you arrive at "5000 values need to be processed 11 times" or "1000 values need to be processed 15 times"? Was this all determined empirically? The way you came to these values might imply the proper formula. Alternatively, why not just employ a while or until loop in processing your array instead of fudging around values?2010-08-18
  • 0
    @Josh: One final thing - you should edit the title of the question to be more specific. Try something like "fitting a curve to decreasing data set undefined at zero"2010-08-18
  • 2
    On a less serious note, I think this thread has gotten an unprecedented number of comments...2010-08-18
  • 1
    I wish to sincerely thank all of you for taking the time with this. Probably should stick to SO. :foot-in-mouth:2010-08-18

2 Answers 2

2

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.

  • 1
    You know, I can't help but feel there's really not enough information available that won't make all proposals look *ad hoc*...2010-08-18
  • 0
    @Josh: That $\uparrow$ is the *elegant* solution.2010-08-18
  • 0
    That looks great. I will give it a shot.2010-08-18
  • 0
    Um, you inverted the values. Though I will solve the other way, for $x=5000$, $y=11$. For $x=200000$, $y=3$.2010-08-18
  • 0
    I got `n=0.3522` and `C=19.3896` (using (5, 11) and (200, 3) as points for simplicity.2010-08-18
1

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.