2 ms·
> Using floor it seems like you can construct a function that's effectively defined piecewise, by constructing a floor expression that's zero outside of a speci
by thaumasiotes 12y ago
> Using floor it seems like you can construct a function that's effectively defined piecewise, by constructing a floor expression that's zero outside of a specified input domain, and 1 within the domain. Then you multiply the floor expression by the piecewise expression that you'd use to define a piecewise function over that domain.
And you can fit a polynomial the same way by (using the example at hand) defining
f(x) = c_1(x-2)(x-3)...(x-12)
+ c_2(x-1)(x-3)...(x-12)
+ c_3(x-1)(x-2)...(x-12) [but the (x-3) factor is missing!]
+ . . .
+ . . .
+ . . .
+ c_12(x-1)(x-2)...(x-11)
And then choosing c_1 such that the c_1 term is equal to 31 when x=1, c_2 such that the c_2 term is equal to 28 when x=2, and so forth. You'll get a well-defined polynomial, impeccably "mathematical" -- in fact, you should get the polynomial listed in Someone's comment (since there should only be one 11th-degree polynomial passing through those 12 points). The traditional way to fit a polynomial to points is by reducing a matrix, linear-algebra style, but this approach is equivalent and, as you can see, amounts to nothing more than defining several functions which are zero except at the point of interest, and then scaling them to take the proper value at the point of interest. Why is that more "valid" than using a modulus?
Frankly, I'm much more concerned by the OP using "2 mod x" when 1 is a legal value for x.