java consider these methods public static double fdouble x r

java

consider these methods

public static double f(double x) {return g(x) + Math.sqrt(h(x));}

public static double g(double x) {return 4 * h(x); }

public static double h(double x) {return x * x + k(x) -1; }

public static double k(double x) {return 2 * (x+1);}

without actually compiling and runing a program, determine the results of the following method calls.

a. double x1 = f(2);

b. double x2 = g(h(2));

c. double x3 =k(g(2) + h(2));

d. double x4 + f(0) + f(1) +f(2);

e double x5 = f(-1) + g(-1) + h(-1) + k(-1);

Solution

From the above given methods double x1 = f(2);

x1 = f(2) = g(2) + Math.sqrt(h(2)) = 4 * h(2) + Math.sqrt(h2))

h(2) = 2*2 + k(2) - 1 = 4 + 2 * ( 2 + 1) - 1 = 9

then x1 = 4 * 9 + 3 = 39

double x2 = g(h(2));

x2 = g(h(2)) = g(9) = 4*9 = 36.

x2 = 36.

double x3 = k(g(2)+h(2));

x3 = k(g(2) + h(2)) = K(36+9) = k(45)

x3 = 2*(45+1) = 2*46 = 92.

double x4 = f(0)+f(1)+f(2);

x4 = f(0)+f(1)+f(2)

f(0) = 5 , f(1) = 18 , f(2) = 39.

x4 = 5+18+39 = 62.

double x5 = f(-1)+g(-1)+h(-1)+k(-1);

x5 = 0+0+0+0

x5 = 0.

java consider these methods public static double f(double x) {return g(x) + Math.sqrt(h(x));} public static double g(double x) {return 4 * h(x); } public static

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site