User:Azjps/geogebra

Gallery of examples: The following Asymptote codes were all generated from Geogebra files (File > Export > Graphics View as Asymptote ...). It is available in the current release of the Geogebra 4.0 Beta version. To download Geogebra 4.0, go here and either choose the webstart (direct) version or choose one of the 3.9 version offline installers (as beta versions, there may unfixed bugs, although the versions are for the most part stable.)

Documentation

Here is a fairly simple example that breaks down the contents of the output code, with Fill type set at "By layering".

[asy]  /* Geogebra to Asymptote conversion, documentation at userscripts.org/scripts/show/72997 */ import graph; size(14.26cm);  real labelscalefactor = 0.5; /* changes label-to-point distance */ pen dps = linewidth(0.7) + fontsize(10); defaultpen(dps); /* default pen style */  pen dotstyle = black; /* point style */  real xmin = -6.22,xmax = 8.04,ymin = -4.18,ymax = 4.76;  /* image dimensions */ pen fueaev = rgb(0.96,0.92,0.9); pen zzttqq = rgb(0.6,0.2,0);   real f2 (real x) {return sin(x);}  filldraw(graph(f2,0,pi )--(pi ,0)--(0,0)--cycle, fueaev, zzttqq);  filldraw((-3.14,0)--(0,0)--(0,3.14)--(-3.14,pi )--cycle, fueaev, zzttqq);  Label laxis; laxis.p = fontsize(10); string xaxislabel (real x) {int n=round(x/pi); if(n==-1) return "$-\pi$"; if(n==1) return "$\pi$"; if(n==0) return "$0$"; return "$" + string(n) + "\pi$";} string yaxislabel (real x) {return "$" + string(x) + "\,\mathrm{}$";}  xaxis("$x$",-6.22,8.04,Ticks(laxis,xaxislabel,Step=3.141592653589793,Size=2),Arrows(6),above=true);  yaxis(-4.18,4.76,Ticks(laxis,yaxislabel,Step=1.0,Size=2),Arrows(6),above=true);   /* draw figures */ real f1 (real x) {return sin(x);}  draw(graph(f1,-6.21,8.03));  draw((-3.14,0)--(0,0), zzttqq);  draw((0,0)--(0,3.14), zzttqq);  draw((0,3.14)--(-3.14,pi ), zzttqq);  draw((-3.14,pi )--(-3.14,0), zzttqq);  draw(circle((0,3.14),1.14)); draw(shift((3.35,2.06))*rotate(1)*xscale(1.59)*yscale(1.1)*unitcircle);  pair hyperbolaLeft1 (real t) {return (0.49*(1+t^2)/(1-t^2),1.04*2*t/(1-t^2));} pair hyperbolaRight1 (real t) {return (0.49*(-1-t^2)/(1-t^2),1.04*(-2)*t/(1-t^2));}  draw(shift((3.35,2.06))*rotate(1)*graph(hyperbolaLeft1,-0.99,0.99)); draw(shift((3.35,2.06))*rotate(1)*graph(hyperbolaRight1,-0.99,0.99)); /* hyperbola construction */  /* dots and labels */ label("$f$",(-6.12,-0.12),NE * labelscalefactor);  label("$a = 2$",(1.46,0.24),NE * labelscalefactor,zzttqq);  dot((-3.14,0),dotstyle);  label("$A$",(-3.06,0.12),NE * labelscalefactor);  dot((2.2,2.04),dotstyle);  dot((4.5,2.08),dotstyle);  clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle);   /* end of picture */ [/asy]

Here is the Asymptote code produced: (with some spacing added)

 /* Geogebra to Asymptote conversion, documentation at userscripts.org/scripts/show/72997 */
import graph; size(14.26cm); 
real labelscalefactor = 0.5; /* changes label-to-point distance */
pen dps = linewidth(0.7) + fontsize(10); defaultpen(dps); /* default pen style */ 
pen dotstyle = black; /* point style */ 
real xmin = -6.22,xmax = 8.04,ymin = -4.18,ymax = 4.76;  /* image dimensions */
pen fueaev = rgb(0.96,0.92,0.9); pen zzttqq = rgb(0.6,0.2,0); 

real f2 (real x) {return sin(x);} 
filldraw(graph(f2,0,pi )--(pi ,0)--(0,0)--cycle, fueaev, zzttqq); 
filldraw((-3.14,0)--(0,0)--(0,3.14)--(-3.14,pi )--cycle, fueaev, zzttqq); 
Label laxis; laxis.p = fontsize(10); 
string xaxislabel (real x) {
 int n=round(x/pi); 
 if(n==-1) return "<math>-\pi</math>"; 
 if(n==1) return "<math>\pi</math>"; 
 if(n==0) return "<math>0</math>"; 
 return "<math>" + string(n) + "\pi</math>";} 
string yaxislabel (real x) {return "<math>" + string(x) + "\,\mathrm{}</math>";} 
xaxis("<math>x</math>",-6.22,8.04,Ticks(laxis,xaxislabel,Step=3.141592653589793,Size=2),Arrows(6),above=true); 
yaxis(-4.18,4.76,Ticks(laxis,yaxislabel,Step=1.0,Size=2),Arrows(6),above=true); 

 /* draw figures */
real f1 (real x) {return sin(x);} 
draw(graph(f1,-6.21,8.03)); 
draw((-3.14,0)--(0,0), zzttqq); 
draw((0,0)--(0,3.14), zzttqq); 
draw((0,3.14)--(-3.14,pi ), zzttqq); 
draw((-3.14,pi )--(-3.14,0), zzttqq); 
draw(circle((0,3.14),1.14)); draw(shift((3.35,2.06))*rotate(1)*xscale(1.59)*yscale(1.1)*unitcircle); 
pair hyperbolaLeft1 (real t) {return (0.49*(1+t^2)/(1-t^2),1.04*2*t/(1-t^2));} 
pair hyperbolaRight1 (real t) {return (0.49*(-1-t^2)/(1-t^2),1.04*(-2)*t/(1-t^2));} 
draw(shift((3.35,2.06))*rotate(1)*graph(hyperbolaLeft1,-0.99,0.99)); 
draw(shift((3.35,2.06))*rotate(1)*graph(hyperbolaRight1,-0.99,0.99)); /* hyperbola construction */

 /* dots and labels */
label("<math>f</math>",(-6.12,-0.12),NE * labelscalefactor); 
label("<math>a = 2</math>",(1.46,0.24),NE * labelscalefactor,zzttqq); 
dot((-3.14,0),dotstyle); 
label("<math>A</math>",(-3.06,0.12),NE * labelscalefactor); 
dot((2.2,2.04),dotstyle); 
dot((4.5,2.08),dotstyle); 
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); 
 /* end of picture */

Here is a line-by-line explanation: ($\texttt{/* COMMENT */}$ are comments that are not read by the Asymptote engine.)

$\texttt{import graph; size(14.26cm); }$ are the opening commands: any files that need to be imported (in this case, graph), followed by the horizontal size in centimeters, as shown by the Export to Asymptote window.

$\texttt{real labelscalefactor = 0.5; /* changes label-to-point distance */}$ This variable scales the distance that labels are from their defined locations on the Geogebra window. This is due to an innate difference in the Asymptote and Geogebra treatment of labels: Geogebra positions labels with respect to a corner of the label, but Asymptote positions labels with respect to the center. Also, both have different default font sizes. The larger the value of $\texttt{labelscalefactor}$, the farther the Asymptote labels are dislocated from their respective points. Usually, $\texttt{labelscalefactor}$ will have to be lowered to better position the labels (truer for longer labels). In concise mode, this variable is abbreviated as $\texttt{lsf}$.

pen dps = linewidth(0.7) + fontsize(10); defaultpen(dps); /* default pen style */ 
pen dotstyle = black; /* point style */ 

These are the definition of the default pens to use. $\texttt{dps}$ stands for default pen style and produces the default pen style. $\texttt{dotstyle}$ stands for the default dot style. In concise mode, the latter is abbreviated as $\texttt{ds}$, and in cse5, this option is completely replaced by the pen $\texttt{pointpen}$.

real xmin = -6.22,xmax = 8.04,ymin = -4.18,ymax = 4.76; /* image dimensions */ }

As the comment suggests, these four variables define the boundaries of the picture (in the units of the picture). Rays and lines that go out of the picture are defined in terms of these variables, as well as the clip window. Thus, changing these variables should keep intact most of the Asymptote contents.

pen fueaev = rgb(0.96,0.92,0.9); pen zzttqq = rgb(0.6,0.2,0);

These pens are custom defined colors, which are actually defined by hexadecimal values of the associated colors. The colors can be changed in this line (changing a specific shade to a darker shade, for example).

filldraw((-3.14,0)--(0,0)--(0,3.14)--(-3.14,pi )--cycle, fueaev, zzttqq);

This $\texttt{filldraw}$ command draws a square in the picture. Of note is that if the axes are defined in terms of pi, then some coordinates are defined in terms of the Asymptote variable $\texttt{pi}$. The command changes to $\texttt{draw}$ if the Fill type is set to "None".

real f2 (real x) {return sin(x);} 
filldraw(graph(f2,0,pi )--(pi ,0)--(0,0)--cycle, fueaev, zzttqq); 

Some commands have to be defined with respect to a function. $\texttt{f2}$ returns the $\sin(x)$ function, and the $\texttt{graph}$ command draws $\texttt{f2}$ from $x = 0$ to $x = \pi$.

Label laxis; laxis.p = fontsize(10); 
string xaxislabel (real x) {
 int n=round(x/pi); 
 if(n==-1) return "<math>-\pi</math>"; 
 if(n==1) return "<math>\pi</math>"; 
 if(n==0) return "<math>0</math>"; 
 return "<math>" + string(n) + "\pi</math>";} 
string yaxislabel (real x) {return "<math>" + string(x) + "\,\mathrm{}</math>";} 
xaxis("<math>x</math>",-6.22,8.04,Ticks(laxis,xaxislabel,Step=3.141592653589793,Size=2),Arrows(6),above=true); 
yaxis(-4.18,4.76,Ticks(laxis,yaxislabel,Step=1.0,Size=2),Arrows(6),above=true); 

These commands draw the axes. The $\texttt{laxis}$ label specifies the label styles of the axes (e.g., the field $\texttt{laxis.p}$ defines the desired font pen).

The next line, the

string xaxislabel (real x) {
 int n=round(x/pi); 
 if(n==-1) return "<math>-\pi</math>"; 
 if(n==1) return "<math>\pi</math>"; 
 if(n==0) return "<math>0</math>"; 
 return "<math>" + string(n) + "\pi</math>";} 
string yaxislabel (real x) {return "<math>" + string(x) + "\,\mathrm{}</math>";} 

are functions that define the labels for both axes. These are abbreviated as $\texttt{xlbl, ylbl}$ in the concise mode. The first defines axes with labels with respect to $\pi$, and it formats the labels so that the $0$ label simply outputs $0$ instead of $0\pi$, and $\pm \pi$ instead of $\pm 1\pi$. Finally,

xaxis("<math>x</math>",-6.22,8.04,Ticks(laxis,xaxislabel,Step=3.141592653589793,Size=2),Arrows(6),above=true); 
yaxis(-4.18,4.76,Ticks(laxis,yaxislabel,Step=1.0,Size=2),Arrows(6),above=true); 

are the commands that actually construct the xaxis and the yaxis. For documentation, see here.

The next block of code does the actual construction of the geometric figures.

/* draw figures */
real f1 (real x) {return sin(x);} 
draw(graph(f1,-6.21,8.03)); 
draw((-3.14,0)--(0,0), zzttqq); 
draw((0,0)--(0,3.14), zzttqq); 
draw((0,3.14)--(-3.14,pi ), zzttqq); 
draw((-3.14,pi )--(-3.14,0), zzttqq); 
draw(circle((0,3.14),1.14)); draw(shift((3.35,2.06))*rotate(1)*xscale(1.59)*yscale(1.1)*unitcircle); 
pair hyperbolaLeft1 (real t) {return (0.49*(1+t^2)/(1-t^2),1.04*2*t/(1-t^2));} pair hyperbolaRight1 (real t) {return (0.49*(-1-t^2)/(1-t^2),1.04*(-2)*t/(1-t^2));} 
draw(shift((3.35,2.06))*rotate(1)*graph(hyperbolaLeft1,-0.99,0.99)); draw(shift((3.35,2.06))*rotate(1)*graph(hyperbolaRight1,-0.99,0.99)); /* hyperbola construction */ 

The first line real f1 (real x) {return sin(x);} defines the sin() function to be drawn, and the next line draw(graph(f1,-6.21,8.03)); actually draws the graph to the diagram. The graph() command comes from the Asymptote graph package. The next few lines draw several line segments. The attribute zzttqq is a pen whose color is mapped from some rgb value (with conversions ... 8 = y, 9 = z, a = a, b = b, ... ).

Options

An outline of the different available options.

(The first three options are related and automatically update with respect to eath other).

X/Y Units (cm): Indicates how many units in the picture correspond to 1 centimeter.

Picture width/height: Indicates what size the Asymptote output should be, in centimeters.

xmin/xmax/ymin/ymax: Indicates the dimensions of the picture in the picture's coordinates.

(The next options change other features).

Font size: Changes the default font size. The value defaults at 10pt, but I personally recommend 7pt for any file with multiple text lines, which more closely approximates the size of the font in the Geogebra window.

Fill type: This includes four options as to how Geogebra elements with different fill colors should be implemented:

  • None: No fills are drawn.
  • Only opaque fills. This will only cause filled objects with opaque transparencies, which are arbitrarily defined as shapes with transparency alpha values greater than 0.9 (on a 0 to 1, 1 being fully opaque, scale), to appear filled.
  • With opacity pen. This uses the opacity() pen to draw transparency fills. This option does not work on the AoPS forums.
  • By layering (my personal preference). Filled objects have "fake transparency" where filled objects are simply drawn before any other objects are drawn, and transparencies just cause a lighter shade. However, filled objects will override other filled objects, and so there is no "darker" transparencies along intersecting regions.

Concise code: This produces shorter Asymptote code. Some of the changes between non-concise and concise code:

  • In non-concise code, most new commands have their own line. In concise code, there are at most about 8 lines of code.
  • Abbreviations are used for certain variables (labelscalefactor to lsf, xaxislabel to xlbl, gridx to gx, and so forth).
  • Pen colors are produced with a single line of pen declarations.
  • Functions are re-used where possible.
  • Less spacing.

The advantages of concise code:

  • Less code to examine.
  • Non-concise code will usually not render on the AoPS forums due to size limits.
  • Guide to customizing code should be in the following posts.

The disadvantages of concise code:

  • More difficult to read (especially without experience with my style of coding), exacerbated by lack of spacing.
  • No documentation comments.
  • Difficult to read through from given code window, requires wrap-around to read effectively.

Concise with cse5: There is also a cse5 option that allows the code to be further compactified with help with the cse5 package (see the stickies in this forum).

  • In non-concise code, most new commands have their own line. In cse5 code, there are at most about 8 lines of code.
  • Abbreviations are used for certain variables (labelscalefactor to lsf, xaxislabel to xlbl, gridx to gx, and so forth).
  • Pairs are given names and produced in a single line; color pens are also produced in a single line.
  • Functions are re-used where possible.
  • Command shortcuts, such as MP() and D() are used extensively.
  • Almost no spacing.

The advantages of cse5 code:

  • Less code to examine.
  • With the exception of excessively complicated diagrams, will almost always fit within AoPS size restrictions.
  • Guide to customizing code should be in the following posts.
  • Allows more customization; changing a declared point and pen will reflect changes across the code.

The disadvantages of cse5 code:

  • Extremely difficult to read (especially without experience with my style of coding), exacerbated by lack of spacing and short commands.
  • No documentation comments.
  • Difficult to read through from given code window, requires wrap-around to read effectively.
  • May occasionally draw skinny points and lines, due to default pathpen and pointpen attributes.

My personal recommendation is the concise code for producing quick sketches (cse5 for large quick sketches), and the non-concise code otherwise.

Grayscale: Uses monochromatic scale to produce all output.

Show Axes/Grid (default checked): Show or hide the axes and the grid.

Keep dot colors: Geogebra defaults free points to a blue color and semi-fixed points to a light blue color. Without this option checked, the Asymptote code will automatically set points to the default color (black). With checked, the Asymptote code will include the point colors as shown in the Geogebra window.

Use point names: (to do) In the Asymptote code, store points in $\texttt{pair}$ variables rather than by write out by coordinates. Done by default for concise cse5 code.

Points

[asy] import graph; size(11.6cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); real xmin=-5.8,xmax=5.8,ymin=-2.2,ymax=5.72;  pen wwqqqq=rgb(0.4,0,0), xdxdff=rgb(0.49,0.49,1), uququq=rgb(0.25,0.25,0.25), ffqqtt=rgb(1,0,0.2); Label laxis; laxis.p=fontsize(10);  xaxis("$x$",-5.8,5.8,defaultpen+wwqqqq+linewidth(1.2),Ticks(laxis,Step=1.0,Size=2),above=true); yaxis("$y$",-3.22,5.72,defaultpen+wwqqqq+linewidth(1.2),Ticks(laxis,Step=1.0,Size=2),above=true); draw(shift((-4,0))*scale(0.11)*(expi(pi/4)--expi(5*pi/4)^^expi(3*pi/4)--expi(7*pi/4)),xdxdff); draw(circle((-3,0),0.11),xdxdff); draw(shift((-2,0))*scale(0.11)*((0,1)--(0,-1)^^(1,0)--(-1,0)),xdxdff); fill(shift((-1,0))*scale(0.11)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle),xdxdff); draw(shift((0,0))*scale(0.11)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle),uququq); fill(shift((1,0))*rotate(90)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),xdxdff); fill(shift((2,0))*rotate(270)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),xdxdff); fill(shift((3,0))*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),xdxdff); fill(shift((4,0))*rotate(180)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),xdxdff); draw(shift((-4,1))*scale(0.11)*(expi(pi/4)--expi(5*pi/4)^^expi(3*pi/4)--expi(7*pi/4)),blue); draw(circle((-3,1),0.11),blue); draw(shift((-2,1))*scale(0.11)*((0,1)--(0,-1)^^(1,0)--(-1,0)),blue); fill(shift((-1,1))*scale(0.11)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle),blue); draw(shift((0,1))*scale(0.11)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle),xdxdff); fill(shift((1,1))*rotate(90)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),blue); fill(shift((2,1))*rotate(270)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),blue); fill(shift((3,1))*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),blue); fill(shift((4,1))*rotate(180)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),blue); draw(shift((-4,2))*scale(0.18)*(expi(pi/4)--expi(5*pi/4)^^expi(3*pi/4)--expi(7*pi/4)),ffqqtt); draw(circle((-3,2),0.18),ffqqtt); draw(shift((-2,2))*scale(0.18)*((0,1)--(0,-1)^^(1,0)--(-1,0)),ffqqtt); fill(shift((-1,2))*scale(0.18)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle),ffqqtt); draw(shift((0,2))*scale(0.18)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle),ffqqtt); fill(shift((1,2))*rotate(90)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),ffqqtt); fill(shift((2,2))*rotate(270)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),ffqqtt); fill(shift((3,2))*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),ffqqtt); fill(shift((4,2))*rotate(180)*scale(0.25)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle),ffqqtt);  dot((-5,0),xdxdff); label("$A$",(-4.92,0.12),NE*lsf,xdxdff); label("$B$",(-3.92,-0.12),NE*lsf,xdxdff); label("$C$",(-2.92,0.12),NE*lsf,xdxdff); label("$D$",(-1.92,0.12),NE*lsf,xdxdff); label("$E$",(-0.92,0.12),NE*lsf,xdxdff); label("$F$",(0.08,0.12),NE*lsf,uququq); label("$G$",(1.08,0.12),NE*lsf,xdxdff); label("$H$",(2.08,0.12),NE*lsf,xdxdff); label("$I$",(3.08,0.12),NE*lsf,xdxdff); label("$J$",(4.08,0.12),NE*lsf,xdxdff); dot((5,0),linewidth(1pt)+xdxdff); label("$K$",(5.08,0.04),NE*lsf,xdxdff); dot((-5,1),blue); label("$L$",(-4.92,1.12),NE*lsf,blue); label("$M$",(-3.92,1.12),NE*lsf,blue); label("$N$",(-2.92,1.12),NE*lsf,blue); label("$O$",(-1.92,1.12),NE*lsf,blue); label("$P$",(-0.92,1.12),NE*lsf,blue); label("$Q$",(0.08,1.12),NE*lsf,xdxdff); label("$R$",(1.08,1.12),NE*lsf,blue); label("$S$",(2.08,1.12),NE*lsf,blue); label("$T$",(3.08,1.12),NE*lsf,blue); label("$U$",(4.08,1.12),NE*lsf,blue); dot((5,1),blue); label("$V$",(5.08,1.12),NE*lsf,blue); dot((-5,2),blue); dot((5,2),linewidth(5pt)+blue); label("$I_1$",(5.08,2.2),NE*lsf,blue); dot((-5,3),blue); dot((-5,4),blue); dot((-5,3.5),uququq);  clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle);  [/asy] Support for drawing different options of points, along with point labeling.

[asy] import graph; size(11.6cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); pen ds=black; real xmin=-5.8,xmax=5.8,ymin=-3.22,ymax=5.72;  pen wwqqqq=rgb(0.4,0,0), ffqqtt=rgb(1,0,0.2); Label laxis; laxis.p=fontsize(10);  xaxis("$x$",-5.8,5.8,defaultpen+wwqqqq+linewidth(1.2),Ticks(laxis,Step=1.0,Size=2),above=true); yaxis("$y$",-3.22,5.72,defaultpen+wwqqqq+linewidth(1.2),Ticks(laxis,Step=1.0,Size=2),above=true); draw(shift((-4,0))*scale(0.11)*(expi(pi/4)--expi(5*pi/4)^^expi(3*pi/4)--expi(7*pi/4))); draw(circle((-3,0),0.11)); draw(shift((-2,0))*scale(0.11)*((0,1)--(0,-1)^^(1,0)--(-1,0))); fill(shift((-1,0))*scale(0.11)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle)); draw(shift((0,0))*scale(0.11)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle)); fill(shift((1,0))*rotate(90)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); fill(shift((2,0))*rotate(270)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); fill(shift((3,0))*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); fill(shift((4,0))*rotate(180)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); draw(shift((-4,1))*scale(0.11)*(expi(pi/4)--expi(5*pi/4)^^expi(3*pi/4)--expi(7*pi/4))); draw(circle((-3,1),0.11)); draw(shift((-2,1))*scale(0.11)*((0,1)--(0,-1)^^(1,0)--(-1,0))); fill(shift((-1,1))*scale(0.11)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle)); draw(shift((0,1))*scale(0.11)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle)); fill(shift((1,1))*rotate(90)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); fill(shift((2,1))*rotate(270)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); fill(shift((3,1))*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); fill(shift((4,1))*rotate(180)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); draw(shift((-4,2))*scale(0.18)*(expi(pi/4)--expi(5*pi/4)^^expi(3*pi/4)--expi(7*pi/4))); draw(circle((-3,2),0.18)); draw(shift((-2,2))*scale(0.18)*((0,1)--(0,-1)^^(1,0)--(-1,0))); fill(shift((-1,2))*scale(0.18)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle)); draw(shift((0,2))*scale(0.18)*((1,0)--(0,1)--(-1,0)--(0,-1)--cycle)); fill(shift((1,2))*rotate(90)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); fill(shift((2,2))*rotate(270)*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); fill(shift((3,2))*scale(0.11)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); fill(shift((4,2))*rotate(180)*scale(0.25)*((1,0)--expi(2*pi/3)--expi(4*pi/3)--cycle)); draw((-4,3)--(-4,4),ffqqtt);  dot((-5,0),ds); label("$A$",(-4.92,0.12),NE*lsf); label("$B$",(-3.92,0.12),NE*lsf); label("$C$",(-2.92,0.12),NE*lsf); label("$D$",(-1.92,0.12),NE*lsf); label("$E$",(-0.92,0.12),NE*lsf); label("$F$",(0.08,0.12),NE*lsf); label("$G$",(1.08,0.12),NE*lsf); label("$H$",(2.08,0.12),NE*lsf); label("$I$",(3.08,0.12),NE*lsf); label("$J$",(4.08,0.12),NE*lsf); dot((5,0),linewidth(1pt)+ds); label("$K$",(5.08,0.04),NE*lsf); dot((-5,1),ds); label("$L$",(-4.92,1.12),NE*lsf); label("$M$",(-3.92,1.12),NE*lsf); label("$N$",(-2.92,1.12),NE*lsf); label("$O$",(-1.92,1.12),NE*lsf); label("$P$",(-0.92,1.12),NE*lsf); label("$Q$",(0.08,1.12),NE*lsf); label("$R$",(1.08,1.12),NE*lsf); label("$S$",(2.08,1.12),NE*lsf); label("$T$",(3.08,1.12),NE*lsf); label("$U$",(4.08,1.12),NE*lsf); dot((5,1),ds); label("$V$",(5.08,1.12),NE*lsf); dot((-5,2),ds); dot((5,2),linewidth(5pt)+ds); label("$I_1$",(5.08,2.2),NE*lsf); dot((-5,3),ds); dot((-5,4),ds); dot((-5,3.5),ds); dot((-4,3),ds); dot((-4,4),ds);  clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle);  [/asy] Also includes an option to remove the coloring of just points (to avoid Geogebra's default of using different colors for different classes of fixed points).


<geogebra>1c89b124bb471a351bc108d34f8096d1f892e012</geogebra> (Note, the version of Geogebra here does not support different dot styles.)


Also has support for different types of axes: bold, with arrows, different colors, different labelling schemes (including with $\pi$ labels as in the next example). Also supports drawing of grid (with for loop constructions). There is a checkbox option to show and hide axes and grids.

Known bugs:

  • Labels may be displaced more from points than shown in Geogebra window. This is not really a bug but a font problem, since Asymptote will write the labels in LaTeX, which has a different size from normal text. The recommended solution is to decrease the font size to fontsize(8) or fontsize(7).
  • Leaving Keep Dot Colors() unchecked will color as black any labels which are a single character long and set to the default shade of blue for new points (presumably all such labels will be dot labels, which is the desired behavior).
  • Some of the point styles might not be perfectly accurate when zoomed in.
  • In cse5 mode, certain dots will appear smaller (default pointpen nature of cse5, not fixing).

Axes

There is support for drawing the x and y axes of the diagram (indeed, without Show Axes/Grid unchecked, and assuming the axes are visible in the Geogebra window, then the axes will be drawn). However, there are several bugs:

  • The Asymptote code will remove the tick labels for $0$. One can undo this by removing the attribute NoZero for the xaxis(), yaxis() commands. The reason is that the zero labels are not positioned well in Asymptote (indeed, the Geogebra tick labels for $0$, or whatever the intersection point is, are shifted slightly)
  • The location where the label of the axes (typically "x" or "y") will by default appear in the first quadrant ("x" above the x-axis, "y" to the right of the y-axis). In Asymptote, the labels appear in the exact opposite locations ("x" below the x-axis, "y" to the left of the y-axis). Low priority bug which is unlikely to be fixed.
  • There is no (easy) support in Asymptote for having the x or y axes intersect at any point other than the origin. In GeoGebra, one can use the Crossing at textbox under Properties to change where the x-axis and y-axis intersects.
  • Geogebra recognizes near-multiples of $\pi$ in axis tick distances; for example, if you enter an axis tick distance of $\pi/3 \approx 1.047\ldots$, Geogebra automatically renders it as $\pi$ instead of $3.14\ldots$. There's no easy way to do it in Asymptote (if you do want to try and mimic the behavior, manually add a labelling function which checks to see if tick labels are sufficient close to an integer multiple of $\pi$. The code is too long to be worth included in general). Also, while $\pi/2$ labels are implemented, $\pi/4$ labels are soon to be introduced and have not been implemented.

Functions and Integrals

[asy] import graph; size(15.36cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); pen ds=black; real xmin=-7.3,xmax=8.06,ymin=-1.44,ymax=5.2;  pen ttqqzz=rgb(0.2,0,0.6), fueaev=rgb(0.96,0.92,0.9), zzttqq=rgb(0.6,0.2,0); real f2(real x){return 2+2*cos(2*x+pi);} filldraw(graph(f2,-6.28,-3.14)--(-3.14,0)--(-6.28,0)--cycle,fueaev,zzttqq); filldraw(box((-3.14,0),(-2.51,0)),fueaev,zzttqq); filldraw(box((-2.51,0),(-1.88,1.38)),fueaev,zzttqq); filldraw(box((-1.88,0),(-1.26,3.62)),fueaev,zzttqq); filldraw(box((-1.26,0),(-0.63,1.38)),fueaev,zzttqq); filldraw(box((-0.63,0),(0,0)),fueaev,zzttqq); filldraw(box((0,0),(0.63,1.38)),fueaev,zzttqq); filldraw(box((0.63,0),(1.26,3.62)),fueaev,zzttqq); filldraw(box((1.26,0),(1.88,4)),fueaev,zzttqq); filldraw(box((1.88,0),(2.51,3.62)),fueaev,zzttqq); filldraw(box((2.51,0),(pi,1.38)),fueaev,zzttqq); filldraw((pi,0)--(3.77,0)--(3.77,1.38)--(pi,0)--cycle,fueaev,zzttqq); filldraw((3.77,0)--(4.4,0)--(4.4,3.62)--(3.77,1.38)--cycle,fueaev,zzttqq); filldraw((4.4,0)--(5.03,0)--(5.03,3.62)--(4.4,3.62)--cycle,fueaev,zzttqq); filldraw((5.03,0)--(5.65,0)--(5.65,1.38)--(5.03,3.62)--cycle,fueaev,zzttqq); filldraw((5.65,0)--(6.28,0)--(6.28,0)--(5.65,1.38)--cycle,fueaev,zzttqq);  Label laxis; laxis.p=fontsize(10); string xlbl(real x){int n=round(x/pi); if(n==-1) return "$-\pi$"; if(n==1) return "$\pi$"; if(n==0) return "$0$"; return "$"+string(round(x/pi))+"\pi$";}  xaxis("$\theta$",-7.3,8.06,linewidth(1.2),Ticks(laxis,xlbl,Step=3.141592653589793,Size=2),Arrows(6),above=true); yaxis(-1.44,5.2,linewidth(1.2),Ticks(laxis,Step=1.0,Size=2),Arrows(6),above=true); real f1(real x){return 2+2*cos(2*x+pi);} draw(graph(f1,-7.29,8.05),linewidth(1.6)+ttqqzz); label("$2 + 2 \cos(2x + \pi)$",(-7.14,4.1),NE*lsf,ttqqzz);  clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle);  [/asy] Allows most functions and can draw integrals and Riemman-like sums. Above, the function is given by $f(x) = 2+2\cos(2x)$; the four shaded regions are drawn using the commands Integral[f,-2pi,-pi], LowerSum[f,-pi,0,5], UpperSum[f,0,pi,5], and TrapezoidalSum[f,pi,2pi,5].

<geogebra>6636ccd3479762307d932c319db7ec1998236a4c</geogebra> 

Known bugs:

  • May capitalize certain functions (like trigonometric functions). Please let me know if this happens.
  • Certain functions recognized by Geogebra might not be recognized by Asymptote.
  • Integrals/Sums drawn over functions that reach undefined values (ex, $\ln(x)$ at $x=0$) will cause a break when drawn in Asymptote (unlikely to be fixed); drawing the functions themselves will work, however.
  • With certain very contrived function strings, it is possible to break the code (won't fix).
  • Sometimes will render LaTeX commands in function strings. Please let me know if this happens.

Lines and Conics

import graph; size(11.6cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); pen ds=black; real xmin=-5.06,xmax=6.54,ymin=-3.4,ymax=5.54; 
pen qqzztt=rgb(0,0.6,0.2), qqqqzz=rgb(0,0,0.6), ffqqtt=rgb(1,0,0.2);draw(circle((0,0),1),linewidth(2.8));draw((0,0)--(1,0)); draw((0,ymin)--(0,ymax)); draw((xmin,(-(3.19)-(1.03)*xmin)/3.02)--(xmax,(-(3.19)-(1.03)*xmax)/3.02)); draw((xmin,(-(-3.19)-(-0.88)*xmin)/3.06)--(xmax,(-(-3.19)-(-0.88)*xmax)/3.06)); draw(shift((-2.81,0.83))*rotate(54.75)*xscale(2.12)*yscale(1.91)*unitcircle,linewidth(1.6)+linetype("2pt 8pt 10pt 8pt")+qqzztt);pair hl1(real t){return (0.53*(1+t^2)/(1-t^2),0.74*2*t/(1-t^2));} pair hr1(real t){return (0.53*(-1-t^2)/(1-t^2),0.74*(-2)*t/(1-t^2));} draw(shift((3.63,0.55))*rotate(178.11)*graph(hl1,-0.99,0.99),linewidth(1.6)+linetype("4pt 4pt")+qqqqzz); draw(shift((3.63,0.55))*rotate(178.11)*graph(hr1,-0.99,0.99),linewidth(1.6)+linetype("4pt 4pt")+qqqqzz); real p1(real x){return x^2/2/3.48;} draw(shift((1.16,3.19))*rotate(16.04)*graph(p1,-13.93,13.93),linewidth(2)+ffqqtt); 
dot((0,0),ds); dot((1,0),ds); dot((-3.34,0.08),ds); dot((-2.28,1.58),ds); dot((-3.4,2.72),ds); dot((-0.94,0.34),ds); dot((2.72,0.58),ds); dot((4.54,0.52),ds); dot((0.68,4.86),ds); 
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); 
 (Error making remote request. Unknown error_msg)

Allows lines, rays, vectors (not shown), and the different conic sections (which includes circle arcs and sectors), including different line colors, line types, line sizes, and in some cases, fill colors. Lines and rays automatically re-scale to fit the entire window when the diagram size is changed.

<geogebra>f475aec9be4bbeb0d7a8b525fb2cbbe905383c5d</geogebra> 

Known bugs:

  • Broken line functions (floor, ceiling) graph incorrectly. Not likely to be fixed due to Asymptote's graph() design.

Filled objects

import graph; size(9.7cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); pen ds=black; real xmin=-3.58,xmax=6.12,ymin=-1.1,ymax=6.1; 
pen cqcqcq=rgb(0.75,0.75,0.75), fueaev=rgb(0.96,0.92,0.9), zzttqq=rgb(0.6,0.2,0), evefev=rgb(0.9,0.94,0.9), qqwuqq=rgb(0,0.39,0);
filldraw((0,0)--(2,0)--(3.41,1.41)--(3.41,3.41)--(2,4.83)--(0,4.83)--(-1.41,3.41)--(-1.41,1.41)--cycle,fueaev,zzttqq); filldraw(arc((2,0),0.6,45,180)--(2,0)--cycle,evefev,qqwuqq); filldraw(arc((0,0),0.6,0,135)--(0,0)--cycle,evefev,qqwuqq); filldraw(arc((-1.41,1.41),0.6,-45,90)--(-1.41,1.41)--cycle,evefev,qqwuqq); filldraw(arc((-1.41,3.41),0.6,-90,45)--(-1.41,3.41)--cycle,evefev,qqwuqq); filldraw(arc((0,4.83),0.6,-135,0)--(0,4.83)--cycle,evefev,qqwuqq); filldraw(arc((2,4.83),0.6,180,315)--(2,4.83)--cycle,evefev,qqwuqq); filldraw(arc((3.41,3.41),0.6,135,270)--(3.41,3.41)--cycle,evefev,qqwuqq); filldraw(arc((3.41,1.41),0.6,90,225)--(3.41,1.41)--cycle,evefev,qqwuqq); 
/*grid*/ pen gs=linewidth(0.7)+cqcqcq+linetype("2pt 2pt"); real gx=1,gy=1;
for(real i=ceil(xmin/gx)*gx;i<=floor(xmax/gx)*gx;i+=gx) draw((i,ymin)--(i,ymax),gs); for(real i=ceil(ymin/gy)*gy;i<=floor(ymax/gy)*gy;i+=gy) draw((xmin,i)--(xmax,i),gs); draw((0,0)--(2,0),zzttqq); draw((2,0)--(3.41,1.41),zzttqq); draw((3.41,1.41)--(3.41,3.41),zzttqq); draw((3.41,3.41)--(2,4.83),zzttqq); draw((2,4.83)--(0,4.83),zzttqq); draw((0,4.83)--(-1.41,3.41),zzttqq); draw((-1.41,3.41)--(-1.41,1.41),zzttqq); draw((-1.41,1.41)--(0,0),zzttqq); draw(arc((2,0),0.6,0.79,pi),qqwuqq); draw(arc((2,0),0.5,0.79,pi),qqwuqq); draw(arc((-1.41,1.41),0.6,-45,85.38),qqwuqq,BeginArcArrow(6)); draw(arc((-1.41,3.41),0.6,-90,40.38),qqwuqq,EndArcArrow(6)); draw(arc((0,4.83),0.6,-2.36,0),qqwuqq); draw((0.21,4.33)--(0.25,4.22),qqwuqq); draw((0.14,4.31)--(0.17,4.19),qqwuqq); draw((0.27,4.36)--(0.33,4.26),qqwuqq); draw(arc((2,4.83),0.6,pi,5.5),qqwuqq); draw((1.73,4.36)--(1.67,4.26),qqwuqq); draw((1.86,4.31)--(1.83,4.19),qqwuqq); draw(arc((3.41,3.41),0.6,2.36,4.71),qqwuqq); draw((2.92,3.21)--(2.8,3.16),qqwuqq); draw(arc((3.41,1.41),0.6,1.57,3.93),qqwuqq); draw(arc((3.41,1.41),0.5,1.57,3.93),qqwuqq); draw(arc((3.41,1.41),0.4,1.57,3.93),qqwuqq); draw((0,0)--(2,0),EndArrow(6));
dot((0,0),ds); dot((2,0),ds); dot((3.41,1.41),ds); dot((3.41,3.41),ds); dot((2,4.83),ds); dot((0,4.83),ds); dot((-1.41,3.41),ds); dot((-1.41,1.41),ds); label("$135^\circ$",(2.64,0.12),NE*lsf,qqwuqq); label("$135^\circ$",(0.28,0.78),NE*lsf,qqwuqq); label("$135^\circ$",(-1.1,2.06),NE*lsf,qqwuqq); label("$135^\circ$",(-0.72,3.28),NE*lsf,qqwuqq); label("$135^\circ$",(-1,4.68),NE*lsf,qqwuqq); label("$135^\circ$",(2.2,4.8),NE*lsf,qqwuqq); label("$135^\circ$",(3.38,3.64),NE*lsf,qqwuqq); label("$135^\circ$",(3.5,1.58),NE*lsf,qqwuqq); 
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle);  (Error making remote request. Unknown error_msg)

Allows certain transparent fills. There are four possible options allowed for fill colors:

  • No fills. Self-explanatory.
  • Opaque fills only. This will only cause filled objects with opaque transparencies, which are arbitrarily defined as shapes with transparency alpha values greater than 0.9 (on a 0 to 1, 1 being fully opaque, scale), to appear filled.
  • With opacity pen. This uses the opacity() pen to draw transparency fills. This option does not work on the AoPS forums.
  • By layering (example above). Filled objects have "fake transparency" where filled objects are simply drawn before any other objects are drawn, and transparencies just cause a lighter shade. However, filled objects will override other filled objects, and so there is no "darker" transparencies along intersecting regions.

Polygons and angles, by default, will have transparent fill colors. Both have support for different line colors and fill colors (with different transparencies, colors, line sizes, etc). Angles include several different styles, including multiple arcs, tick marks, and arc arrows.

<geogebra>008edd5949bd2386cd1b9a7b223f16e44cbaf28c</geogebra> 

Known bugs:

  • Non re-sized arc arrows.
  • Overlapping transparency colors do not sum together.

Text

import graph; size(11.58cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); pen ds=black; real xmin=-4.3,xmax=7.28,ymin=-2.64,ymax=6.3; 
pen cqcqcq=rgb(0.75,0.75,0.75), qqccqq=rgb(0,0.8,0), ccqqtt=rgb(0.8,0,0.2);
/*grid*/ pen gs=linewidth(0.7)+cqcqcq+linetype("3pt 3pt"); real gx=1,gy=1;
for(real i=ceil(xmin/gx)*gx;i<=floor(xmax/gx)*gx;i+=gx) draw((i,ymin)--(i,ymax),gs); for(real i=ceil(ymin/gy)*gy;i<=floor(ymax/gy)*gy;i+=gy) draw((xmin,i)--(xmax,i),gs); 
Label laxis; laxis.p=fontsize(10); 
xaxis(-4.3,7.28,defaultpen+black,Ticks(laxis,Step=1.0,Size=2),Arrows(6),above=true); yaxis(-2.64,6.3,defaultpen+black,Ticks(laxis,Step=1.0,Size=2),Arrows(6),above=true); label("abc",(-3,5.24),SE*lsf); label("a2 b3 c3 o pi e infty otimes sqrt(x)",(-3,4.24),SE*lsf); label("$\parbox{1.4 cm}{abc \\  def \\  ghi}$",(-3,3.24),SE*lsf); label("$  \sqrt{ abc }  $",(-3,2.24),SE*lsf); label("$abc \\ def$",(-3,1.24),SE*lsf); label("$abc$",(-3,0.24),SE*lsf); label("$\alpha\beta\gamma$",(-3,-0.76),SE*lsf); label("alpha beta gamma ",(-3,-1.76),SE*lsf); label("\textit{\textbf{abc}}",(0,5.24),SE*lsf,qqccqq+fontsize(12)); label("\textit{\textbf{alpha beta gamma }}",(0,-1.76),SE*lsf,qqccqq+fontsize(12)); label("$\mathit{\mathbf{ \alpha\beta\gamma }}$",(0,-0.76),SE*lsf,ccqqtt+fontsize(12)); label("\textit{\textbf{$abc$}}",(0,0.24),SE*lsf,qqccqq+fontsize(12)); label("$\mathit{\mathbf{ abcdef }}$",(0,1.24),SE*lsf,ccqqtt+fontsize(12)); label("$\mathit{\mathbf{  \sqrt{ abc }  }}$",(0,2.24),SE*lsf,ccqqtt+fontsize(12)); label("$\parbox{1.5 cm}{\textit{\textbf{abc \\  def \\  ghi}}}$",(0,3.24),SE*lsf,qqccqq+fontsize(12)); label("\textit{\textbf{a2 b3 co pi e infty otimes sqrt(x)}}",(0,4.24),SE*lsf,qqccqq+fontsize(12)); label("\textit{abc}",(3,5.24),SE*lsf,fontsize(8)); label("$\parbox{1.34 cm}{\textit{abc \\  def \\  ghi}}$",(3,3.24),SE*lsf,fontsize(8)); label("$\mathit{  \sqrt{ abc }  }$",(3,2.24),SE*lsf,fontsize(8)); label("$\mathit{abcdef}$",(3,1.24),SE*lsf,fontsize(8)); label("\textit{$abc$}",(3,0.24),SE*lsf,fontsize(8)); label("\textit{alpha beta gamma }",(3,-1.76),SE*lsf,fontsize(8)); label("$\mathit{ \alpha\beta\gamma }$",(3,-0.76),SE*lsf,fontsize(8)); label("pi e infty otimes questeq ne le ge neg wedge vee parallel perp in subseteq subset cong equiv measuredangle triangle ",(3,4.24),SE*lsf); 
dot((-3,0),ds); dot((-3,1),ds); dot((-3,2),ds); dot((-3,3),ds); dot((-3,4),ds); dot((-3,5),ds); dot((0,5),ds); dot((0,4),ds); dot((0,3),ds); dot((0,2),ds); dot((0,1),ds); dot((0,0),ds); dot((0,-1),ds); dot((-3,-1),ds); dot((-3,-2),ds); dot((0,-2),ds); dot((3,5),ds); dot((3,4),ds); dot((3,3),ds); dot((3,2),ds); dot((3,1),ds); dot((3,0),ds); dot((3,-1),ds); dot((3,-2),ds); 
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); 
 (Error making remote request. Unknown error_msg)

Supports most text options, including different font styles, bold, italics, and $\LaTeX$.

<geogebra>087e142af582ed87e10a11362584f7ced9b606bd</geogebra> 

Known bugs:

  • Including text strings with dollar signs will convert it to LaTeX. An odd number of dollar signs in a text string will usually cause an error (working on for $\LaTeX$ strings).
  • Certain contrived strings will break the code (may never be fixed).
  • Fontsize might not be correct occasionally, especially for cse5 commands. (Please let me know if this happens.)


Locus construction

[asy] import graph; size(10.16cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); real xmin=-3.28,xmax=6.88,ymin=-2.9,ymax=4.3;  pen xdxdff=rgb(0.49,0.49,1), uququq=rgb(0.25,0.25,0.25), ffqqtt=rgb(1,0,0.2);draw((1,ymin)--(1,ymax)); draw(circle((1,0),1.85));draw((xmin,(-(3.7)-(0)*xmin)/-2)--(xmax,(-(3.7)-(0)*xmax)/-2)); draw((1,(-(5.56)-(-3.19)*1)/1.28)--(xmax,(-(5.56)-(-3.19)*xmax)/1.28)); draw((2.48,ymin)--(2.48,ymax)); draw((xmin,(-(-17.1)-(0)*xmin)/12.76)--(xmax,(-(-17.1)-(0)*xmax)/12.76)); draw((2.48,1.34)--(2.43,1.37)--(2.38,1.4)--(2.33,1.43)--(2.28,1.46)--(2.23,1.49)--(2.17,1.51)--(2.08,1.56)--(1.98,1.61)--(1.88,1.65)--(1.79,1.69)--(1.69,1.73)--(1.6,1.76)--(1.5,1.78)--(1.41,1.81)--(1.32,1.82)--(1.23,1.84)--(1.14,1.85)--(1.05,1.85)--(0.96,1.85)--(0.87,1.85)--(0.77,1.84)--(0.68,1.82)--(0.59,1.81)--(0.5,1.78)--(0.41,1.76)--(0.31,1.73)--(0.22,1.69)--(0.12,1.65)--(0.03,1.61)--(-0.07,1.57)--(-0.17,1.51)--(-0.22,1.49)--(-0.27,1.46)--(-0.32,1.43)--(-0.37,1.4)--(-0.43,1.37)--(-0.48,1.34)--(-0.53,1.31)--(-0.59,1.28)--(-0.64,1.24)--(-0.69,1.21)--(-0.75,1.18)--(-0.81,1.14)--(-0.86,1.1)--(-0.92,1.07)--(-0.98,1.03)--(-1.04,0.99)--(-1.1,0.95)--(-1.16,0.91)--(-1.22,0.87)--(-1.28,0.83)--(-1.34,0.79)--(-1.41,0.75)--(-1.47,0.71)--(-1.54,0.67)--(-1.61,0.63)--(-1.67,0.58)--(-1.74,0.54)--(-1.81,0.5)--(-1.89,0.45)--(-1.96,0.41)--(-2.04,0.36)--(-2.11,0.32)--(-2.19,0.27)--(-2.27,0.23)--(-2.35,0.18)--(-2.44,0.14)--(-2.52,0.09)--(-2.61,0.05)--(-2.7,0)--(-2.79,-0.04)--(-2.89,-0.09)--(-2.98,-0.13)--(-3.08,-0.18)--(-3.13,-0.2)--(-3.18,-0.22)--(-3.24,-0.25)^^(6.81,-0.78)--(6.74,-0.76)--(6.66,-0.74)--(6.58,-0.72)--(6.51,-0.7)--(6.44,-0.68)--(6.37,-0.66)--(6.3,-0.64)--(6.23,-0.61)--(6.16,-0.59)--(6.1,-0.57)--(6.03,-0.55)--(5.97,-0.53)--(5.9,-0.51)--(5.84,-0.48)--(5.78,-0.46)--(5.72,-0.44)--(5.66,-0.42)--(5.6,-0.4)--(5.54,-0.37)--(5.49,-0.35)--(5.43,-0.33)--(5.38,-0.31)--(5.32,-0.28)--(5.27,-0.26)--(5.22,-0.24)--(5.17,-0.22)--(5.11,-0.19)--(5.06,-0.17)--(4.97,-0.13)--(4.87,-0.08)--(4.78,-0.04)--(4.73,-0.01)--(4.71,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.7,0)--(4.69,0)--(4.68,0.01)--(4.66,0.02)--(4.63,0.04)--(4.55,0.08)--(4.48,0.12)--(4.4,0.16)--(4.33,0.19)--(4.26,0.23)--(4.2,0.27)--(4.13,0.31)--(4.06,0.35)--(4,0.39)--(3.93,0.42)--(3.87,0.46)--(3.81,0.5)--(3.75,0.54)--(3.69,0.57)--(3.63,0.61)--(3.57,0.65)--(3.52,0.68)--(3.46,0.72)--(3.4,0.75)--(3.35,0.79)--(3.29,0.82)--(3.24,0.86)--(3.19,0.89)--(3.14,0.93)--(3.08,0.96)--(3.03,0.99)--(2.98,1.03)--(2.88,1.09)--(2.83,1.13)--(2.77,1.16)--(2.72,1.2)--(2.66,1.23)--(2.61,1.26)--(2.55,1.3)--(2.48,1.34),linewidth(2.8)+ffqqtt);  dot((1,0),xdxdff); dot((1,2),blue); dot((-0.66,0.82),blue); dot((1,1.85),uququq); dot((2.28,1.34),xdxdff); dot((1,-1.85),uququq); dot((2.48,1.85),uququq); dot((2.48,1.34),uququq);  clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle);  [/asy] Locus constructions with all of the usual lines options. Shown above is the "witch of aggensi".

<geogebra>d2594993982afff858b6296678b2bab7bbe351d8</geogebra> 

Comment: Can create huge files.

Known bugs: none.

Statistics

[asy] import graph; size(14.26cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(7); defaultpen(dps); pen ds=black; real xmin=-1.1,xmax=13.16,ymin=-2.36,ymax=6.58;  pen ccffcc=rgb(0.8,1,0.8), fueaev=rgb(0.96,0.92,0.9), zzttqq=rgb(0.6,0.2,0); filldraw(box((0,0),(1,2)),fueaev,linewidth(2)+zzttqq); filldraw(box((1,0),(2,6)),fueaev,linewidth(2)+zzttqq); filldraw(box((2,0),(3,8)),fueaev,linewidth(2)+zzttqq); filldraw(box((3,0),(4,3)),fueaev,linewidth(2)+zzttqq); filldraw(box((4,0),(5,1)),fueaev,linewidth(2)+zzttqq); filldraw(box((3.5,-1.5),(8,-0.5)),fueaev,linewidth(2)+zzttqq);  Label laxis; laxis.p=fontsize(7);  xaxis(-1.1,13.16,defaultpen+black,Ticks(laxis,Step=1.0,Size=2),Arrows(6),above=true); draw((2,-1.5)--(2,-0.5),linewidth(2)+zzttqq); draw((9,-1.5)--(9,-0.5),linewidth(2)+zzttqq); draw((6,-1.5)--(6,-0.5),linewidth(2)+zzttqq); draw((2,-1)--(3.5,-1),linewidth(2)+zzttqq); draw((8,-1)--(9,-1),linewidth(2)+zzttqq);  label("$b = 20$",(2.38,0.24),NE*lsf,zzttqq); label("$c = 6$",(6,-1.26),NE*lsf,zzttqq);  clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); shipout(bbox(ccffcc,Fill));  [/asy]

Does BoxPlot[], Histogram[] commands, as well as background colors.

Known bugs: none known

Implicit functions

Graph implicit functions that are polynomials in two variables $x,y$ using Asymptote's $\texttt{contour}$ package.

See here.

Inequalities

Graph a certain set of inequalities: functions, conics, and conjunction/disjunctions. (to do)

Full example

import graph; size(13.92cm); real lsf=0.5; pen dps=linewidth(0.7)+fontsize(10); defaultpen(dps); real xmin=-0.72,xmax=3.2,ymin=-1.81,ymax=1.35; 
pen ffqqcc=rgb(1,0,0.8), uququq=rgb(0.25,0.25,0.25), evefev=rgb(0.9,0.94,0.9), qqwuqq=rgb(0,0.39,0), evffff=rgb(0.9,1,1), qqffff=rgb(0,1,1);
filldraw(arc((2.69,-1.5),0.16,134.59,180)--(2.69,-1.5)--cycle,evefev,qqwuqq); filldraw(arc((2,-0.8),0.16,-113.2,-90)--(2,-0.8)--cycle,evefev,qqwuqq); filldraw(arc((2,-1.5),0.16,0,90)--(2,-1.5)--cycle,evefev,qqwuqq); filldraw(arc((1.7,-1.5),0.16,0,66.8)--(1.7,-1.5)--cycle,evefev,qqwuqq); filldraw(arc((1.31,0),0.16,157.5,180)--(1.31,0)--cycle,evefev,qqwuqq); filldraw(arc((0.38,0),0.16,0,90)--(0.38,0)--cycle,evefev,qqwuqq); filldraw(arc((2.23,0),0.16,90,180)--(2.23,0)--cycle,evefev,qqwuqq); filldraw(arc((1.31,0),0.16,0,22.5)--(1.31,0)--cycle,evefev,qqwuqq); filldraw(arc((1.31,0),0.16,22.5,112.5)--(1.31,0)--cycle,evffff,qqffff); filldraw(arc((0,0),0.16,0,45)--(0,0)--cycle,evffff,qqffff); draw((xmin,(-(0)-(0)*xmin)/1)--(xmax,(-(0)-(0)*xmax)/1)); draw(circle((0,0),1.31),linetype("4pt 4pt")+blue);draw(circle((1.31,0),1),linetype("4pt 4pt")+red);draw((0.92,0.92)--(0,0),linewidth(1.6)); draw((0,0)--(1.31,0),linewidth(1.6)); draw((0.92,0.92)--(1.31,0),linewidth(1.6)); draw((1.31,0)--(2.23,0.38),linewidth(1.6)); draw((2.23,0.38)--(0.92,0.92),linewidth(1.6)); draw((0.38,0.38)--(2.23,0.38),ffqqcc); draw((0,0)--(2.23,0.38),ffqqcc); draw((2.23,0.38)--(2.23,0),dotted); draw((0,0.38)--(0,0),dotted); draw((0,0.38)--(0.38,0.38),dotted); draw((0.38,0.38)--(0.38,0.38),linewidth(1.2)+linetype("1pt 1pt")); draw((0.38,0.38)--(0,0),linewidth(1.2)+linetype("1pt 1pt")); draw((0.38,0.38)--(1.31,0),linewidth(1.2)+linetype("1pt 1pt")); draw((0.38,0.38)--(1.31,0),linewidth(1.2)+linetype("1pt 1pt")); draw((2.69,-1.5)--(2,-0.8)); draw((2,-0.8)--(1.7,-1.5)); draw((1.7,-1.5)--(2.69,-1.5)); draw((2,-0.8)--(2,-1.5)); label("$r $",(2.69,-1.84),SE*lsf); label("r",(2.3,-1.39),SE*lsf); label("$ r\sqrt{ 2 } $",(2.75,-1.24),SE*lsf); label("$r( \sqrt{ 2 } - 1 )$",(2.02,-1.85),SE*lsf); label("$45^\circ$",(2.41,-1.3),SE*lsf); label("$22.5^\circ$",(2.02,-0.96),SE*lsf); draw(circle((2.07,-1.43),0.01),qqwuqq); label("$90^\circ$",(2.15,-1.3),SE*lsf); label("$67.5^\circ$",(1.79,-1.28),SE*lsf); label("$22.5^\circ$",(0.84,0.1),SE*lsf); label("r",(0.71,-0.06),SE*lsf); label("$r( \sqrt{ 2 } - 1 )$",(0.27,0.35),SE*lsf); label("$r( \sqrt{ 2 } - 1 )$",(-0.05,-0.12),SE*lsf); label("$r( \sqrt{ 2 } - 1 )$",(-0.09,0.63),SE*lsf); label("$r( \sqrt{ 2 } - 1 )$",(-0.44,0.31),SE*lsf); draw(circle((0.45,0.07),0.01),qqwuqq); label("$90^\circ$",(0.6,0.1),SE*lsf); draw(circle((2.16,0.07),0.01),qqwuqq); label("$90^\circ$",(2.31,0.17),SE*lsf); label("$22.5^\circ$",(1.64,0.11),SE*lsf); label("r",(2.04,-0.09),SE*lsf); draw((1.4,-0.2)--(1.11,0.17),EndArrow(6));label("$ \sqrt{ (r (\sqrt{ 2 } - 1) + r + r )^2 + (r (\sqrt{ 2 } - 1) )^2 }$",(1.58,-0.2),SE*lsf); label("$ = \sqrt{ (r (\sqrt{ 2 } + 1) )^2 + (r (\sqrt{ 2 } - 1) )^2 } $",(1.53,-0.37),SE*lsf); label("$\mathbf{=r  \sqrt{ 6 }}$",(1.53,-0.72),SE*lsf,blue); label("$= \sqrt{ r^2 (3 + 2 \sqrt{ 2 }) + r^2 (3 - 2 \sqrt{ 2 }) } $",(1.53,-0.54),SE*lsf); label("$\mathbf{2r}$",(1.46,0.64),SE*lsf,blue); label("$\mathbf{\frac{BE}{AE} = \frac{r \sqrt{ 6 }}{2r} = \frac{ \sqrt{ 6 }}{2}}$",(0.78,-1.47),SE*lsf,red+fontsize(14)); draw((1.74,-1.13)--(0.83,-0.06),EndArrow(6));draw(circle((1.34,0.09),0.01),qqffff); label("$45^\circ$",(-0.01,0.13),SE*lsf); label("$90^\circ$",(-0.22,1.47),SE*lsf); label("$90^\circ$",(1.39,0.24),SE*lsf); draw((0.38,0)--(0.38,0.38),linewidth(0.4)+dotted); 
dot((0,0),blue); label("$B$",(-0.06,-0.09),NE*lsf,blue); dot((1.31,0),blue); label("$D$",(1.34,-0.09),NE*lsf,blue); dot((0.92,0.92),blue); label("$C$",(0.91,0.99),NE*lsf,blue); dot((2.23,0.38),blue); label("$E$",(2.27,0.39),NE*lsf,blue); dot((0.38,0.38),blue); label("$A$",(0.33,0.41),NE*lsf,blue); dot((0.38,0),linewidth(1pt)+uququq); label("$G$",(0.41,-0.1),NE*lsf,uququq); dot((0,0.38),linewidth(1pt)+uququq); dot((2.23,0),linewidth(1pt)+uququq); label("$F$",(2.24,-0.1),NE*lsf,uququq); dot((0.38,0.38),uququq); dot((1.7,-1.5),blue); dot((2,-0.8),blue); dot((2.69,-1.5),blue); dot((2,-1.5),blue); 
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle); 
 (Error making remote request. Unknown error_msg)

Courtesy of User:Kouichi Nakagawa.

<geogebra>9fa91fc57b9e5def39d73828270c8c027c565d85</geogebra>