"Fossies" - the Fresh Open Source Software Archive

Member "NZMATH-1.2.0/tutorial.txt" (26 Nov 2012, 9874 Bytes) of package /linux/misc/old/NZMATH-1.2.0.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 ===============
    2 NZMATH Tutorial
    3 ===============
    4 
    5 --------------
    6 1. What is it?
    7 --------------
    8 
    9 The purpose of the NZMATH system is to provide mathematical,
   10 especially number-theoretic computational power to you.  It is written
   11 in Python scripting language in order to enhance quickly with users'
   12 experiences.
   13 
   14 
   15 --------
   16 2. Usage
   17 --------
   18 
   19 2.1. Before You Start
   20 =====================
   21 
   22 2.1.1. Installation of Python
   23 -----------------------------
   24 
   25 NZMATH requires Python version 2.5 or later.  If you do not have
   26 Python installed on your computer, please install it.
   27 
   28 The Python language is a very high level language.  It is downloadable
   29 from the website_.  There are also some documents there.
   30 
   31 .. _website: http://www.python.org/
   32 
   33 2.1.1.1. Note about Python 3
   34 ----------------------------
   35 
   36 NZMATH is not ready for Python 3 now.
   37 It is planned to port NZMATH for Python 3, in a year or so.
   38 
   39 
   40 2.1.2. Installation of NZMATH
   41 -----------------------------
   42 
   43 2.1.2.1. Download
   44 -----------------
   45 
   46 First of all, please download the distribution file.  The file you
   47 need differs depending on your operating system.  For unix or
   48 unix-like systems the file is NZMATH-x.y.z.tar.gz, where x, y, z are
   49 non-negative integers.  For Microsoft Windows,
   50 NZMATH-x.y.z.win32Install.exe.
   51 
   52 The places to download are:
   53  * http://sourceforge.net/projects/nzmath/files/
   54  * http://tnt.math.se.tmu.ac.jp/nzmath/download/
   55 
   56 
   57 2.1.2.1. On Unix sytems including Linux, Mac OS X, etc.
   58 -------------------------------------------------------
   59 
   60 To install NZMATH you should have privilege which lets you install
   61 some files under the standard python script path,
   62 /usr/lib/python2.5/site-packages or
   63 /usr/local/lib/python2.5/site-packages depending on the Python
   64 installation path.
   65 
   66 We denote the privileged user's prompt # and ordinary user's %.
   67 
   68 Expand the downloaded file.
   69 
   70     % tar zxf NZMATH-x.y.z.tar.gz
   71 
   72 Then, you have a child directory named NZMATH-x.y.z.
   73 
   74     % cd NZMATH-x.y.z
   75     % su
   76     # python setup.py install
   77 
   78 The last command install NZMATH into the python script path described
   79 above.
   80 
   81 
   82 2.1.2.2. On Windows
   83 -------------------
   84 
   85 Click the downloaded file, and follow the instruction.
   86 
   87 
   88 2.1.3. Installation of IPython
   89 ------------------------------
   90 
   91 (Optional, but recommended)
   92 
   93 IPython is an enhanced interactive Python shell.  If you do not have
   94 it installed on your system, it is recommended to install it now.
   95 
   96 To install it, follow the instruction on its own documentation.
   97 http://ipython.scipy.org/moin/
   98 
   99 
  100 2.1.4. Installation of mpmath
  101 -----------------------------
  102 
  103 (Optional, but recommended)
  104 
  105 mpmath is a multiple precision floating point arithmetic package for
  106 Python.  Some modules in NZMATH essentially depend on the availability
  107 of mpmath, and some other modules can be more powerful with mpmath.
  108 
  109 To install it, follow the instruction on its own documentation.
  110 http://code.google.com/p/mpmath/
  111 
  112 
  113 2.2. Quick Start
  114 ================
  115 
  116 2.2.1. User Interfaces
  117 ----------------------
  118 
  119 NZMATH does not have own interpreter nor graphical interface.  Users
  120 have to use with the raw Python interpreter (or possibly IPython).
  121 Though the interpreters are designed well, of course, they are not
  122 specialized for mathematical computation.  Please be patient about it.
  123 
  124 
  125 2.2.2. Sample Session
  126 ---------------------
  127 
  128 Start your Python interpreter
  129 
  130     % python
  131     Python 2.6.2 (r262:71600, Sep  3 2009, 19:37:04)
  132     [GCC 4.2.1 (Apple Inc. build 5574)] on darwin
  133     Type "help", "copyright", "credits" or "license" for more information.
  134     >>>
  135 
  136 (we use '%' for a command prompt.  If you are on Windows, it may be
  137 'C:\>' or something.)
  138 
  139 Here, '>>>' is a Python prompt.  You are in the Python interpreter
  140 until you will type EOF (Ctrl-D on unices and Ctrl-Z on Windows).
  141 Then, type:
  142 
  143     >>> from nzmath import *
  144     >>>
  145 
  146 The whole NZMATH stuff is imported.
  147 
  148     >>> r = rational.Rational(113, 355)
  149     >>> print r
  150     113/355
  151     >>>
  152     ....
  153 
  154 The session continues until you will stop.
  155 
  156 2.2.3. Readline
  157 ---------------
  158 
  159 (Optional)
  160 As you see, class names of NZMATH objects may be boringly long to
  161 type.  You can use completion feature; if you are using ipython it is
  162 presented by default, or if you use default Python you might be able
  163 to configure it to use readline.  Unfortunately, sometimes Python is
  164 built WITHOUT readline module for some license issue.  So, the
  165 following is for those who are lucky to have readline enabled Python.
  166 
  167 Save the following content in your file, pythonrc.py, for example:
  168 
  169 try:
  170     import readline
  171 except ImportError:
  172     print "Module readline not available."
  173 else:
  174     import rlcompleter
  175     readline.parse_and_bind("tab: complete")
  176 
  177 Then, set environment variable PYTHONSTARTUP pointing to the file.
  178 
  179 (Please read Python Library Reference of readline and rlcompleter
  180 modules for more detailed explanation.)
  181 
  182 
  183 -------------------------
  184 3. How to Write a Program
  185 -------------------------
  186 
  187 Writing everything at the interpreter prompt is a dull work.  Instead
  188 of it, you can make a program file.
  189 
  190 The name of file must end with '.py'; for example, 'sample.py'.
  191 
  192 The contents of the file must be a valid Python program.  And, you may
  193 want to import some NZMATH modules at the start of the file.
  194 
  195 See the Python documents for detailed Python syntax or built-in data
  196 types and functions.  NZMATH data types are explained below.
  197 
  198 To invoke your program (sample.py, say), simply:
  199 
  200     % python sample.py
  201 
  202 Or, if you are using unices, make it executable as usual.
  203 
  204 
  205 -------------
  206 4. Data types
  207 -------------
  208 
  209 Python is an object-oriented programming language, and user can create
  210 a new data type as class.  The data types provided by NZMATH are also
  211 classes, which have a lot of methods including overloaded operators.
  212 
  213 
  214 4.1. Numbers
  215 ============
  216 
  217 4.1.1. Integer
  218 --------------
  219 
  220 There are two integer data types already in Python; int (single
  221 precision) and long (arbitrary precision).  NZMATH has Integer
  222 (nzmath.rational.Integer) to give a rational result for division
  223 instead of a float.
  224 
  225     >>> from __future__ import division # new division semantics
  226     >>> rational.Integer(3) / 4
  227     Rational(3, 4)
  228     >>> 3 / 4
  229     0.75
  230     >>> 3L / 4L
  231     0.75
  232 
  233 If you do not import division from __future__, then Python's
  234 int/long behave just like C's int type, i.e. floor division.
  235 
  236     >>> 3 / 4
  237     0
  238     >>>
  239 
  240 In many cases, Python's integer is chosen for the sake of execution
  241 speed.  Even in such cases, doing "from __future__ import division"
  242 is strongly recommended.  With or without future declaration, floor
  243 division is available as double slash operator.
  244 
  245     >>> 3 // 4
  246     0
  247     >>> 8L // 5
  248     1L
  249 
  250 The *L* suffix indicating the number is a long integer does not have
  251 any real meaning, so please ignore it.
  252 
  253 
  254 4.1.2. Rational
  255 ---------------
  256 
  257 NZMATH provides Rational (nzmath.rational.Rational) class representing
  258 a rational number, as already appeared in the previous example.
  259 
  260 
  261 4.1.3. Algebraic number
  262 -----------------------
  263 
  264 In NZMATH, algfield provides algebraic numbers.
  265 
  266 
  267 4.1.4. floating point number
  268 ----------------------------
  269 
  270 Python has float data type for it.  The mpmath also provides it.
  271 
  272 
  273 4.2. Algebraic types
  274 ====================
  275 
  276 4.2.1. Polynomials
  277 ------------------
  278 
  279 There are several polynomial classes.  New users should use poly
  280 sub-package.
  281 
  282     >>> poly.uniutil.polynomial({0:-1,100:1}, rational.theIntegerRing)
  283     IntegerPolynomial([(0, -1L), (100, 1L)], IntegerRing())
  284 
  285 poly.uniutil.polynomial is the factory function for univariate
  286 polynomials.
  287 
  288 
  289 4.2.2. Matrices
  290 ---------------
  291 
  292 There are several matrix classes.  matrix module provides them.
  293 
  294 
  295 4.3. Algebraic structures
  296 =========================
  297 
  298 4.3.1. Rings
  299 ------------
  300 
  301 Integers are in the integer ring, A polynomial in a certain polynomial
  302 ring, etc..  They are obtained from elements of them by getRing
  303 method.  For example, rational.Integer(1).getRing() returns a
  304 rational.IntegerRing object.
  305 
  306 This is a convention in NZMATH and does not apply to the object
  307 provided by Python itself such as int or long.
  308 
  309 
  310 4.3.2. Fields
  311 -------------
  312 
  313 Fields are a part of rings (see Rings).
  314 
  315 There are some fields: the field of rational numbers, real numbers,
  316 and complex numbers are defined.  Finite fields are provided through
  317 finitefield module.
  318 
  319 
  320 4.3.3. Groups
  321 -------------
  322 
  323 There are some groups in NZMATH: for example, class group of
  324 imaginary quadratic fields in quad module, or rational point of
  325 elliptic curves over finite fields in elliptic module.
  326 
  327 We are not providing general frameworks for them, though.
  328 
  329 
  330 ----------------
  331 5. Other Modules
  332 ----------------
  333 
  334 There are other modules, such as bigrandom, factor, prime, etc.
  335 Please read the manual for those modules.
  336 
  337 
  338 --------------
  339 6. Development
  340 --------------
  341 
  342 The project is of open source, and your participation is essential.
  343 
  344 6.1. sourceforge.net
  345 ====================
  346 
  347 We have a project site on the sf.net_.  There are bug tracker, source
  348 repository and so on.
  349 
  350 .. _sf.net: http://sourceforge.net/projects/nzmath/
  351 
  352 6.2. TMU
  353 ========
  354 
  355 Almost all the former developers are doctor course / master course
  356 students of Tokyo Metropolitan University (TMU).  There is the server
  357 called tnt, which is primalily run for TNT (Tools on Number Theory)
  358 project, hosting `web pages`_ and the mailing list (see below).
  359 
  360 .. _web pages: http://tnt.math.se.tmu.ac.jp/nzmath/
  361 
  362 
  363 6.2.1. Mailing List
  364 -------------------
  365 
  366 A mailing list nzmath-user@tnt.math.se.tmu.ac.jp is for discussing
  367 anything about NZMATH.  You can join the list with writing a mail
  368 containing a line of "subscribe" in the body to
  369 nzmath-user-request@tnt.math.se.tmu.ac.jp.  *Be careful* not to send
  370 it to nzmath-user.
  371 
  372 
  373 ----------
  374 7. License
  375 ----------
  376 
  377 NZMATH is distributed under the BSD license.  Please read LICENSE.txt_
  378 in the distribution tar ball for detail.
  379 
  380 .. _LICENSE.txt: LICENSE.txt
  381 
  382 
  383 Copyright (c) 2004-2012, NZMATH development group, all right reserved.