1 .TH ginsh 1 "January, 2000" "GiNaC @VERSION@" "The GiNaC Group"
3 ginsh \- GiNaC Interactive Shell
9 is an interactive frontend for the GiNaC symbolic computation framework.
10 It is intended as a tool for testing and experimenting with GiNaC's
11 features, not as a replacement for traditional interactive computer
12 algebra systems. Although it can do many things these traditional systems
13 can do, ginsh provides no programming constructs like loops or conditional
14 expressions. If you need this functionality you are advised to write
15 your program in C++, using the "native" GiNaC class framework.
18 After startup, ginsh displays a prompt ("> ") signifying that it is ready
19 to accept your input. Acceptable input are numeric or symbolic expressions
20 consisting of numbers (e.g.
21 .BR 42 ", " 2/3 " or " 0.17 ),
23 .BR x " or " result ),
24 mathematical operators like
27 .BR sin " or " normal ).
28 Every input expression must be terminated with either a semicolon
32 If terminated with a semicolon, ginsh will evaluate the expression and print
33 the result to stdout. If terminated with a colon, ginsh will only evaluate the
34 expression but not print the result. It is possible to enter multiple
35 expressions on one line. Whitespace (spaces, tabs, newlines) can be applied
36 freely between tokens. To quit ginsh, enter
37 .BR quit " or " exit ,
38 or type an EOF (Ctrl-D) at the prompt.
40 Anything following a double slash
42 up to the end of the line, and all lines starting with a hash mark
44 are treated as a comment and ignored.
46 ginsh accepts numbers in the usual decimal notations. This includes arbitrary
47 precision integers and rationals as well as floating point numbers in standard
48 or scientific notation (e.g.
50 The general rule is that if a number contains a decimal point
52 it is an (inexact) floating point number; otherwise it is an (exact) integer or
54 Integers can be specified in binary, octal, hexadecimal or arbitrary (2-36) base
55 by prefixing them with
56 .BR #b ", " #o ", " #x ", or "
60 Symbols are made up of a string of alphanumeric characters and the underscore
62 with the first character being non-numeric. E.g.
64 are acceptable symbol names, while
66 is not. It is possible to use symbols with the same names as functions (e.g.
68 ginsh is able to distinguish between the two.
70 Symbols can be assigned values by entering
72 .IB symbol " = " expression ;
75 To unassign the value of an assigned symbol, type
77 .BI unassign(' symbol ');
80 Assigned symbols are automatically evaluated (= replaced by their assigned value)
81 when they are used. To refer to the unevaluated symbol, put single quotes
83 around the name, as demonstrated for the "unassign" command above.
85 Symbols are considered to be in the complex domain by default, i.e. they are
86 treated as if they stand in for complex numbers. This behavior can be changed
91 and affects all newly created symbols.
93 The following symbols are pre-defined constants that cannot be assigned
104 Euler-Mascheroni Constant
110 an object of the GiNaC "fail" class
113 There is also the special
117 symbol that controls the numeric precision of calculations with inexact numbers.
118 Assigning an integer value to digits will change the precision to the given
119 number of decimal places.
121 The has(), find(), match() and subs() functions accept wildcards as placeholders
122 for expressions. These have the syntax
126 for example $0, $1 etc.
127 .SS LAST PRINTED EXPRESSIONS
128 ginsh provides the three special symbols
132 that refer to the last, second last, and third last printed expression, respectively.
133 These are handy if you want to use the results of previous computations in a new
136 ginsh provides the following operators, listed in falling order of precedence:
139 \" GINSH_OP_HELP_START
187 All binary operators are left-associative, with the exception of
189 which are right-associative. The result of the assignment operator
191 is its right-hand side, so it's possible to assign multiple symbols in one
193 .BR "a = b = c = 2;" ).
195 Lists are used by the
199 functions. A list consists of an opening curly brace
201 a (possibly empty) comma-separated sequence of expressions, and a closing curly
205 A matrix consists of an opening square bracket
207 a non-empty comma-separated sequence of matrix rows, and a closing square bracket
209 Each matrix row consists of an opening square bracket
211 a non-empty comma-separated sequence of expressions, and a closing square bracket
213 If the rows of a matrix are not of the same length, the width of the matrix
214 becomes that of the longest row and shorter rows are filled up at the end
215 with elements of value zero.
217 A function call in ginsh has the form
219 .IB name ( arguments )
223 is a comma-separated sequence of expressions. ginsh provides a couple of built-in
224 functions and also "imports" all symbolic functions defined by GiNaC and additional
225 libraries. There is no way to define your own functions other than linking ginsh
226 against a library that defines symbolic GiNaC functions.
228 ginsh provides Tab-completion on function names: if you type the first part of
229 a function name, hitting Tab will complete the name if possible. If the part you
230 typed is not unique, hitting Tab again will display a list of matching functions.
231 Hitting Tab twice at the prompt will display the list of all available functions.
233 A list of the built-in functions follows. They nearly all work as the
234 respective GiNaC methods of the same name, so I will not describe them in
235 detail here. Please refer to the GiNaC documentation.
238 \" GINSH_FCN_HELP_START
239 .BI charpoly( matrix ", " symbol )
240 \- characteristic polynomial of a matrix
242 .BI coeff( expression ", " object ", " number )
243 \- extracts coefficient of object^number from a polynomial
245 .BI collect( expression ", " object-or-list )
246 \- collects coefficients of like powers (result in recursive form)
248 .BI collect_distributed( expression ", " list )
249 \- collects coefficients of like powers (result in distributed form)
251 .BI collect_common_factors( expression )
252 \- collects common factors from the terms of sums
254 .BI conjugate( expression )
255 \- complex conjugation
257 .BI content( expression ", " symbol )
258 \- content part of a polynomial
260 .BI decomp_rational( expression ", " symbol )
261 \- decompose rational function into polynomial and proper rational function
263 .BI degree( expression ", " object )
264 \- degree of a polynomial
266 .BI denom( expression )
267 \- denominator of a rational function
269 .BI determinant( matrix )
270 \- determinant of a matrix
272 .BI diag( expression... )
273 \- constructs diagonal matrix
275 .BI diff( expression ", " "symbol [" ", " number] )
276 \- partial differentiation
278 .BI divide( expression ", " expression )
279 \- exact polynomial division
281 .BI eval( "expression [" ", " level] )
282 \- evaluates an expression, replacing symbols by their assigned value
284 .BI evalf( "expression [" ", " level] )
285 \- evaluates an expression to a floating point number
287 .BI evalm( expression )
288 \- evaluates sums, products and integer powers of matrices
290 .BI expand( expression )
291 \- expands an expression
293 .BI find( expression ", " pattern )
294 \- returns a list of all occurrences of a pattern in an expression
296 .BI gcd( expression ", " expression )
297 \- greatest common divisor
299 .BI has( expression ", " pattern )
300 \- returns "1" if the first expression contains the pattern as a subexpression, "0" otherwise
302 .BI integer_content( expression )
303 \- integer content of a polynomial
305 .BI inverse( matrix )
306 \- inverse of a matrix
309 \- returns "1" if the relation is true, "0" otherwise (false or undecided)
311 .BI lcm( expression ", " expression )
312 \- least common multiple
314 .BI lcoeff( expression ", " object )
315 \- leading coefficient of a polynomial
317 .BI ldegree( expression ", " object )
318 \- low degree of a polynomial
320 .BI lsolve( equation-list ", " symbol-list )
321 \- solve system of linear equations
323 .BI map( expression ", " pattern )
324 \- apply function to each operand; the function to be applied is specified as a pattern with the "$0" wildcard standing for the operands
326 .BI match( expression ", " pattern )
327 \- check whether expression matches a pattern; returns a list of wildcard substitutions or "FAIL" if there is no match
329 .BI nops( expression )
330 \- number of operands in expression
332 .BI normal( "expression [" ", " level] )
333 \- rational function normalization
335 .BI numer( expression )
336 \- numerator of a rational function
338 .BI numer_denom( expression )
339 \- numerator and denumerator of a rational function as a list
341 .BI op( expression ", " number )
342 \- extract operand from expression
344 .BI power( expr1 ", " expr2 )
345 \- exponentiation (equivalent to writing expr1^expr2)
347 .BI prem( expression ", " expression ", " symbol )
348 \- pseudo-remainder of polynomials
350 .BI primpart( expression ", " symbol )
351 \- primitive part of a polynomial
353 .BI quo( expression ", " expression ", " symbol )
354 \- quotient of polynomials
359 .BI rem( expression ", " expression ", " symbol )
360 \- remainder of polynomials
362 .BI resultant( expression ", " expression ", " symbol )
363 \- resultant of two polynomials with respect to symbol s
365 .BI series( expression ", " relation-or-symbol ", " order )
368 .BI sprem( expression ", " expression ", " symbol )
369 \- sparse pseudo-remainder of polynomials
371 .BI sqrfree( "expression [" ", " symbol-list] )
372 \- square-free factorization of a polynomial
374 .BI sqrt( expression )
377 .BI subs( expression ", " relation-or-list )
379 .BI subs( expression ", " look-for-list ", " replace-by-list )
380 \- substitute subexpressions (you may use wildcards)
382 .BI tcoeff( expression ", " object )
383 \- trailing coefficient of a polynomial
385 .BI time( expression )
386 \- returns the time in seconds needed to evaluate the given expression
391 .BI transpose( matrix )
392 \- transpose of a matrix
394 .BI unassign( symbol )
395 \- unassign an assigned symbol
397 .BI unit( expression ", " symbol )
398 \- unit part of a polynomial
400 \" GINSH_FCN_HELP_END
412 ginsh can display a (short) help for a given topic (mostly about functions
413 and operators) by entering
421 will display a list of available help topics.
425 .BI print( expression );
427 will print a dump of GiNaC's internal representation for the given
429 This is useful for debugging and for learning about GiNaC internals.
433 .BI print_latex( expression );
435 prints a LaTeX representation of the given
440 .BI print_csrc( expression );
444 in a way that can be used in a C or C++ program.
448 .BI iprint( expression );
452 (which must evaluate to an integer) in decimal, octal, and hexadecimal representations.
454 Finally, the shell escape
457 .RI [ "command " [ arguments ]]
463 to the shell for execution. With this method, you can execute shell commands
464 from within ginsh without having to quit.
472 (x+1)^(\-2)*(\-2\-x+x^2)
474 (2*x\-1)*(x+1)^(\-2)\-2*(x+1)^(\-3)*(\-x+x^2\-2)
478 717897987691852588770249
480 717897987691852588770247/717897987691852588770250
484 0.999999999999999999999995821133292704384960990679
488 (x+1)^(\-2)*(\-x+x^2\-2)
489 > series(sin(x),x==0,6);
490 1*x+(\-1/6)*x^3+1/120*x^5+Order(x^6)
491 > lsolve({3*x+5*y == 7}, {x, y});
492 {x==\-5/3*y+7/3,y==y}
493 > lsolve({3*x+5*y == 7, \-2*x+10*y == \-5}, {x, y});
495 > M = [ [a, b], [c, d] ];
496 [[\-x+x^2\-2,(x+1)^2],[c,d]]
498 \-2*d\-2*x*c\-x^2*c\-x*d+x^2*d\-c
500 (\-d\-2*c)*x+(d\-c)*x^2\-2*d\-c
501 > solve quantum field theory;
502 parse error at quantum
507 .RI "parse error at " foo
508 You entered something which ginsh was unable to parse. Please check the syntax
509 of your input and try again.
511 .RI "argument " num " to " function " must be a " type
516 must be of a certain type (e.g. a symbol, or a list). The first argument has
517 number 0, the second argument number 1, etc.
522 Christian Bauer <Christian.Bauer@uni-mainz.de>
524 Alexander Frink <Alexander.Frink@uni-mainz.de>
526 Richard Kreckel <Richard.Kreckel@uni-mainz.de>
528 Jens Vollinga <vollinga@thep.physik.uni-mainz.de>
530 GiNaC Tutorial \- An open framework for symbolic computation within the
531 C++ programming language
533 CLN \- A Class Library for Numbers, Bruno Haible
535 Copyright \(co 1999-2005 Johannes Gutenberg Universit\(:at Mainz, Germany
537 This program is free software; you can redistribute it and/or modify
538 it under the terms of the GNU General Public License as published by
539 the Free Software Foundation; either version 2 of the License, or
540 (at your option) any later version.
542 This program is distributed in the hope that it will be useful,
543 but WITHOUT ANY WARRANTY; without even the implied warranty of
544 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
545 GNU General Public License for more details.
547 You should have received a copy of the GNU General Public License
548 along with this program; if not, write to the Free Software
549 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.