Download A Tutorial for Pari/GP
Transcript
plotstring(2, lims[3], bottom+vgap+right+hgap) plotmove(2, 0.98,0.1); plotstring(2, lims[2], right+top+vgap) plotmove(2, 0.1,0.98); plotstring(2, lims[4], right+hgap+top) plotdraw([2, 0,0, 3, 0.1,0.02], relative) We started with a trivial requirement: have an additional frame around the graph, and it took some effort to do so. But at least it was possible, and PARI did the hardest part: creating the actual graph. Now do a different thing: plot together the “exact” graph of ζ(1/2 + it) together with one obtained from splines approximation. We can emit these graphs into two rectangles, say 0 and 1, then put these two rectangles together on one plot. Or we can emit these graphs into one rectangle 0. However, a problem arises: note how we introduced a coordinate system in rectangle 2 of the above example, but we did not introduce a coordinate system in rectangle 3. Plotting a graph into rectangle 3 automatically created a coordinate system inside this rectangle (you could see this coordinate system in action if your output device supports mouse operations). If we use two different methods of graphing, the bounding boxes of the graphs will not be exactly the same, thus outputting the rectangles may be tricky. Thus during the second plotting we ask plotrecth to use the coordinate system of the first plotting. Let us add another plotting with fewer points too: plotinit(0, 0.9,0.9, relative) plotrecth(0, t=100,110, f(t), "Parametric",300) plotrecth(0, t=100,110, f(t), "Parametric|Splines|Points_too|no_Rescale",30); plotrecth(0, t=100,110, f(t), "Parametric|Splines|Points_too|no_Rescale",20); plotdraw([0, 0.05,0.05], relative) This achieves what we wanted: we may compare different ways to plot a graph, but the picture is confusing: which graph is what, and why there are multiple boxes around the graph? At least with some output devices one can control how the output curves look like, so we can use this to distinguish different graphs. And the mystery of multiple boxes is also not that hard to solve: they are bounding boxes for calculated points on each graph. We can disable output of bounding boxes with appropriate options for plotrect. With these frills the script becomes: plotinit(0, 0.9,0.9, relative) plotpointtype(-1, 0) \\ set color of graph points plotpointsize(0, 0.4) \\ use tiny markers (if available) plotrecth(0, t=100,110, f(t), "Parametric|no_Lines", 300) plotpointsize(0, 1) \\ normal-size markers plotlinetype(-1, 1) \\ set color of graph lines plotpointtype(-1, 1) \\ set color of graph points opts="Parametric|Splines|Points_too|no_Rescale|no_Frame|no_X_axis|no_Y_axis"; plotrecth(0, t=100,110,f(t), opts, 30); plotlinetype(-1, 2) \\ set color of graph lines plotpointtype(-1, 2) \\ set color of graph points plotrecth(0, t=100,110,f(t), opts, 20); plotdraw([0, 0.05,0.05], relative) Plotting axes on the second and third graph would not hurt, but is not needed either, so we omit them. One can see that the discrepancies between the exact graph and one based on 30 points exist, but are pretty small. On the other hand, decreasing the number of points to 20 makes quite a noticeable difference. 48