fn <- function(r,s){
sub <- function(c,Area1=1){
b0=(c^2+r^2-s^2)/(2*c) # B(b0,b1)
b1=sqrt(r^2-(c^2+r^2-s^2)^2/(4*c^2))
# blue = function(x) sqrt(s^2-(x-c)^2)
Blue = function(x) (x - c)* sqrt(s^2-c^2 + 2*c*x - x^2) +
s^2*atan((x - c)/sqrt(s^2 - (c - x)^2))
# green = function(x) sqrt(r^2-x^2)
Green = function(x) x*sqrt(r^2 - x^2) + r^2*atan(x/sqrt(r^2 - x^2))
BLUE=2*(Blue(c+s) - Blue(b0))
# BLUE= integrate(blue,b0,c+s)$value*2
GREEN=2*(Green(b0)-Green(-r))
# GREEN=integrate(green,-r,b0)$value*2
GREEN+BLUE-Area1
}
sub=Vectorize(sub)
x=seq(-r-s,r-s,length=100) ; plot(x,sub(x),pch=19) ; abline(h=0,lty=3)
warnings()
(c=uniroot(sub,c(-r-s,r-s))$root)
b0=(c^2+r^2-s^2)/(2*c)
b1=sqrt(r^2-(c^2+r^2-s^2)^2/(4*c^2))

sub2 <- function(R,Area2=2){
a=b0+sqrt(R^2-b1^2)
Blue = function(x) (x - c)* sqrt(s^2-c^2 + 2*c*x - x^2) +
s^2*atan((x - c)/sqrt(s^2 - (c - x)^2))
BLUE=2*(Blue(c+s) - Blue(b0))
# blue = function(x) sqrt(s^2-(x-c)^2)
# BLUE = integrate(blue,b0,c+s)$value*2
Red = function(x) x*sqrt(R^2 - x^2) + R^2*atan(x/sqrt(R^2 - x^2))
RED = 2*(Red(a+R) - Red(b0))
# red = function(x) sqrt(R^2-(x-a)^2)
# RED = integrate(red,b0,a+R)$value*2 - BLUE
RED - Area2
}

sub2=Vectorize(sub2)
# x=seq(r,s,0.001) ; plot(x,sub2(x)) ; abline(h=0,lty=3)
(R=uniroot(sub2,c(r,s))$root)
arcGreen = 2*pi*r-2*r*asin(b1/r)
arcBlue = 2*s*asin(b1/s)
arcRed = 2*pi*R-2*R*asin(b1/R)
arcGreen+arcBlue+arcRed
}
fn=Vectorize(fn)
fn(2/3,2)