NAME
math-image -- display some mathematical images
SYNOPSIS
math-image [--options]
DESCRIPTION
math-image
displays some mathematical style images, either in a Gtk2 graphical interface, as an image file output, or setting the root window.
There's lots of options for images to display, in particular they include Ulam's spiral of prime numbers, and variations on that numbers in a path theme, including Sacks spiral and Vogel floret.
OPTIONS
Values Options
The following control what set of values is displayed in the image.
- --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.
- --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 path 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=NUM/DEN
-
The 1 bits in the binary expansion of a fraction. The default is 5/29 which means 9,11,12, 17, 21,22,24, 27,28,29,30, etc. A fraction is always a repeating pattern, with length no longer than the denominator, but can give interesting patterns for various paths.
- --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--vogely
it shows where all the points lie. - --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.
Path Options
The following control the path in the plane where the values will be displayed as pixels (or circles for Sacks and Vogel).
- --ulam
-
Ulam's primes in a square spiral (currently the default too).
- --vogel
-
Vogel's floret design for the positions of seeds in a sunflower. 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 points going by their square root, by Robert Sacks.
- --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
-
Diagonals between the X and Y axes, per Math::PlanePath::Diagonals.
- --rows
- --columns
Output Options
- --window
-
Run the Gtk GUI. This is the default.
- --fullscreen
-
Run the Gtk GUI starting in full screen mode. Press Control-F to toggle between full screen and a normal window. In full screen mode the menus can still be used, just press Alt-E etc as normal.
- --root
-
Set the root window background to the requested image and exit. For example to a random image, perhaps from your ~/.xsession file,
math-image --root --random
Under X the root window is set with
X11::Protocol
if available, orGtk2
otherwise.X11::Protocol
is preferred as it allows the--foreground
and--background
colours to be saved on a pseudo-colour screen.Gtk2
on a true-colour screen is fine, as are black and white (being permanent in the default colormap) but other colours won't be preserved. - --display=DPY
-
Select an X display for
X11::Protocol
or Gtk. The default is from theDISPLAY
environment variable.math-image --display=:3
- --png
- --xpm
-
Write a PNG or XPM image file to standard output and exit. PNG requires either
Image::Base::GD
orImage::Base::PNGwriter
and the respective supporting libraries. XPM output requiresImage::Xpm
.math-image --png >/tmp/my-file.png
- --text
-
Write a text-only image to standard output and exit. The default size follows the terminal (per
Term::Size
). This 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 --width=130 --height=49 | lpr
Other Options
- --random
-
Choose a path and values at random. For example in your ~/.xsession
math-image --root --random
- --scale=PIXELS
-
How many pixels for each value shown. The current default is 3 to show 3x3 squares, or for
--text
output just 1. - --foreground=COLOUR
- --background=COLOUR
-
Set the foreground and background colours. The colours can be names, or hex style #RRGGBB or #RRRRGGGGBBBB. For example white on a shade of red,
math-image --foreground=white --background=#A01010
Available names depend on the output type, for example in Gtk and X the X RGB database /etc/X11/rgb.txt, or for PNG output the
GD::Simple
names, or for XPM anything at all passes through to the file. - --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 for the window, though it may be widened to accomodate to the menubar. Under
--fullscreen
this is the unfullscreened size if you switch to that (Control-F).The default for the GUI is to make the toplevel window about 4/5 of the screen. The default for image file output is an arbitrary 200x200, or for
--text
output the size of the terminal (perTerm::Size
). - --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).
OPTIONAL MODULES
In addition to Math::Symbolic
and the image output modules described above, the following optional module are used in the GUI if available,
Gtk2::Ex::CrossHair
-
Lines following the cursor.
Gtk2::Ex::ErrorTextDialog
-
Error messages in a dialog instead of to
STDERR
. Of course there shouldn't be any errors, though currently a bad "expression" entered will provoke errors.
BUGS
Math::Prime::XS
is used to generate primes but as of version 0.20_01 it puts its sieve space on the stack (the C stack) which may limit the size of images showing primes. Depending on the chosen path an image 3000 high or so might overflow an 8Mb stack limit (see ulimit(3)). The symptom is usually a seg fault. Increase the stack if necessary or perhaps a newer module version will use plain malloc
, and/or pack more sieving into the bytes.
SEE ALSO
LICENSE
Math-Image is Copyright 2010 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/>.