News for hackers. Stuff that matters.
Re:Ask HN: Anyone know any funny programming jokes? by smlckz on Thursday January 21, 2021 @05:08AM (#25857310)
I think the integral is

        4 * integrate sqrt(r^2 - x^2) w.r.t. x from x=0 to x=r
which is from the equation of circle with radius r centered at the origin:

        x^2 + y^2 = r^2
        => y = sqrt(r^2 - x^2)
any other way achieve the same using integration?
Re:Ask HN: Anyone know any funny programming jokes? by ChrisLomont on Friday January 22, 2021 @08:43AM (#25871562)
You can arrive at the same by slicing in nearly any manner you wish: vertical dx strips, horizontal dy strips, radial dtheta strips, concentric rings treated as rectangles, diagonal strips, literally anything you wish.

If you've never set up and worked a few, try the dx version and the dy version, then maybe fiddle with a few others. They all work.

The concentric rings one is trivial to work out. Integrate over r from 0 to R. Each ring at radius r has thickness dr, and has length 2 pi r, treated simply as a rectangle, which is "close enough" since each is arbitrarily thin. Then the integral is

int_0^R 2 pi r dr = 2pi r^2/2 from 0 to R = pi R^2.

A really pretty one cuts the circle into wedges, then rearranges them by alternating direction to make a "rectangle" approx r high, approx pi * r wide, with bumpy top and bottom. In the limit this has area pi * r * r, and can be shown to kids without needing calculus.

And it's not magic or circular, since pi is defined (in this case...) as the ratio of circumference to diameter.

Re:Ask HN: Anyone know any funny programming jokes? by sriku on Thursday January 21, 2021 @05:34AM (#25857486)
\int_0^2π{(1/2)r^2dθ}

Value inside the integral is area of thin triangle of height r and base rdθ.