D:\jknuba_2025_spring\jknuba_NM\jknuba_NM_Job6.wxmx

# Метод ітерацій (Method of iterations)

kill(all);

M(x):=0.9*x;

N(x):=2.2*(x+1)-5;

X(n):=((n+5)/2.2)-1;

R(x):=N(x)-M(x);

 plot2d([M(x),N(x)],[x,0,5],
   [legend, "M(x)","N(x)"],
   [style, [lines, 3,5],  [lines, 3,1]]); 

Iteration 1

delta:0.1;

i:0;

m:M(i);o:X(m);

if (M(o)-N(o)<delta)then display("OK")else display(M(o)-N(o));

o;N(o);

plot2d([M(x),N(x),[discrete,[i,o],[M(i),N(o)]], [discrete,[o],[N(o)]]],[x,0,5],
   [legend, "M(x)","N(x)", "Iteration", "point"],
   [style, [lines, 3,5],  [lines, 3,1], [lines, 2,2], [points,6,1 ]]); 

Iteration 2

plot2d([M(x),N(x),[discrete,[i,o],[M(i),N(o)]],[discrete,[o,o],[M(o),N(o)]],[discrete,[o],[N(o)]]],[x,0,5],
   [legend, "M(x)","N(x)", "Iteration","Iteration_2",  "point"],
   [style, [lines, 3,5],  [lines, 3,1], [lines, 2,2],[lines, 5,3],  [points,6,1 ]])$

i:o;

m:M(i);o:X(m);

if (M(o)-N(o)<delta)then display("OK")else display(M(o)-N(o));

plot2d([M(x),N(x),[discrete,[i,o],[M(i),N(o)]],[discrete,[o,o],[M(o),N(o)]],[discrete,[o],[N(o)]]],[x,0,5],
   [legend, "M(x)","N(x)", "Iteration_2","Iteration_3",  "point"],
   [style, [lines, 3,5],  [lines, 3,1], [lines, 2,2],[lines, 5,3],  [points,6,1 ]])$

Iteration 3

i:o;

m:M(i);o:X(m);

if (M(o)-N(o)<delta)then display("OK")else display(M(o)-N(o));

plot2d([M(x),N(x),[discrete,[i,o],[M(i),N(o)]],[discrete,[o,o],[M(o),N(o)]],[discrete,[o],[N(o)]]],[x,0,5],
   [legend, "M(x)","N(x)", "Iteration_3","Iteration_4",  "point"],
   [style, [lines, 3,5],  [lines, 3,1], [lines, 2,2],[lines, 5,3],  [points,6,1 ]])$

Iteration 4

i:o;

m:M(i);o:X(m);

if (M(o)-N(o)<delta)then display("OK",M(o)-N(o))else display(M(o)-N(o));

plot2d([M(x),N(x),[discrete,[i,o],[M(i),N(o)]],[discrete,[o,o],[M(o),N(o)]],[discrete,[o],[N(o)]]],[x,0,5],
   [legend, "M(x)","N(x)", "Iteration_4","Iteration_5",  "point"],
   [style, [lines, 3,5],  [lines, 3,1], [lines, 2,2],[lines, 5,3],  [points,6,1 ]])$

plot2d([M(x),N(x),[discrete,[i,o],[M(i),N(o)]],[discrete,[o,o],[M(o),N(o)]],[discrete,[o],[N(o)]]],[x,1.9,2.3],
   [legend, "M(x)","N(x)", "Iteration_4","Iteration_5",  "point"],
   [style, [lines, 3,5],  [lines, 3,1], [lines, 2,2],[lines, 5,3],  [points,6,1 ]])$

del:M(o)-N(o);