Note that in each case, to find the domain, determine the set of elements assigned values by the function.
As you should know by now, we need to always start with the 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.
Now we can start answering the questions.
Table of Contents
- a) the function that assigns to each bit string the number of ones in the string minus the number of zeros in the string
- b) the function that assigns to each bit string twice the number of zeros in that string
- c) the function that assigns the number of bits left over when a bit string is split into bytes (which are blocks of 8 bits)
- d) the function that assigns to each positive integer the largest perfect square not exceeding this integer
a) the function that assigns to each bit string the number of ones in the string minus the number of zeros in the string
To solve this type of exercise, first, we need to know the definition of domain and range.
From the definition above, the domain is the set of all values for which f is defined. The range will be the set of all images of A.
In this case, we can see that this function assigns a value to the set of bit strings. Therefore, that is the domain.
Domain: the set of bit strings.
The function assigns a number to each bit string. As the number is the result of subtracting the number of 1’s minus the number of 0’s, we can state that the result will always be an integer number.
Notice that the result can be positive, zero, or negative, but it will always be an integer.
Range: the set of integers.
b) the function that assigns to each bit string twice the number of zeros in that string
Following a similar approach to the first exercise, we find out the following:
- This function assigns a value to each bit string, so the domain is the set of bit strings.
- The value assigned to each bit string is twice the number of 0s in the bit string. Because of this, we know that the value cannot be negative, but it can be zero if the bit string doesn’t contain any 0.
Domain: the set of bit strings.
Range: the set of nonnegative integers.
c) the function that assigns the number of bits left over when a bit string is split into bytes (which are blocks of 8 bits)
By now you should know how to solve this type of exercise.
From the description above, we know the following:
- This function assigns a number to each bit string. Therefore, the domain is the set of bit strings.
- The number that is assigned, is the number of bits left over when a bit string is split into bytes. Because a byte is a block of 8 bits, and you are splitting a bit string into a block of 8 bits, the bits left over cannot be greater than 7, otherwise, it will be 8 and no bit will be left over. Also, notice that this number can be 0 if the length of the bit string is a multiple of 8.
Domain: the set of bit strings.
Range: the set of nonnegative integers not exceeding 7.
d) the function that assigns to each positive integer the largest perfect square not exceeding this integer
Following a similar approach to the previous exercises, from the description we know:
- The function assigns a value to each positive integer so that one is the domain.
- The value that the function assigns to each positive integer, is a perfect square, not exceeding that number. In other words, the images will always be a perfect square. It will be positive because the square of a positive number is always positive, and it will be the largest not exceeding the number. Notice that the set of positive integers is infinite. Therefore, the set of images will also be infinite.
Domain: the set of positive integers.
Range: the set of squares of positive integers = {1, 4, 9, 16, . . .}.
Related posts: