On Wed, 20 Nov 2013 00:50:59 -0700, "Robert Crandal" <firstname.lastname@example.org> wrote:
>I asked a similar question earlier. Thank you >everyone who tried helping. However, I'd now >like to revise the data and requirements. >Here is the new data set: > >X Y >-- -- >0.0 1 >0.1 1 >0.5 1 >0.9 1 >1.0 1 >1.03 2 >1.5 2 >1.8 2 >2.0 2 >2.3 3 >3.0 3 >3.2 4 > >X is a positive real number greater than or equal >to zero (or 0.0). Y is an integer as seen in the >second column above. > >Can this data be represented with a formula >that only uses either addition, subtraction, >multiplication, division, modulus, or the power (^) >function, or any combination of these? > >The function f(x) = x + (0^x) almost works, but >it needs a little bit of tweaking. > >If possible, I would like to avoid using any >abs() value functions, or max() functions, or >"if-else" programming logic, or roundup() functions. >I'm curious if I can find a formula that only >uses basic math operators. > >I'd appreciate any ideas. Thank you!
I don't know if this is the same as the reference Peter provided but I learned this in high school as a rebuttal to those inane IQ test questions about the next number in sequence. It works for any finite number of real X and Y values.
If there are N sets of X-Y values, the polynomial consists of the sum of N terms, each term being a polynomial of degree N-1. The i-th term is the product of a quotient and a constant. The numerator of the quotient is formed as the product of factors each having the form X-X(j) where j goes from 1 to N but omits i. The denominator of the quotient is formed as the product of factors each having the form X(i)-X(j) for the same j. The constant this quotient is multiplied by is Y(i).
If you evaluate this polynomial at X(k), every term goes to zero, because the numerator contains the expression X-X(k), except the k-th term. In the k-th term, the numerator and denominator evaluate to the same value so the quotient is 1 and the product is simply Y(k) as desired.
Here is a sample using just the X values of 0.0, 0.9, 1.5, and 3.2 from your data. It is probably best viewed in monospaced font.
(x-0.9)(x-1.5)(x-3.2) y = ---------------------- * 1 (-0.9)(-1.5)(-3.2)