Skip to content

Instantly share code, notes, and snippets.

@igorvanloo
Created May 15, 2022 14:43
Show Gist options
  • Select an option

  • Save igorvanloo/b009ad3ab0a147f16268ca68d5acbc5b to your computer and use it in GitHub Desktop.

Select an option

Save igorvanloo/b009ad3ab0a147f16268ca68d5acbc5b to your computer and use it in GitHub Desktop.
p226
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