File:Mrs Miniver's Problem.svg

Summary

Description
English: Three instances of Mrs. Miniver's problem, of arranging two circles so that their area of overlap equals the area of their symmetric difference. In each case the inner yellow area equals the total area of the surrounding blue regions. The left case shows two circles of equal areas, the right case shows one circle with twice the area of the other, and the middle case is intermediate between these two.
Date
Source Own work
Author David Eppstein
SVG development
InfoField

Licensing

David Eppstein, the copyright holder of this work, hereby publishes it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Category:CC-Zero#Mrs%20Miniver's%20Problem.svgCategory:Self-published work

Source code

The logo of Python – general-purpose programming language
The logo of Python – general-purpose programming language
This media was created with Python (general-purpose programming language)Category:Images with Python source code
Here is a listing of the source used to create this file.

Deutsch  English  +/−

from math import pi,asin,sin,cos,acos
from PADS.SVG import *
import sys

# Circular segment formulas from https://en.wikipedia.org/wiki/Circular_segment

def areaFromRadius(r): return pi*r**2

def twoCircleArea(r1,r2): return areaFromRadius(r1)+areaFromRadius(r2)

def angleFromChord(r,c):
    return 2*asin(c/(2*r))

def areaFromAngle(r,theta):
    return r**2*(theta-sin(theta))/2

def areaFromChord(r,c):
    theta = angleFromChord(r,c)
    return areaFromAngle(r,theta)

def distanceToChord(r,c):
    theta = angleFromChord(r,c)
    return r*cos(theta/2)

def separationFromChord(r1,r2,c):
    return distanceToChord(r1,c)+distanceToChord(r2,c)

# Bisection to solve Mrs. Miniver's problem within floating point accuracy

def miniverSeparation(r1,r2):
    if r1 > r2: r1,r2 = r2,r1   # make sure small circle first
    totalArea = twoCircleArea(r1,r2)
    targetArea = totalArea/3

    def miniverTest(x):
        # x = cos(chord on small circle), -1: outside, 1: inside
        chord = 2*r1*sin(acos(x))
        area1 = areaFromChord(r1,chord)
        if x > 0:
            area1 = areaFromRadius(r1) - area1
        area2 = areaFromChord(r2,chord)
        return area1 + area2 < targetArea

    lo,hi = -1.0,1.0
    for i in range(100):
        mid = (hi+lo)/2
        if miniverTest(mid):
            lo = mid
        else:
            hi = mid
    chord = 2*r1*sin(acos(mid))
    return distanceToChord(r2,chord) - r1*mid

# Make it into a nice picture
# Monochromatic and with a loose frame for now; we'll fix it up later

gridUnit = 150
targetArea = 100000.0
boundingBox = (6+4j)*gridUnit
output = SVG(boundingBox,sys.stdout)
output.group(fill="none",stroke="#000")

for i in (0,1,2):
    ratio = 2.0**(i*0.25)
    areaWhenSmall = twoCircleArea(1.0,ratio)
    factor = (targetArea/areaWhenSmall)**0.5
    r1,r2 = factor,factor*ratio
    s = miniverSeparation(r1,r2)
    o = (1+2j+2*i)*gridUnit
    output.circle(o + (s+r2-r1)*0.5j, r1)
    output.circle(o - (s+r1-r2)*0.5j, r2)
  
output.ungroup()
output.close()
Category:Circles
Category:CC-Zero Category:Circles Category:Images with Python source code Category:Self-published work Category:Valid SVG created with Python