This is an example of a fractal, generated recursivey. We use simple plot commands, holding the current graphics.
>A=[cos(pi/3),-sin(pi/3);sin(pi/3),cos(pi/3)]; >B=inv(A); >function koch (x,v,n) ...
global A,B; if n==0 then hold on; plot([x[1],x[1]+v[1]],[x[2],x[2]+v[2]]); hold off; else w=v/3; koch(x,w,n-1); x=x+w; w1=A.w; koch(x,w1,n-1); x=x+w1; w1=B.w; koch(x,w1,n-1); x=x+w1; koch(x,w,n-1); endif; endfunction
One level deep, the Curve looks like this.
>plot2d(none,a=0,b=1,c=0,d=1); ... >koch([0;0],[1;1],2); insimg;
Several levels deep, we relace every straight line with one curve of the same shape over and over again. The work grows exponentially. n=7 is about the most, Euler can do.
>plot2d(none,a=0,b=1,c=0,d=1); ... >koch([0;0],[1;1],7); insimg;