# Math Help - Computer science: Functions help

1. ## Computer science: Functions help

Hi, I hope I can get some help with this problem. The class is called "Formal models of computation". It's a computer science course where we talk about models of how computers work, Turing machines, automatons, etc. It's kind of like Discrete Math for computer science (which I hated).

Give functions f: E -> E (where E is the set of even integers) that fulfill the following properties

a. f is one-to-one, but not onto or total
b. f is total, but not one-to-one or onto
c. f is total, one-to-one and onto, but is not the identity function (f(x) = x)
d. f is not total or one-to-one, but is onto.

I have part c figured out but can't come up with anything for the other 3. Everytime I come up with a function for one property it doesn't meet the other ones. The professor wants the functions to be in the form f(x) = something. We are not allowed to create subsets of set E either. The functions have to work over the entire set E.

Thanks for any help.

2. ## (b) and (c)

Originally Posted by AlexH
Give functions f: E -> E (where E is the set of even integers) that fulfill the following properties

a. f is one-to-one, but not onto or total
b. f is total, but not one-to-one or onto
c. f is total, one-to-one and onto, but is not the identity function (f(x) = x)
d. f is not total or one-to-one, but is onto.
I can't help you with all of them, but for (b), try the absolute value function or $f(x)=x^2$. For (c) try $f(x)=x+2$.

3. ## Functions

Hello AlexH
Originally Posted by AlexH
Give functions f: E -> E (where E is the set of even integers) that fulfill the following properties

a. f is one-to-one, but not onto or total
b. f is total, but not one-to-one or onto
c. f is total, one-to-one and onto, but is not the identity function (f(x) = x)
d. f is not total or one-to-one, but is onto.

I have part c figured out but can't come up with anything for the other 3. Everytime I come up with a function for one property it doesn't meet the other ones. The professor wants the functions to be in the form f(x) = something. We are not allowed to create subsets of set E either. The functions have to work over the entire set E.
(a) $f(x) = \sqrt{x}$ works OK. It's not total - only perfect squares, 0, 4, 16, ... work as input values; it's not onto - we're just taking the positive square root; but it is one-to-one.

wil's suggestions for (b) seem to work OK.

I'm still thinking about (d) ...

4. ## Functions

Hello AlexH
Originally Posted by AlexH
d. f is not total or one-to-one, but is onto.
I have got an answer for (d), but it's pretty obscure. I reasoned as follows:

$f$ is not total, so we must exclude at least one even integer from being a valid input to $f$. The square root function permits only positive numbers as inputs, so that looks a likely candidate.

$f$ is onto, so we have to find some way of generating negative as well as positive outputs. So I thought of $(-1)^n$ as a candidate, because, as $n$ goes alternately odd and even, $(-1)^n$ has values -1, 1, -1, 1, ...

$f$ is not one-one, so there must be at least two different input values that generate the same output value.

So I played around with these ideas and came up with (wait for it!)

$f(x) = \tfrac{1}{2}(-1)^{\frac{1}{2}\sqrt{x}}(\sqrt{x} - 1 + (-1)^{\frac{1}{2}\sqrt{x}})$

So: $x$ can only take (positive) even perfect squares as values: 0, 4, 16, 36, 64, 100, ... Therefore $f$ is not total.

For these values of $x$, then:

$\sqrt{x} = 0, 2, 4, 6, 8, 10, ...$

$(-1)^{\frac{1}{2}\sqrt{x}} = 1, -1, 1, -1, 1, -1, ...$

$\sqrt{x} - 1 + (-1)^{\frac{1}{2}\sqrt{x}} = 0, 0, 4, 4, 8, 8, ...$

and finally:

$\tfrac{1}{2}(-1)^{\frac{1}{2}\sqrt{x}}(\sqrt{x} - 1 + (-1)^{\frac{1}{2}\sqrt{x}}) = 0, 0, 2, -2, 4, -4, ...$

Note that $f(0) = 0 = f(4)$. So $f$ is not one-one, but it is total, because any even integer (positive or negative) can be generated using a suitable value of $x$.

I think you need a twisted mind for this sort of thing!