ITPEC FE Subject B April 2025 Question 5
From the answer group below, select the correct answer to be inserted into blank in the program.
The function calc receives the positive real numbers x and y, and returns the result of the calculation of (√x + √y)2. For instance, when the function calc is called as calc(, the return value is 25. Here, the function pow( returns a raised to the power of b.
Answer group
Explanation
pow(pow(x, 0.5) + pow(y, 0.5), 2) — take both square roots, add them, and square the sum last.
A square root is a power of 0.5, so √x is pow(, and squaring is pow(. The formula is read outside-in: the outermost operation, the square, becomes the outermost pow call, and its first argument is the sum of the two roots.
Check with calc(: √4 + √9 = 2 + 3 = 5, and 52 = 25, as the example requires. Expanded, (√x + √y)2 = x + y + 2√xy, so the result must contain the cross term 2√xy.
Answer (a)
Why not others:
- •(b) — squares each root before adding, which is just x + y = 13; the cross term 2√xy = 12 is lost.
- •(c) — computes √x2 + y2 = √97, about 9.85: squares and roots in the wrong places.
- •(d) — the sum of the roots, 5, without the outer square.
- •(e) — ÷ binds tighter than +, so only the second root is divided: 2 + 3 ÷ √2, about 4.12.
- •(f) — squares instead of roots, and again divides only the second term: 16 + 81 ÷ √2, about 73.3.
Key rule: Translate a formula outside-in, one function call per operation, and remember that division binds tighter than addition in an unbracketed expression.
Math & Numbers · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.