Skip to content

Instantly share code, notes, and snippets.

@santhoshtr
Created February 13, 2026 10:04
Show Gist options
  • Select an option

  • Save santhoshtr/6667b90c132d76e7572e462ee3c1942a to your computer and use it in GitHub Desktop.

Select an option

Save santhoshtr/6667b90c132d76e7572e462ee3c1942a to your computer and use it in GitHub Desktop.
Untitled Metapost Sample #metapost-sandbox
u := 1cm;
pickup pencircle scaled 0.6bp;
path fcurve;
fcurve := (0,-1.0u)
.. (1u,-0.6u)
.. (2u,-0.1u)
.. (3u,0.5u)
.. (4u,1.3u)
.. (5u,2.4u);
%%%%%%%%%%%% Рисунок 1
beginfig(1);
drawarrow (-0.5u,0)--(6u,0);
label.bot("x",(6u,0));
draw fcurve withpen pencircle scaled 1bp;
pair A,B;
A := point 0 of fcurve;
B := point length(fcurve) of fcurve;
draw (0,0)--(0,ypart A) dashed evenly;
draw (5u,0)--(5u,ypart B) dashed evenly;
label.top("a",(0,0));
label.top("b",(5u,0));
dotlabel.lft("A",A);
dotlabel.rt("B",B);
numeric xn;
pair An;
xn := 2;
An := point 3 of fcurve;
draw (xn*u,0)--(xn*u,ypart An) dashed evenly;
label.top("x_n",(xn*u,0));
dotlabel.lft("A_n",An);
draw An--B;
pair Pxn; % x_{n+1}
Pxn := ((xpart An + (xpart B - xpart An)
*(-ypart An)/(ypart B - ypart An)), 0);
drawdot Pxn;
label.top("x_(n+1)",Pxn);
endfig;
%%%%%%%%%%%% Рисунок 2
beginfig(2);
drawarrow (-0.5u,0)--(6u,0);
label.bot("x",(6u,0));
draw fcurve withpen pencircle scaled 1bp;
label.lft("y=f(x)",(0.2u,0.4u));
A := point 0 of fcurve;
B := point length(fcurve) of fcurve;
draw (0,0)--(0,ypart A) dashed evenly;
draw (5u,0)--(5u,ypart B) dashed evenly;
label.top("a",(0,0));
label.top("b",(5u,0));
dotlabel.lft("A",A);
dotlabel.rt("B",B);
pair C;
C := (3u,0);
drawdot C; label.top("C",C);
numeric xzero;
numeric xone;
pair Bzero,Bone;
xzero := 4.2; Bzero := (4.2u,1.8u);
xone := 3.4; Bone := (3.4u,0.9u);
draw (xzero*u,0)--Bzero dashed evenly;
draw (xone*u,0)--Bone dashed evenly;
label.top("x_0",(xzero*u,0));
label.top("x_1",(xone*u,0));
dotlabel.rt("B_0",Bzero);
dotlabel.rt("B_1",Bone);
draw Bzero--Bone;
endfig;
%%%%%%%%%%%% Рисунок 3
beginfig(3);
drawarrow (-0.5u,0)--(6u,0);
label.bot("x",(6u,0));
draw fcurve withpen pencircle scaled 1bp;
label.lft("y=f(x)",(0.2u,0.4u));
A := point 0 of fcurve;
B := point length(fcurve) of fcurve;
draw (0,0)--(0,ypart A) dashed evenly;
draw (5u,0)--(5u,ypart B) dashed evenly;
label.top("a",(0,0));
label.top("b",(5u,0));
dotlabel.lft("A",A);
dotlabel.rt("B",B);
pair Caxis,Bn;
Caxis := (3u,0); drawdot Caxis; label.top("C",Caxis);
Bn := (4.1u,1.6u);
draw (4.1u,0)--Bn dashed evenly;
label.top("x_n",(4.1u,0));
dotlabel.rt("B_n",Bn);
draw Bn--Caxis;
pair PxnB;
PxnB := ((xpart Bn + (xpart Caxis - xpart Bn)
*(-ypart Bn)/(ypart Caxis - ypart Bn)), 0);
drawdot PxnB;
label.bot("x_(n+1)",PxnB);
endfig;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment