Before I differentiate anything, let me say what this object is. It is not an integral to be evaluated. It is a composition. The inner function is x squared; the outer function is the accumulation function G, which carries the integral from zero up to a plain variable u.
Once I see f as G composed with x squared, the derivative is the chain rule talking about an accumulation function. That is the calculus fundamental theorem in motion, with the Leibniz rule wrapped around it.
So my plan: differentiate first, integrate never, and then verify by integrating, because on this particular integrand the direct integral is secretly possible and it makes an honest cross-check.
The full two-moving-ends rule: derivative of an integral with limits a of x and b of x is h evaluated at the top times the rate the top rises, minus h at the bottom times the rate the bottom rises. I state the general rule so that my special case is a specialization, not a half-remembered formula.
Here the bottom is the constant zero, so its rate is zero and that whole term dies. The top is x squared, rising at the rate 2 x, and the integrand sampled at the top is cosine of the square root of x squared.
That is the answer waiting to be tidied. The two traps I can already see coming: forgetting the 2 x factor, and what the square root of x squared actually equals.
Let me draw the integrand itself, because f is the signed area of this curve from zero up to the moving point x squared. The curve starts at one, slides down, and crosses the axis exactly where square root of t equals pi over two; that is t equals pi squared over four, about 2.47.
Now the evaluation point: x is square root of pi, so the upper limit is x squared, which is pi, about 3.14. That lands to the right of the crossing. The strip being glued on as x grows is drawn from the part of the curve that is below the axis.
So the picture already tells me f prime of square root of pi must be negative, before I multiply anything. If my algebra later hands me a positive number, I will know I have erred.
Tidying: the square root of x squared is the modulus of x, not x itself. That is the line candidates skip, and I refuse to skip it silently. It collapses here only because cosine is an even function: cosine of the modulus of x equals cosine of x. So f prime of x is 2x cosine x, and it holds for every real x, negatives included.
Now substitute x equals square root of pi, about 1.7725. The cosine argument is the square root of pi itself, which is not pi; its cosine is about minus 0.2003. Times 2 root pi, the exact value is 2 square root pi cosine square root pi, roughly minus 0.710022.
The sign agrees with the drawing. The magnitude is honest: nothing about this number simplifies, and I will not pretend it does.
I do not trust my own first answer yet. So back to the definition: f of x is the integral from zero to x squared of cosine square root t, which I will integrate numerically and form the symmetric difference quotient f of x plus h minus f of x minus h over 2h, at x equal to square root of pi.
With h a tenth I get minus 0.7154. Cut h to a hundredth: minus 0.71008. To a thousandth: minus 0.710023. To a ten-thousandth: minus 0.7100221. The error is dropping by roughly a factor of one hundred per decade of h, the clean second-order signature of a central difference, marching onto minus 0.710022.
That is the same number my formula produced, obtained from the integral alone with no differentiation rule involved.
The Leibniz rule is not unconditional. It asks that the integrand be continuous at the moving endpoint. Cosine of square root t is a composition of continuous functions on the non-negative axis; the square root is continuous even at zero. So the accumulation function G is differentiable everywhere on the domain, x squared is smooth, and the chain rule is legal at every real x. There is no hidden exception.
A consequence I can test for free: f depends on x only through x squared, so f is an even function, so its derivative must be odd. Two x cosine x is indeed odd, and it predicts f prime of minus square root pi equals plus 0.710022; the mirror sign. That is structural insurance, independent of any calculation.
The one corner I want to look at: x equals zero. The formula gives zero there, and from the definition the integral up to x squared is approximately its length times one; that is x squared to leading order; so f of x over x tends to zero. The derivative at the origin exists and agrees.
Let me get the same derivative a second, independent way: this integrand actually yields to brute force. Substitute t equals u squared, so dt is 2u du, and the square root of t is just u. So the integral becomes 2 times the integral of u cosine u, from zero up to the modulus of x.
Integrate by parts and I get 2 of u sine u plus cosine u, evaluated at the modulus of x minus at zero. Since u sine u is even in disguise, the modulus times sine of the modulus equals x times sine of x, the closed form is 2 of x sine x plus cosine x minus one, and that is valid for every real x.
Differentiate that directly: the sines cancel and I am left with 2x cosine x. Same as the Leibniz route, which never needed the integral at all. Two independent routes agreeing. And the closed form lets me read off a free exact fact: f peaks at x equals pi over two with height exactly pi minus two, about 1.1416, consistent with the tangent in the drawing sitting just past that peak.
So the answer: f prime of x is 2x cosine x for every real x, and f prime of square root of pi is 2 square root pi cosine square root pi, exactly that, approximately minus 0.710022.
The square on the upper limit was never special. For the x to the n family, the same two-line argument gives n x to the n minus one, times cosine of the modulus of x to the n over two. Note that the modulus has reappeared, because now it is x to the n that gets square-rooted.
And two boundaries where the method stops being legal. For odd n, negative x makes the upper limit negative and the integrand itself stops being real; the domain of f feels the square-root issue too. And the rule needs the integrand continuous at the moving top: swap cosine square root t for something with a jump, and the derivative acquires a corner exactly where x squared crosses the jump. I would rather state the boundary of the tool than discover it by failing.
If you want to know why interviewers ask this shape of question: here the integral was doable, so differentiating-first was the efficient route. Replace the integrand by e to the minus t squared and the integral has no elementary closed form at all, but the Leibniz shortcut still hands you the derivative instantly. The shortcut is not a trick that replaces integration; it is a door that opens when integration cannot.
And on exactness: the answer minus 0.710022 is not simplifying to anything pretty. Cosine of square root pi is about minus 0.2003; square root pi is 1.77, not pi. I keep the exact form boxed and the decimal only as evidence.
I would offer this as a bonus rather than as the answer: the question only asked for the derivative and its value.
Nothing about this number tidies up: the square root of pi is about one point seven seven, not pi, so its cosine is about minus zero point two and the product does not simplify.
Same rule, both terms alive. The upper limit contributes cosine of the square root of x squared, times 2x, which collapses to 2 x cosine x as before; the lower limit now rises too, contributing minus cosine of the square root of x, times the rate one.
So the derivative is 2 x cosine x minus cosine square root x. I keep the x greater than zero caveat, because the second term samples the integrand at the lower limit x itself, and the square root there wants a non-negative argument; the domain of the answer is not the domain of the original f.
From f prime equals 2x cosine x, the stationary points are x equals zero and the zeros of cosine, the first being plus and minus pi over two. The drawing settles which is which: the integrand turns negative past t equals pi squared over four, and that crossing lands exactly where x squared hits pi squared over four, so pi over two is a genuine peak.
Because f is even, minus pi over two is an identical peak, and x equals zero is a minimum with f equal zero. The closed form from the cross-check route gives the height exactly: two of pi over two times one, plus zero, minus one. The maximum is pi minus two, about 1.1416.
And the second derivative test agrees for free: f double prime at pi over two is minus pi, comfortably negative.
Differentiate 2x cosine x by the product rule: f double prime is 2 cosine x minus 2x sine x. At square root of pi the first term is 2 cosine of square root pi, about minus 0.4006; the second term is minus 2 square root pi sine square root pi, about minus 3.4731, and the sum is about minus 3.8737.
Two readings: the tangent is falling, slope minus 0.71; and it is falling harder as x grows, since the negative second derivative says f is concave down there. Consistent with sitting just past the peak at pi over two.
It is a real rule that was harmless here only by accident: cosine is even, so cosine of the modulus of x equals cosine of x and the absolute value folded away without changing the answer.
Change the integrand to square root t and it bites. The rule returns 2 x times the square root of x squared, which is 2 x times the modulus of x. Integrating the raw square root directly: the integral is two thirds of the modulus of x cubed, whose derivative is indeed 2 x modulus of x, while the naive answer 2 x squared is wrong for negative x.
So the discipline is: write the modulus, then check whether the outer function erases it. Never erase it yourself before looking.