Indicate whether the two functions are equal
Question
Indicate whether the two functions are equal. If the two functions are not equal, then give an element of the domain on which the two functions have different values.
(i) S: Z–> Z, where S(y)=y^3. H: Z –> Z, where H(y) = ΙyΙ^3.
(ii) S: Z–> Z, where S(y) = y^4. H: Z –> Z, where H(y) = Ι-yΙ^4
(b) Express the range of function G.
Let A = {2, 3, 4, 5, 6}.
g: A –> Z such that G(y) = 2y + y^2-1.
Summary
In this question, we have been given two functions and we have to tell if they are equal. If the functions are not equal, then we have to tell the element of the domain on which the two functions are not equal. As we can see, in the first question, for the negative values of y, we will have different results from the functions S and H. So, the domain will be a collection of those numbers which are negative. And in the second case, for all the values of y, we will have equal results from the functions S and H, therefore here the domain will be null.
The range of function g, over the relation A -> Z is:
{7, 14, 23, 34, 47}.
Explanation
Here we implement the function “S” in which we pass an integer as an argument and it will return the cube of it. We will also implement the function “H” in which we pass an integer as an argument and it will return the cube of absolute y. Again, we will implement a function “S1” which represents the “S” function in case 2. This returns the 4th power of the y. We implement function “H1” which returns the 4th power of absolute y.
At last, we implement the function “rangeOfG” in which we pass an array and its size as arguments, and we will print the range of “G” over the relation A –> Z to the console as output.
In the main method, it will check the working of these functions.
Code
import java.util.*; class Main { /* to implement function S in case 1 */ public static int S(int y){ return y*y*y; } /* to implement function H in case 1 */ public static int H(int y){ if(y<0) y=-1*y; return y*y*y; } /* to implement function S in case 2 */ public static int S1(int y){ return y*y*y*y; } /* to implement function H in case 2 */ public static int H1(int y){ if(y<0) y=-1*y; return y*y*y*y; } /* to implement the range of relation G from A to Z */ public static void rangeOfG(int A[],int n){ System.out.println("Range of g: "); for(int i=0;i<n;i++){ int y=A[i]; System.out.print(2*y+y*y-1+" "); } } /* driver code */ public static void main(String args[]){ System.out.println("Case - 1:\nValues for which s and h are inequal"); for(int i=-10;i<=10;i++){ if(S(i)!=H(i)) System.out.print(i+" "); } System.out.println("\n"); System.out.println("Case - 2:\nValues for which s and h are inequal"); for(int i=-10;i<=10;i++){ if(S1(i)!=H1(i)) System.out.print(i+" "); } System.out.println(); int n=5; int A[]={2, 3, 4, 5, 6}; rangeOfG(A,n); } }
Output
Also read, Create a new Java class named Student that has the following fields