summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/bpolynomial/examples.mp
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/metapost/bpolynomial/examples.mp')
-rw-r--r--Master/texmf-dist/doc/metapost/bpolynomial/examples.mp73
1 files changed, 73 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/metapost/bpolynomial/examples.mp b/Master/texmf-dist/doc/metapost/bpolynomial/examples.mp
new file mode 100644
index 00000000000..135b7881fdc
--- /dev/null
+++ b/Master/texmf-dist/doc/metapost/bpolynomial/examples.mp
@@ -0,0 +1,73 @@
+input bpolynomial;
+input graph
+prologues := 3;
+
+
+beginfig(1);
+ newBPolynomial.f(2, 0, -3, -1);
+ draw f.getPath(-2, 2) xscaled 1cm yscaled 0.1cm;
+endfig;
+
+
+beginfig(2);
+ newBPolynomial.f(2, 0, -3, -1);
+ for x=-2 step .25 until 2:
+ label(btex $\star$ etex, (x, f.eval(x)) xscaled 1cm yscaled 0.1cm);
+ endfor
+endfig;
+
+
+beginfig(3);
+numeric u;
+u := 0.5cm;
+ %%% Draw a coordinate system.
+ xmin := -5; xmax := 6;
+ ymin := -5; ymax := 6;
+ drawarrow ((xmin,0)--(xmax,0)) scaled u;
+ drawarrow ((0,ymin)--(0,ymax)) scaled u;
+ drawoptions(withpen pencircle scaled 1bp);
+ %%% Define polynomial f of degree 2.
+path f[];
+ newBPolynomial.f(0, 0.5, -2, 0);
+ f1 := f.getPath(-2, 0);
+ f2 := f.getPath(0, 4);
+ f3 := f.getPath(4, 5.5);
+ draw f1 scaled u dashed evenly scaled 2;
+ draw f3 scaled u dashed evenly scaled 2;
+ draw f2 scaled u dashed withdots
+ withpen pencircle scaled 1.5bp withcolor .5white;
+ %%% Define polynomial g of degree 3.
+path g;
+ newBPolynomial.g(0.3, 0, -3, -1);
+ g := g.getPath(-3.5, 4);
+ show g;
+ draw g scaled u;
+ %%% Write table with some points of g to log file.
+ show "Polynomial: " & decimal g.a & "x^3+" & decimal g.b
+ & "x^2+" & decimal g.c & "x+" & decimal g.d;
+ for x=-5 upto 5:
+ show (x, g.eval(x));
+ endfor
+endfig;
+
+
+beginfig(4);
+path f,g;
+ xmin := -7; xmax := 7;
+ ymin := -7; ymax := 7;
+ newBPolynomial.f(0, 0.5, -2, 0);
+ f := f.getPath(xmin, xmax);
+ newBPolynomial.g(0.3, 0, -3, -1);
+ g := g.getPath(xmin, xmax);
+ draw begingraph(10cm, 6cm);
+ setrange(xmin,ymin, xmax,ymax);
+ autogrid(grid.bot, grid.lft)
+ dashed withdots withpen pencircle scaled .7bp withcolor .5white;
+ drawoptions(withpen pencircle scaled 1bp);
+ gdraw f dashed evenly scaled 2;
+ gdraw g;
+ drawoptions();
+ endgraph;
+endfig;
+
+end