How to find the surface area of a spherical cap by integration? I don't really understand how they derived the formula in the following picture.

The aim is basically to find the formula for the surface area of a spherical cap. 
Why do you differentiate the $x=\sqrt{r^2-y^2}$? how does that help to find the surface?
What role does $ds$ play in here ? 
How do you know that $S_y= 2\pi \int_c^d x\, ds$?
 A: The idea they are trying to put across is that a surface can be generated by an arc.  In the sketch, they are highlighting an arc of the circle and indicating that when the arc revolves around the y-axis, the arc sweeps out an area.  Then entire circle would generate the sphere, but the arc only generates the spherical cap.  
Until now we have been talking about the entire highlighted circular arc revolving around the y-axis.  The entire arc would have to revolve through an angle of 180 degrees to generate the spherical cap.  We now want to consider only the right half of that arc and revolve that arc through an angle of 360 degrees, or $2\pi$ radians, to sweep out the entire cap.  That will make the math a little simpler.
Now for the math.  Each little element ($ds$) of the arc generates part of the surface area.  Revolving the arc causes each little element to move along a circular path around the y-axis.  These individual paths are not shown, except at the base of the cap.  Each of these circular paths has a different radius, $r'$.  When the arc revolves by the angle $\theta$, the distance that the element travels is $r' \theta$.  To sweep out the entire spherical cap, we need to revolve the (right half of the highlighted) arc through an angle of $2 \pi$ radians.  We just ignore the left half.
The amount of area swept out by $ds$ is $r' \theta ds = 2\pi r' ds$.  So, to find the surface area, they want find an expression $ds$ and an expression for $r'$.  Their expression for $ds$ is $\sqrt{1+\frac{dx}{dy}}dy$, so that why they calculate $dx/dy$.  They calculated that first, because they knew would need it later.  
The element has coordinates (x,y), where "x" is the distance from the y-axis.  In other words, x is the radius $r'$ of circular path that the element takes.  That allows them to write an element of area as $2\pi\space x\space ds$.  They integrate this expression, the x's cancel out and $r$ is a constant.  
A: Slice the surface of the sphere with two horizontal planes just distant by $dy$.
They enclose a portion of the cap that is a circular strip of length $2\pi x$ ($x$ being the radius). The height of the strip is $ds=\sqrt{dx^2+dy^2}$ by Pythagoras, because it is oblique.
$ds$ is known as the element of arc, i.e. the length of an infinitesimal curve drawn on the surface. It is computed by $$ds=\frac{ds}{dy}dy=\sqrt{\left(\frac{dx}{dy}\right)^2+1}\,dy,$$ and this is how you see the derivative of $x$ appear.
The total surface is the integral of the strip surface $2\pi x\,ds$ over the whole range of $y$.
