NAME
math-image -- display some mathematical images
SYNOPSIS
math-image [--options]
DESCRIPTION
math-image
displays some mathematical images, either in a Gtk2 GUI, as an image file output, or setting the root window.
There's lots of options for what to display, in particular including Ulam's spiral of prime numbers, and variations on the numbers in a path theme including Sacks spiral and Vogel floret. Try --random
or the Randomize button for interesting combinations.
Most of the code is plain Perl, so it's not blindingly fast, but the GUI or the root window are drawn progressively so you can see what's happening. In the GUI you can change the controls while drawing to start again on something else.
Mouse button 1 in the GUI drags the image to see parts away from the origin and which otherwise wouldn't fit on screen. This can become particularly slow when displaying things like prime numbers which must be calculated all the way up to the desired part.
OPTIONS
Values Options
The following otpions control what set of values to display. The --values
option described last is the most general.
- --primes
-
The prime numbers.
- --twin
- --twin1
- --twin2
-
The twin primes.
--twin
is both twins like 11,13.--twin1
is just the first of each like 11, or--twin2
is just the second like 13. - --semi-primes
- --semi-primes-odd
-
The semi-prime or bi-prime numbers, meaning integers which have two prime factors p*q, including p==q squares of primes.
--semi-primes-odd
is just the odd semiprimes. - --squares
-
The perfect squares 1, 4, 9, 16, 25, 36, etc.
- --pronic
-
The pronic numbers 2, 6, 12, 20, 30, 42, etc, k*(k+1). These are half way between successive perfect squares, and twice the triangular numbers.
- --triangular
-
The triangular numbers 1, 3, 6, 10, 15, 21, etc, k*(k+1)/2.
- --polygonal=K
-
The K-sided polygon numbers. For example
--polygonal=3
is the triangular numbers,--polygonal=4
is the squares. - --cubes
- --tetrahedral
-
The cubes 1, 8, 27, 64, 125, etc or tetrahedral numbers 1, 4, 10, 20, 35, 56, etc. These tend to grow too quickly to display much of a pattern, though the Vogel floret is close,
math-image --cubes --vogel
- --fibonacci
-
The Fibonacci numbers 1,1,2,3,5,8,13,21, etc. On the Vogel floret these fall on an axis going to the right. For other spirals and paths they tend to grow too quickly to show much.
- --perrin
- --padovan
-
The Perrin numbers 3, 0, 2, 3, 2, 5, 5, 7, 10, etc. Or Padovan numbers 1, 1, 1, 2, 2, 3, 4, 5, 7, 9, etc. These are cubic recurrences and tend to grow too quickly to display much in the way of patterns.
- --fraction=5/29
- --fraction=1.234
-
The digits in the decimal expansion of a fraction. For example the default in the GUI is 5/29 which means 9,11,12, 17, 21,22,24, 27,28,29,30, etc. A decimal like 1.234 means 1234/1000.
A fraction is always a repeating pattern, with length no longer than the denominator, but can give interesting patterns for various paths. For example 1/137 in binary (choose radix 2 in the GUI) shows the fine structure constant 1/137 as a repeating pattern of an angry man with a beard and a skull wearing a hat. No doubt this has deep cosmic significance.
- --all
- --odd
- --even
-
All integers, or just odd or even integers. For the paths which fill the plane
--all
will just fill the screen (slowly!), but for--sacks
and--vogel
it shows where all the points lie. - --aronson
-
Aronson's sequence 1,4,9,... of "T is the first, fourth, ninth, ...". This requires the
Math::Aronson
module. - --expression='x^2+2*x+1'
-
Draw values following a formula. It should have a single variable which will be evaluated at 0,1,2, etc. This option requires
Math::Symbolic
. - --lines
-
Draw lines along the path instead of a set of selected points. This shows where a path travels but you may have to increase the
--scale
to see it properly. - --values=MODULE
- --values=MODULE,NAME=VALUE,NAME=VALUE,...
-
Draw values from the given
App::MathImage::NumSeq::Sequence
module. For examplemath-image --values=Emirps
The names for these modules are not settled, so expect some splits, mergers or renamings. Parameters can be passed as comma separated NAME=VALUE, for example
math-image --values=TwinPrimes,pairs=both
This can be used to read values from a text file
math-image --values=File,filename=/my/dir/data.txt
And the OEIS module takes a sequence of values by its OEIS A-number, for example tribonnaci numbers A000073
math-image --values=OEIS,anum=A000073
This selects whichever module implements the desired sequence, or will read downloaded OEIS files from a $HOME/OEIS/ directory,
A000073.internal # for info A000073.html # fragile for info, but accepted b000073.txt # values file, if available
A .internal file is the "internal format" OEIS info download. The .html rendition of the same works, but parsing it is likely to be fragile and may or may not work.
Path Options
The following control the path in the plane where on which the values will be displayed. The --path
option described last is the most general.
- --ulam
-
Ulam's primes in a square spiral (currently the default).
- --vogel
-
Vogel's floret design for the positions of seeds in a sunflower (see Math::PlanePath::VogelFloret). Try the following to see all the points in the pattern before applying various special sets of values.
math-image --vogel --all --scale=10
Scaling up helps the circles draw properly. When the values displayed are less than all the integers a lower scale can be used.
- --sacks
-
An Archimedian spiral with the square root as angle of rotation, by Robert Sacks (see Math::PlanePath::SacksSpiral).
- --theodorus
-
The spiral of Theodorus or square-root spiral (see Math::PlanePath::TheodorusSpiral).
- --diamond
-
A diamond shaped spiral (see Math::PlanePath::DiamondSpiral).
- --pyramid
-
The sides of a pyramid shape (see Math::PlanePath::PyramidSides).
- --pyramid-rows
-
A pyramid made from horizontal rows (see Math::PlanePath::PyramidRows).
- --corner
- --diagonals
-
Corners or diagonals between the X and Y axes, per Math::PlanePath::Corner and Math::PlanePath::Diagonals.
- --rows
- --columns
-
Points drawn in successive rows or columns.
- --path=MODULE
- --path=MODULE,NAME=VALUE,NAME=VALUE,...
-
Draw following the given
Math::PlanePath
module. For examplemath-image --path=HeptSpiralSkewed
This includes experimental paths called "MathImageFoo", but expect their names to change when finished.
Parameters to the path are supplied as comma separated
NAME=VALUE
, for example,math-image --path=SquareSpiral,wider=3
Output Options
The default is to run the Gtk GUI.
- --fullscreen
-
Start the GUI in full screen mode. Menu entry Tools/Fullscreen can toggle between full screen and a normal window. In full screen mode the menus still work, just press Alt-F, Alt-T, etc as normal.
- --root
-
Set the root window background to the requested image and exit. For example a random image from your ~/.xsession file,
math-image --root --random
Add
--verbose
to print what was in fact chosen and displayed. Output in ~/.xsession normally goes to the ~/.xsession-errors file. Sometimes--random
may use a lot of memory, so consider alimit
(see sh(1)) or timeout (see timeout(1)), or both.Under X the root window is set with
X11::Protocol
if available, otherwiseGtk2
.X11::Protocol
is preferred as it allows--foreground
and--background
colours to be preserved on a PseudoColor visual.Gtk2
is fine on a TrueColor, or using black and white (those colours permanent in the default colormap), but otherwise colours won't be preserved. - --flash
-
Flash the requested image on the screen instead of starting the GUI. Together with
--root
the image is drawn to the root then flashed as well. This is good if updating the background randomly every so often, as it shows the image when otherwise obscured by lots of windows.math-image --root --random --flash
- --display=DPY
-
Select the X server for X11 or Gtk output. The default is from the
DISPLAY
environment variable (normally set at X startup).math-image --display=:3
- --png
- --xpm
-
Write a PNG or XPM image file to standard output and exit. PNG is always possible with GdkPixbuf but can also use
Image::Base::GD
,Image::Base::PNGwriter
,Image::Base::Imager
,Image::Base::Magick
orImage::Base::Prima::Image
and their respective supporting libraries.math-image --png >/tmp/my-file.png
XPM output requires either
Image::Xpm
,Image::Base::Magick
orImage::Base::Prima::Image
.Note that Prima for X11 requires an X server to do its drawing, either PNG or XPM (expect an obscure error if no display).
- --text
-
Write a text-only image to standard output and exit. The default size follows the terminal with
Term::Size
. A typical tty size like 80x25 is usually too small to see much, but a bigger image might be cute to send to a line printer or similar.math-image --text --size=130x49 | lpr
- --prima
-
Run the Prima GUI. This requires the
Prima
andImage::Base::Prima::Drawable
modules. It doesn't yet have the full set of options the Gtk GUI does, but works as far as it goes.A combination
--prima --png
means write a PNG image to standard output, using Prima. - --curses
-
Run the Curses interactive text interface. This requires the
Curses::UI
modules. This is experimental and the control options are minimal.
Other Options
- --random
-
Choose a path and values at random. For example in your ~/.xsession
math-image --root --random
- --foreground=COLOUR
- --background=COLOUR
-
Set the foreground and background colours. The colours can be either names or hex style #RRGGBB or #RRRRGGGGBBBB. For example white on a shade of red,
math-image --foreground=white --background=#A01010
The default is white foreground on black background. For a
--root
background a full white can be a bit hard on the eye when there's a lot of points shown. Try a shade of grey insteadmath-image --root --foreground=lightgrey
Available names depend on the output type. Gtk uses a hard-coded copy of the X /etc/X11/rgb.txt. The
X11::Protocol
--root
uses the server's database.--png
output with GD has theGD::Simple
names.--xpm
passes anything at all through to the file. For--text
currently the colours can be single characters to show, though perhaps that will change. - --size=PIXELS
- --size=WIDTHxHEIGHT
-
Set the size of the image in pixels. A single value means that size square, otherwise WIDTHxHEIGHT. For
--root
this size is currently ignored and the full screen used.For the GUI this is an initial size, though it might be widened to accommodate the menubar. Under
--fullscreen
the size is the unfullscreened window if you switch back to that (menu entry Tools/Fullscreen).The default for the GUI is about 4/5 of the screen. The default for PNG etc image file output is an arbitrary 200x200, or for
--text
output the size of the terminal fromTerm::Size
. - --scale=PIXELS
-
How many pixels for each value shown. The current default is 3 to show 3x3 pixel squares, or for
--text
output just 1 for a pixel per character - --help, -?
-
Print a summary of the options.
- --version
-
Print the program version number.
- --<gtk-options>
-
Standard Gtk options. See gtk-options(7) for the full list. The only one which does much for
math-image
is--display
to set the X display (default from theDISPLAY
environment variable).
MODULES
In addition to the modules noted above, the following are used in the GUI if available,
Gtk2::Ex::PodViewer
-
A "Help/POD Documentation" menu item to display this documentation and the
Math::PlanePath
classes. Gtk2::Ex::CrossHair
-
Lines following the cursor, enabled from the Tools/Cross menu item.
Gtk2::Ex::ErrorTextDialog
-
Error messages in a dialog instead of to
STDERR
. Of course there shouldn't be any errors! Gtk2::Ex::QuadButton
-
Scroll arrows in the bottom right corner.
ENVIRONMENT
DISPLAY
-
The X display to use.
BUGS
Some of the values plotted can be a bit slow to generate or use a lot of memory, or both. When the path goes out to large positions, or when paged out away from the origin, the display can hang generating values. This happens for example plotting primes on the PythagoreanTree.
SEE ALSO
Math::PlanePath, Math::Aronson, Gtk2, X11::Protocol, Gtk2::Ex::PodViewer, Gtk2::Ex::CrossHair, Gtk2::Ex::ErrorTextDialog
HOME PAGE
http://user42.tuxfamily.org/math-image/index.html
LICENSE
Math-Image is Copyright 2010, 2011 Kevin Ryde
Math-Image is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-Image is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-Image. If not, see <http://www.gnu.org/licenses/>.