Solve for the Red Area

Published by Ruud Peter Boelens in

This problem went viral in China, spreading on Weibo. The problem is to solve for the area shown in red between the semicircle and the rectangle’s diagonal.

Create a function that takes a number r as an the length of the side and returns the area rounded to the nearest thousandth. Watch the video in the Resources tab for the answer to the problem.

The shaded part

Examples

redArea(0) ➞ 0

redArea(4) ➞ 1.252

redArea(25) ➞ 48.906

Notes

The input r is always a valid number.

Watch a quick demo on how Edabit works.