How to develop a formula for a function?

501 Views Asked by At

What are the general tips and techniques to define an explicit formula for a function when the mapping of that function is known. Say f: N to Z (N is natural numbers and Z is integers). In this example, it is clear from mapping that if we assign odd numbers to Non negative integers and even numbers to negative integers ,we can define a function. But what would be the precise formula to show this relation? And how can I develop it?

1

There are 1 best solutions below

0
On

First, not every function has a convenient algebraic formula -- in general, for a function on $\{ 1, \ldots, n\}$, you should expect a polynomial formula to involve powers up to $x^{n-1}$, and even if you use trig or exponential functions, you generally don't save much.

Second, you can build up a lot of functions that are "case based" by using a few case-based primitives, such as "abs", "sgn", "floor", "ceiling", "frac", "max", and "min".

For instance, to define a function on the integers that's zero on evens and one on odds, you can take $$ s(n) = 2(\frac{n}{2} - \lfloor \frac{n}{2}\rfloor)). $$

We can use this to map even numbers to negative numbers (including $0 \mapsto 0$) by writing:

$$ h(n) = (1-s(n)) (-|n| + \frac{1-sgn(n)}{2}) $$

This also maps odd numbers to zero.

We can map odds to positive numbers using

$$ k(n) = s(n) (|n| + \frac{1-sgn(n)}{2}) $$

And now $$ u(n) = h(n) + k(n) $$ sends evens to negatives and odds to positives. That's exactly the inverse of what you wanted, but I was on a roll, and decided to do this one rather than its opposite.

The function you're looking for will be similar, and comparably messy, and just as uninformative as this one, which is why most books don't bother writing down algebraic formulas for things like this.