From: David Arnold <dwarnold45@cox.net>
Subject: Arithmetic Overflow
Date: Thu, 5 Jan 2006 18:15:22 -0800 [thread overview]
Message-ID: <D37A70AA-114C-45F2-A82B-755A8F409454@cox.net> (raw)
All, Is there a switch I can set to get rid of the arithmetic
overflow in the following example?
%output=pdf
\setupcolors[state=start]
\definecolor[gridlines][s=0.7]
\startMPinclusions
color gridlines; gridlines:=\MPcolor{gridlines};
vardef create_grid (expr l,r,h,b,t,v,wid,ht)=
save ux, uy; numeric ux, uy;
(r-l)*ux=wid; (t-b)*uy=ht;
for k=b step v until t:
draw (l*ux,k*uy)--(r*ux,k*uy) withcolor \MPcolor{gridlines};
endfor;
for k=l step h until r:
draw (k*ux,b*uy)--(k*ux,t*uy) withcolor \MPcolor{gridlines};
endfor;
enddef;
vardef create_axes (expr l,r,b,t,wid,ht,blbl) (text xlbl,ylbl) =
save ux, uy; numeric ux, uy;
(r-l)*ux=wid; (t-b)*uy=ht;
textextoffset:=3pt;
drawdblarrow (1.05*l*ux,0)--(1.05*r*ux,0);
draw textext.rt(xlbl) shifted (1.05*r*ux,0);
if blbl:draw textext.bot(decimal r) shifted (r*ux,0); fi;
drawdblarrow (0,1.05*b*uy)--(0,1.05*t*uy);
draw textext.top(ylbl) shifted (0,1.05*t*uy);
if blbl: draw textext.lft(decimal t) shifted (0,t*uy); fi;
enddef;
vardef drawfcn (expr ind,dep,l,r,b,t,wid,ht,n) text txt =
save x, dx, ux, uy; numeric x, dx, ux, uy;
dx:=(r-l)/n;
(r-l)*ux=wid; (t-b)*uy=ht;
save cpath; path cpath; cpath:=(l,b)--(r,b)--(r,t)--(l,t)--cycle;
save p; path p; hide (x:=l;) p:=(scantokens(ind),scantokens(dep));
for xx:=l step dx until r:
hide (x:=xx;) p:=p--(scantokens(ind),scantokens(dep));
endfor;
hide(x:=r;) p:=p--(scantokens(ind),scantokens(dep));
p:=p cutbefore cpath;
p:=reverse p;
p:=p cutbefore cpath;
p:=p xyscaled (ux,uy);
drawdblarrow p txt;
enddef;
\stopMPinclusions
\starttext
\startMPpage %figure library name: x2
%initialize window parameters
numeric xmin, xmax, xscl, ymin, ymax, yscl;
xmin:=-10;
xmax:=10;
xscl:=1;
ymin:=-10;
ymax:=10;
yscl:=1;
%initialize number of points
numeric num_points;
num_points:=100;
%initialize dimensions of image
numeric width, height;
width=1.5in;
height=1.5in;
%create the grid
create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height);
boolean lbl_scl; lbl_scl:=true;
%create the axes
create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)("$x$")("$y$");
%draw the function
drawfcn("x","x*x",xmin,xmax,ymin,ymax,width,height,100)
withcolor blue ;
\stopMPpage
\startMPpage %figure library name: x4
%initialize window parameters
numeric xmin, xmax, xscl, ymin, ymax, yscl;
xmin:=-10;
xmax:=10;
xscl:=1;
ymin:=-10;
ymax:=10;
yscl:=1;
%initialize number of points
numeric num_points;
num_points:=100;
%initialize dimensions of image
numeric width, height;
width=1.5in;
height=1.5in;
%create the grid
create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height);
boolean lbl_scl; lbl_scl:=true;
%create the axes
create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)("$x$")("$y$");
%draw the function
drawfcn("x","x**4",xmin,xmax,ymin,ymax,width,height,100)
withcolor blue ;
\stopMPpage
\startMPpage %figure library name: x6
%initialize window parameters
numeric xmin, xmax, xscl, ymin, ymax, yscl;
xmin:=-10;
xmax:=10;
xscl:=1;
ymin:=-10;
ymax:=10;
yscl:=1;
%initialize number of points
numeric num_points;
num_points:=100;
%initialize dimensions of image
numeric width, height;
width=1.5in;
height=1.5in;
%create the grid
create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height);
boolean lbl_scl; lbl_scl:=true;
%create the axes
create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)("$x$")("$y$");
%draw the function
drawfcn("x","x**6",xmin,xmax,ymin,ymax,width,height,100)
withcolor blue ;
\stopMPpage
\stoptext
%%% Local Variables:
%%% mode: conTeXt-en
%%% End:
next reply other threads:[~2006-01-06 2:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-06 2:15 David Arnold [this message]
2006-01-06 6:09 ` David Arnold
2006-01-06 8:14 ` Taco Hoekwater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D37A70AA-114C-45F2-A82B-755A8F409454@cox.net \
--to=dwarnold45@cox.net \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).