Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. Consider the following function
    double f(double x){
       if( abs(x*x – 3) < 0.01) return x;
       else return f(x/2 + 1.5/x);
    }
    Give a value q (to 2 decimals) such that f(q) will return q:_____.
    1. 1.73 to 1.74
    2. 1.73
    3. 1.74
    4. None of the above
Correct Option: B

f(g) + q ⇒
x
+
1.5
= x
2x

x2 + 3
= x ⇒ x2 + 3 = 2x2
2x

⇒ x2 = 3 ⇒ x = 1.73



Your comments will be displayed only after manual approval.