2
$\begingroup$

I have several points on a graph. The graph is of a continuous curve that flows through points $(0, \infty)$, $(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 \to 0$, and the 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
    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.

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