6. Find the domain and range of these functions

As usual, let’s start with relevant definitions.

Definition: “If f is a function from A to B, we say that A is the domain of f and B is the codomain of f. If f (a) = b, we say that b is the image of a and a is a preimage of b. The range, or image, of f is the set of all images of elements of A. Also, if f is a function from A to B, we say that f maps A to B.” Discrete mathematics and its applications By Rosen.

a) the function that assigns to each pair of positive integers the first integer of the pair

In this case, the function assigns values to each pair of positive integers. Therefore, the domain is the cartesian product of Z+ and Z+ (review the definition of the cartesian product of two sets).

As the function assigns the first integer of the pair, the range is the set of positive integers.

Answer:

Domain: Z+ x Z+

Range: Z+

b) the function that assigns to each positive integer its largest decimal digit

Answer:

Domain: Z+

Range: the set {0,1,2,…,9}

c) the function that assigns to a bit string the number of ones minus the number of zeros in the string

The function assigns values to a bit string. Therefore, the domain is the set of bit strings.

The function assigns the result of subtracting a nonnegative number from another one. Therefore, this value can be a negative integer, zero, or positive integer.

Answer:

Domain: the set of bit strings

Range: Z

d) the function that assigns to each positive integer the largest integer not exceeding the square root of the integer

Answer:

Domain: Z+

Range: Z+

e) the function that assigns to a bit string the longest string of ones in the string

Answer:

Domain: the set of bit strings.

Range: the set of bit strings with only 1s and the null/empty string.

Related exercises: