Created
May 15, 2022 14:43
-
-
Save igorvanloo/b009ad3ab0a147f16268ca68d5acbc5b to your computer and use it in GitHub Desktop.
p226
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| from scipy.integrate import quad | |
| def f(x): | |
| return (1 - math.sqrt(2*x - 4*x*x))/2 | |
| def I(x): | |
| if x == 1: | |
| return 1/2 | |
| if 0 < x <= 1/2: | |
| return I(2*x)/4 + (x*x)/2 | |
| if 1/2 < x <= 1: | |
| return 1/2 - I(1 - x) | |
| def compute(): | |
| area_under_blancmange = I(1/2) - I(0.0789) | |
| area_under_circle = quad(f, 0.0789, 1/2)[0] | |
| return round(area_under_blancmange - area_under_circle, 8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment