D:\jknuba_2025_spring\jknuba_NM\jknuba_MSC_Job1\jknuba_MSC_Job1f.wxmx  27.02.2025

pg1:if x<(x0-1/1000) then f0 else if x<x0+1/1000 then 5000 else f1;

kill(all);

ro:1000$g:9.81$R:1$

fP(R,h):=6540.0*(R**2-(R-h)^2)^(3/2);Px:fP(R,R)/2,numer;

fPfull(R,x):=6540.0*(R**2-(R-x)^2)^(3/2)-Px;

fPi(R,h):=6540.0*(R**2-(R-h)^2)^(3/2)-Px;fPi(R,0.1);

-----    start     -----

x1:0;x2:R;

vx1[0]:x1;vx2[0]:x2;

-----    cycle 1     -----

x1:vx1[0];x2:vx2[0];

dx:(x2-x1)/2+x1;

Pi:fPi(R,dx),numer;

test_rel:Pi/(Px/100);

fl - flag of number of moved zone 1 or 2

if Pi > 0 then (x2:dx,fl:2) else (x1:dx,fl:1);fl;

x1;x2;y1:fPi(R,x1),numer;y2:fPi(R,x2),numer;

save coordinates of cycle 1

vx1[1]:x1;vx2[1]:x2;vx1[1];vx2[1];

if f = 2 then xi:x1 else xi:x2;

xd:[[x1,fPi(R,xi)],[x2,fPi(R,xi)]];

xs:[[vx1[0],fPi(R,vx1[1])],[vx2[0],fPi(R,vx1[1])]];

coordinates of vertical Line

if fl = 2 then (xv:x2) else (xv:x1);

x_ver:[[xv,0],[xv,fPi(R,xv)]];

plot2d([fPi(R,n),[discrete,xs],[discrete,xd],[discrete,x_ver]],[n,0,R],[color, red, blue,green,red],grid2d,[title, "A dichotomies"],[style, [lines,1]]);

plot2d([fPi(R,n),[discrete,xs],[discrete,xd],[discrete,x_ver]],[n,0,R],[color, red, blue,green,red],grid2d,[title, "A dichotomies"]);

plot2d([[discrete,[[0,0], [1,1], [1.5,(1.5)^2]]],[discrete,[[0,0.1], [0.75,1], [1.25,1.5]]]],[style, [points, 1, red, 1 ], [points, 1.5, blue, 1]]);

-----    cycle 2     -----

x1:vx1[1];x2:vx2[1];

dx:(x2-x1)/2+x1;

Pi:fPi(R,dx),numer;

test_rel:Pi/(Px/100);

fl - flag of number of moved zone 1 or 2

if Pi > 0 then (x2:dx,fl:2) else (x1:dx,fl:1);fl;

x1;x2;y1:fPi(R,x1),numer;y2:fPi(R,x2),numer;

save coordinates of cycle 2

vx1[2]:x1;vx2[2]:x2;

xd:[[vx1[2],fPi(R,vx1[2])],[vx2[2],fPi(R,vx1[2])]];

xs:[[vx1[0],fPi(R,0)],[vx2[0],fPi(R,0)]];

xs2:[[vx1[1],fPi(R,vx2[1])],[vx2[1],fPi(R,vx2[1])]];

plot2d([fPi(R,n),[discrete,xs2],[discrete,xs],[discrete,xd]],[n,0,R],[color, red, blue,green,red],grid2d, [title, "A dichotomies"],[style, [lines,5,1],[lines,2,2], [lines,3,3],[lines,4,4]]);

-----    cycle 3     -----

vx1[2]:x1;x2[2]:x2;

dx:(x2-x1)/2+x1$

Pi:fPi(R,dx),numer$

test_rel:Pi/(Px/100);

fl - flag of number of moved zone 1 or 2

if Pi > 0 then (x2:dx,fl:2) else (x1:dx,fl:1)$fl;

x1;x2;y1:fPi(R,x1),numer;y2:fPi(R,x2),numer;

save coordinates of cycle 3

vx1[3]:x1$vx2[3]:x2$

xd:[[vx1[3],fPi(R,vx1[3])],[vx2[3],fPi(R,vx1[3])]];

xs:[[vx1[0],fPi(R,0)],[vx2[0],fPi(R,0)]];

xs2:[[vx1[1],fPi(R,vx2[1])],[vx2[1],fPi(R,vx2[1])]];

xs3:[[vx1[2],fPi(R,vx1[2])],[vx2[2],fPi(R,vx1[2])]];

plot2d([fPi(R,n),[discrete,xs3],[discrete,xs2],[discrete,xs],[discrete,xd]],[n,0,R],[color, red, blue,green,yellow,blue],grid2d, [title, "A dichotomies"],[style, [lines,5,1],[lines,2,2], [lines,3,3],[lines,4,4],[lines,2,2]]);

-----    cycle 4     -----

vx1[3]:x1;x2[3]:x2;

dx:(x2-x1)/2+x1$Pi:fPi(R,dx),numer$

test_rel:Pi/(Px/100);

fl - flag of number of moved zone 1 or 2

if Pi > 0 then (x2:dx,fl:2) else (x1:dx,fl:1)$fl;

x1;x2;y1:fPi(R,x1),numer;y2:fPi(R,x2),numer;

save coordinates of cycle 4

vx1[4]:x1$vx2[4]:x2$

xd:[[vx1[3],fPi(R,vx1[3])],[vx2[3],fPi(R,vx1[3])]];

xs:[[vx1[0],fPi(R,0)],[vx2[0],fPi(R,0)]];

xs2:[[vx1[1],fPi(R,vx2[1])],[vx2[1],fPi(R,vx2[1])]];

xs3:[[vx1[2],fPi(R,vx1[2])],[vx2[2],fPi(R,vx1[2])]];

xs4:[[vx1[4],fPi(R,vx2[4])],[vx2[4],fPi(R,vx2[4])]];

plot2d([fPi(R,n),[discrete,xs4],[discrete,xs3],[discrete,xs2],[discrete,xs],[discrete,xd]],[n,0,R],[color, red, blue,green,yellow,blue,green],grid2d, [title, "A dichotomies"],[style, [lines,5,1],[lines,2,2], [lines,3,3],[lines,4,4],[lines,2,2],[lines,3,1]]);

vx1[1],numer;fPi(R,vx2[1]),numer;fPi(R,vx1[1]),numer;

vx1[2],numer;fPi(R,vx2[2]),numer;fPi(R,vx1[2]),numer;

vx1[3],numer;vx2[3],numer;fPi(R,vx2[3]),numer;fPi(R,vx1[3]),numer;

vx1[4],numer;vx2[4],numer;fPi(R,vx2[4]),numer;fPi(R,vx1[4]),numer;