/usr/share/texmf-texlive/tex/generic/genmisc/mandel.tex is in texlive-generic-recommended 2009-15.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | % TeX Mandelbrot Program
%
% My entry for the contest ``The most useless TeX program ever written''.
% Can anyone top that? (Don't mention MusicTeX in this context. That's not
% meant to be a joke.)
% Also welcome: Improvements of this saving on TeX's resources. This takes
% more than five minutes on my NeXT 486/66.
%
% Seb, 6.7.94
%
% (seb@balu.afp.ruhr-uni-bochum.de)
%
%
% parameters that you can modify:
%
% \x, \y, \xmax, \ymax in units of 10000
\newcount\x
\x=-20000 % means -2.000 for real part of start value
\newcount\y
\y=-20000 % imaginary part
\newcount\xmax
\xmax=20000 % end value, real
\newcount\ymax
\ymax=20000 % end value, imaginary
%
% calculation depth
\newcount\mandeldepth
\mandeldepth=100
%
%
% recursation depth = number of pixels.
\newcount\xsize % (Don't go wild, tail recursion
\xsize=100 % uses loads of TeX memory!)
\newcount\ysize
\ysize=100
%
% picture size
\newdimen\height
\newdimen\width
\height=10cm
\width=10cm
%
% that was all the parameters!
%
%
% pixel size:
\newdimen\xgrid
\xgrid=\height
\divide\xgrid by\xsize
\newdimen\ygrid
\ygrid=\width
\divide\ygrid by\ysize
%
\nopagenumbers
%
\newcount\stepX % work out step sizes
\stepX=\xmax
\advance\stepX by -\x
\divide\stepX by\xsize
\newcount\stepY
\stepY=\ymax
\advance\stepY by -\y
\divide\stepY by\ysize
%
\def\cout#1{\immediate\write16{#1}} % type out debug message
%
\def\yes{Y} % some stupid logical macros
\def\no{N}
\def\notyet{x}
%
\newcount\u % variables for calculation
\newcount\v
\newcount\newV
\newcount\newU
\newcount\d
\newcount\h
\def\runmandel{% % recursive Mandelbrot macro
\newU=\u%
\multiply\newU by \u% % newU := u^2
\h=\v%
\multiply\h by \v% % h := v^2
\advance\newU by -\h% % newU := u^2 - v^2
\h=\x%
\multiply\h by 10000% % h := x * 10000 (normalize)
\advance\newU by \h% % newU := newU + h
\divide\newU by 10000% % renormalize u
\newV=\u%
\multiply\newV by \v%
\multiply\newV by 2% % newV := 2 *u * v
\h=\y%
\multiply\h by 10000% % h := y * 10000
\advance\newV by \h% % newV := newV + h
\divide\newV by 10000% % renormalize v
\u=\newU% % newU = u^2 - v^2 + x
\v=\newV% % newV = 2 * u * v + y
\advance\d by 1%
% \cout{d: \the\d, u: \the\u, v: \the\v}%
\ifnum\d>\mandeldepth% % member ofthe Mandelbrot set
\def\result{\yes}%
\fi%
\ifnum\u<-20000%
\def\result{\no}% % real part exceeded -2
\fi%
\ifnum\u>20000%
\def\result{\no}% % real part exceeded 2
\fi%
\ifnum\v<-20000%
\def\result{\no}% % imaginary part exceeded -2
\fi%
\ifnum\v>20000%
\def\result{\no}% % real part exceeded 2
\fi%
\if\notyet\result\runmandel\fi% % play it again...
}%
\def\result{\yes}%
\def\makeline{\advance\x by \stepX%
%\cout{testing \the\x = i * \the\y}%
\u=0%
\v=0%
\d=0%
\def\result{\notyet}%
\runmandel% result expands to either yes or no now
\if\result\yes%
\vrule height \xgrid depth 0pt width \ygrid%
\else%
\vrule height \xgrid depth 0pt width 0pt\hskip\xgrid%
\fi%
\ifnum\x<\xmax%
\makeline%
\else\fi}%
\def\makepicture{\advance\y by \stepY%
\hbox{\makeline}%
%\cout{y in makepicture: \the\y}%
\ifnum\y<\ymax%
\makepicture%
\else\fi}%
\vbox{\offinterlineskip\makepicture} % now, let's go tail
\bye % recursive!
|