A unit square has a fixed position. A second unit square overlaps the first. The overlap is a rectangle with area 1/2.
Find the area enclosed by the locus of the center of the second square.
clearvars
% overlap height * width must equal 1/2
% (1-x)*(1-y)=.5 (first quadrant)
% y = (1 - 2*x)/(2 - 2*x) and x~=1
for dx=[.005,.0005,.00005,.000005,.0000001]
i=1; tot=0;
for x=0:dx:.5
% fprintf('%4.2f %8.6f\n',x,(1-2*x)/(2-2*x))
xx(i)=x; yy(i)=(1-2*x)/(2-2*x);
i=i+1;
term=(1-2*x)/(2-2*x)*dx;
if x==0
term=term/2;
end
tot=tot+term;
end
4*tot
end
ans =
0.613693139036351
ans =
0.613705513880126
ans =
0.613705637630108
ans =
0.613705638867625
ans =
0.613705638880112
are finer and finer numericalintegrations.
Wolfram Alpha:
integral(1 - 2 x)/(2 - 2 x) dx = x + 1/2 log(1 - x) + constant
(assuming a complex-valued logarithm)
4 integral_0^0.5 (1 - 2 x)/(2 - 2 x) dx = 0.613706
>> x0=0; x1=.5;
>> 4*(x1 + 1/2 * log(1 - x1)- (x0 + 1/2* log(1 - x0)))
ans =
0.613705638880109
|
Posted by Charlie
on 2024-07-03 13:42:53 |