Setting to help with overflow in Metapost
![](https://secure.gravatar.com/avatar/13a310a9e966d8e50f10029887c37493.jpg?s=120&d=mm&r=g)
All, This code is causing an overflow. Isn't there a setting that will allow bigger numbers? I am not looking for more code and/or rescaling code, but a setting that I know is there that will allow larger numbers. %mode=short \startcomponent section1exercises \project book \product chapter5/chapter5 \usemodule[newmat] \usemodule[math=ext] \usemodule[fig-base] \usefigurebase[figures/figlibSection1] \setupheadnumber[chapter][6] \setupheadnumber[section][1] \def\qor{\quad\text{or}\quad} \def\qqor{\qquad\text{or}\qquad} \def\qand{\quad\text{and}\quad} \def\qqand{\qquad\text{and}\qquad} \setupcolors[state=start] \definecolor[gridlines][s=0.7] \startMPinclusions color mygridcolor; mygridcolor=\MPcolor{gridlines}; color gridlines; gridlines:=\MPcolor{gridlines}; def vtick(expr pos)= draw ((0,-3)--(0,3)) shifted pos; enddef; def htick(expr pos)= draw ((-3,0)--(3,0)) shifted pos; enddef; def opendot(expr pos)= fill fullcircle scaled 4pt shifted pos withcolor white; draw fullcircle scaled 4pt shifted pos withcolor red; enddef; def filleddot(expr pos)= fill fullcircle scaled 4pt shifted pos withcolor red; draw fullcircle scaled 4pt shifted pos withcolor red; enddef; \stopMPinclusions \startuseMPgraphic{55_grid} for k=-5u step 1u until 5u: draw (k,-5u)--(k,5u) withcolor gridlines; draw (-5u,k)--(5u,k) withcolor gridlines; endfor; \stopuseMPgraphic \startuseMPgraphic{55_xy_axes} drawdblarrow (-5u,0)--(5u,0); label.rt(btex $\tfx x$ etex, (5u,0)); label.bot(btex $\tfx 5$ etex, (5u,0)); drawdblarrow (0,-5u)--(0,5u); label.top (btex $\tfx y$ etex, (0,5u)); label.lft(btex $\tfx 5$ etex, (0,5u)); \stopuseMPgraphic \startuseMPgraphic{1010_grid} for k=-10u step 1u until 10u: draw (k,-10u)--(k,10u) withcolor gridlines; draw (-10u,k)--(10u,k) withcolor gridlines; endfor; \stopuseMPgraphic \startuseMPgraphic{1010_xy_axes} drawdblarrow (-10u,0)--(10u,0); label.rt(btex $\tfx x$ etex, (10u,0)); label.bot(btex $\tfx 10$ etex, (10u,0)); drawdblarrow (0,-10u)--(0,10u); label.top (btex $\tfx y$ etex, (0,10u)); label.lft(btex $\tfx 10$ etex, (0,10u)); \stopuseMPgraphic \startuseMPgraphic{1010_xy_axes_ti} drawdblarrow (-10u,0)--(10u,0); label.rt(btex $\tfx x$ etex, (10u,0)); label.bot(btex $\tfx 10$ etex, (10u,0)); label.bot(btex $\tfx -10$ etex, (-10u,0)); drawdblarrow (0,-10u)--(0,10u); label.top (btex $\tfx y$ etex, (0,10u)); label.lft(btex $\tfx 10$ etex, (0,10u)); label.lft(btex $\tfx -10$ etex, (0,-10u)); \stopuseMPgraphic \startuseMPgraphic{05_grid} for k=0 step 1u until 5u: draw (k,0)--(k,5u) withcolor gridlines; draw (0,k)--(5u,k) withcolor gridlines; endfor; \stopuseMPgraphic \startuseMPgraphic{05_xy_axes} drawarrow (0,0)--(5u,0); label.rt(btex $\tfx x$ etex, (5u,0)); label.bot(btex $\tfx 5$ etex, (5u,0)); drawarrow (0,0)--(0,5u); label.top (btex $\tfx y$ etex, (0,5u)); label.lft(btex $\tfx 5$ etex, (0,5u)); \stopuseMPgraphic \startquestions % Exercise #29 \beginquestion \startquestion[ex:secqu.29] $p(x)=-x^6-4x^5+27x^4+78x^3+4x^2+376x-480$ \stopquestion \endquestion \beginlonganswer \startanswer %\startlinecorrection[blank] %\midaligned{\externalfigure[q25v][width=0.4\textwidth]} %\midaligned{\externalfigure[q25][width=0.4\textwidth]} %\stoplinecorrection \stopanswer \endlonganswer \beginshortanswer \startanswer Note that the leading term $-x^6$ (dashed) has the same end-behavior as the polynomial $p$. \startbuffer %initialize scale and draw axes numeric u; 20ux=2in; 10000uy=2in; drawdblarrow (-10ux,0)--(10ux,0); label.rt(btex $\tfx x$ etex, (10ux,0)); label.bot(btex $\tfx -10$ etex, (-10ux,0)); label.bot(btex $\tfx 10$ etex, (10ux,0)); drawdblarrow (0,-5000uy)--(0,5000uy); label.top(btex $\tfx y$ etex, (0,5000uy)); label.lft(btex $\tfx -5000$ etex, (0,-5000uy)); label.lft(btex $\tfx 15$ etex, (0,5000uy)); %leading term vardef lead(expr x)= -1*x*x*x*x*x*x enddef; %polynomial vardef p(expr x)= -1*x**6-4*x**5+27*x**4+78*x**3+4*x**2+376*x-480 enddef; %path p_lead path p_lead; p_lead:=(-4.1352,lead(-4.1352)); for x=-4.1352 step .1 until 4.1252: p_lead:=p_lead--(x,lead(x)); endfor; p_lead:=p_lead--(4.1252,lead(4.1252)); p_lead:=p_lead xyscaled(ux,uy); draw p_lead dashed evenly withcolor red; %path p_p path p_p; p_p:=(-6.5009,p(-6.5009)); for x=-6.5009 step .1 until 5.3356 : p_p:=p_p--(x,p(x)); endfor; p_p:=p_p--( 5.3356 ,p(5.3356)); p_p:=p_p xyscaled(ux,uy); drawdblarrow p_p withcolor blue; label.rt(btex $\tfx p(x)=-x^6-4x^5+27x^4+78x^3+4x^2+376x-480$ etex, (5.3356 ,p(5.3356 )) xyscaled(ux,uy)); \stopbuffer \startlinecorrection[blank] \midaligned{\processMPbuffer} \stoplinecorrection \stopanswer \endshortanswer % Exercise #30 \beginquestion \startquestion[ex:secqu.30] $p(x)=2x^4-3x^3+x-10$ \stopquestion \endquestion \beginlonganswer[-] \startanswer \stopanswer \endlonganswer \beginshortanswer[-] \startanswer \stopanswer \endshortanswer \stopquestions \placeanswers\kern0pt \stopcomponent
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
dwarnold45@cox.net wrote:
All,
This code is causing an overflow. Isn't there a setting that will allow bigger numbers?
That is not possible, I'm afraid. There is actually a macro file that uses logarithmic numbers and another one using strings as numbers, but neither can be used without extensive changes to your code. My suggestion would be to use gnuplot. Greetings, taco
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
dwarnold45@cox.net wrote:
All,
This code is causing an overflow. Isn't there a setting that will allow bigger numbers?
4096bp is the default max with (in metafun) 32K being the insecure max; next year there will be a metapost that has a higher limit Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
dwarnold45@cox.net
-
Hans Hagen
-
Taco Hoekwater