1 .TH ginsh 1 "January, 2000" "GiNaC"
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 ginsh accepts numbers in all formats accepted by CLN (the Class Library for
41 Numbers, that is the foundation of GiNaC's numerics). This includes arbitrary
42 precision integers and rationals as well as floating point numbers in standard
43 or scientific notation (e.g.
45 The general rule is that if a number contains a decimal point
47 it is an (inexact) floating point number; otherwise it is an (exact) integer or
50 Symbols are made up of a string of alphanumeric characters and the underscore
52 with the first character being non-numeric. E.g.
54 are acceptable symbol names, while
56 is not. It is possible to use symbols with the same names as functions (e.g.
58 ginsh is able to distinguish between the two.
60 Symbols can be assigned values by entering
62 .IB symbol " = " expression ;
65 To unassign the value of an assigned symbol, type
67 .BI unassign(' symbol ');
70 Assigned symbols are automatically evaluated (= replaced by their assigned value)
71 when they are used. To refer to the unevaluated symbol, put single quotes
73 around the name, as demonstrated for the "unassign" command above.
75 The following symbols are pre-defined constants that cannot be assigned
86 Euler-Mascheroni Constant
92 an object of the GiNaC "fail" class
95 There is also the special
99 symbol that controls the numeric precision of calculations with inexact numbers.
100 Assigning an integer value to digits will change the precision to the given
101 number of decimal places.
102 .SS LAST PRINTED EXPRESSIONS
103 ginsh provides the three special symbols
107 that refer to the last, second last, and third last printed expression, respectively.
108 These are handy if you want to use the results of previous computations in a new
111 ginsh provides the following operators, listed in falling order of precedence:
114 \" GINSH_OP_HELP_START
131 non-commutative multiplication
165 All binary operators are left-associative, with the exception of
167 which are right-associative. The result of the assignment operator
169 is its right-hand side, so it's possible to assign multiple symbols in one
171 .BR "a = b = c = 2;" ).
173 Lists are used by the
177 functions. A list consists of an opening square bracket
179 a (possibly empty) comma-separated sequence of expressions, and a closing square
183 A matrix consists of an opening double square bracket
185 a non-empty comma-separated sequence of matrix rows, and a closing double square
188 Each matrix row consists of an opening double square bracket
190 a non-empty comma-separated sequence of expressions, and a closing double square
193 If the rows of a matrix are not of the same length, the width of the matrix
194 becomes that of the longest row and shorter rows are filled up at the end
195 with elements of value zero.
197 A function call in ginsh has the form
199 .IB name ( arguments )
203 is a comma-separated sequence of expressions. ginsh provides a couple of built-in
204 functions and also "imports" all symbolic functions defined by GiNaC and additional
205 libraries. There is no way to define your own functions other than linking ginsh
206 against a library that defines symbolic GiNaC functions.
208 ginsh provides Tab-completion on function names: if you type the first part of
209 a function name, hitting Tab will complete the name if possible. If the part you
210 typed is not unique, hitting Tab again will display a list of matching functions.
211 Hitting Tab twice at the prompt will display the list of all available functions.
213 A list of the built-in functions follows. They nearly all work as the
214 respective GiNaC methods of the same name, so I will not describe them in
215 detail here. Please refer to the GiNaC documentation.
218 \" GINSH_FCN_HELP_START
219 .BI charpoly( matrix ", " symbol )
220 \- characteristic polynomial of a matrix
222 .BI coeff( expression ", " symbol ", " number )
223 \- extracts coefficient of symbol^number from a polynomial
225 .BI collect( expression ", " symbol )
226 \- collects coefficients of like powers
228 .BI content( expression ", " symbol )
229 \- content part of a polynomial
231 .BI degree( expression ", " symbol )
232 \- degree of a polynomial
234 .BI denom( expression )
235 \- denominator of a rational function
237 .BI determinant( matrix )
238 \- determinant of a matrix
240 .BI diag( expression... )
241 \- constructs diagonal matrix
243 .BI diff( expression ", " "symbol [" ", " number] )
244 \- partial differentiation
246 .BI divide( expression ", " expression )
247 \- exact polynomial division
249 .BI eval( "expression [" ", " level] )
250 \- evaluates an expression, replacing symbols by their assigned value
252 .BI evalf( "expression [" ", " level] )
253 \- evaluates an expression to a floating point number
255 .BI expand( expression )
256 \- expands an expression
258 .BI gcd( expression ", " expression )
259 \- greatest common divisor
261 .BI has( expression ", " expression )
262 \- returns "1" if the first expression contains the second as a subexpression, "0" otherwise
264 .BI inverse( matrix )
265 \- inverse of a matrix
268 \- returns "1" if the relation is true, "0" otherwise (false or undecided)
270 .BI lcm( expression ", " expression )
271 \- least common multiple
273 .BI lcoeff( expression ", " symbol )
274 \- leading coefficient of a polynomial
276 .BI ldegree( expression ", " symbol )
277 \- low degree of a polynomial
279 .BI lsolve( equation-list ", " symbol-list )
280 \- solve system of linear equations
282 .BI nops( expression )
283 \- number of operands in expression
285 .BI normal( "expression [" ", " level] )
286 \- rational function normalization
288 .BI numer( expression )
289 \- numerator of a rational function
291 .BI op( expression ", " number )
292 \- extract operand from expression
294 .BI power( expr1 ", " expr2 )
295 \- exponentiation (equivalent to writing expr1^expr2)
297 .BI prem( expression ", " expression ", " symbol )
298 \- pseudo-remainder of polynomials
300 .BI primpart( expression ", " symbol )
301 \- primitive part of a polynomial
303 .BI quo( expression ", " expression ", " symbol )
304 \- quotient of polynomials
306 .BI rem( expression ", " expression ", " symbol )
307 \- remainder of polynomials
309 .BI series( expression ", " "symbol [" ", " "point [" ", " order]] )
312 .BI sqrfree( expression ", " symbol )
313 \- square-free factorization of a polynomial
315 .BI sqrt( expression )
318 .BI subs( expression ", " relation-or-list )
320 .BI subs( expression ", " look-for-list ", " replace-by-list )
321 \- substitute subexpressions
323 .BI tcoeff( expression ", " symbol )
324 \- trailing coefficient of a polynomial
326 .BI time( expression )
327 \- returns the time in seconds needed to evaluate the given expression
332 .BI transpose( matrix )
333 \- transpose of a matrix
335 .BI unassign( symbol )
336 \- unassign an assigned symbol
338 .BI unit( expression ", " symbol )
339 \- unit part of a polynomial
341 \" GINSH_FCN_HELP_END
353 ginsh can display a (short) help for a given topic (mostly about functions
354 and operators) by entering
362 will display a list of available help topics.
366 .BI print( expression );
368 will print a dump of GiNaC's internal representation for the given
370 This is useful for debugging and for learning about GiNaC internals.
372 Finally, the shell escape
375 .RI [ "command " [ arguments ]]
381 to the shell for execution. With this method, you can execute shell commands
382 from within ginsh without having to quit.
390 (x+1)^(\-2)*(\-x+x^2\-2)
392 (2*x\-1)*(x+1)^(\-2)\-2*(x+1)^(\-3)*(\-x+x^2\-2)
396 717897987691852588770249
398 717897987691852588770247/717897987691852588770250
402 0.999999999999999999999995821133292704384960990679L0
406 (x+1)^(\-2)*(\-x+x^2\-2)
407 > lsolve([3*x+5*y == 7], [x, y]);
408 [x==\-5/3*y+7/3,y==y]
409 > lsolve([3*x+5*y == 7, \-2*x+10*y == \-5], [x, y]);
411 > M = [[ [[a, b]], [[c, d]] ]];
412 [[ [[\-x+x^2\-2,(x+1)^2]], [[c,d]] ]]
414 \-2*d\-2*x*c\-x^2*c\-x*d+x^2*d\-c
416 (\-d\-2*c)*x+(d\-c)*x^2\-2*d\-c
417 > solve quantum field theory;
418 parse error at quantum
423 .RI "parse error at " foo
424 You entered something which ginsh was unable to parse. Please check the syntax
425 of your input and try again.
427 .RI "argument " num " to " function " must be a " type
432 must be of a certain type (e.g. a symbol, or a list). The first argument has
433 number 0, the second argument number 1, etc.
438 Christian Bauer <Christian.Bauer@uni-mainz.de>
440 Alexander Frink <Alexander.Frink@uni-mainz.de>
442 Richard Kreckel <Richard.Kreckel@uni-mainz.de>
444 GiNaC Tutorial \- An open framework for symbolic computation within the
445 C++ programming language
447 CLN \- A Class Library for Numbers, Bruno Haible
449 Copyright \(co 1999-2000 Johannes Gutenberg Universit\(:at Mainz, Germany
451 This program is free software; you can redistribute it and/or modify
452 it under the terms of the GNU General Public License as published by
453 the Free Software Foundation; either version 2 of the License, or
454 (at your option) any later version.
456 This program is distributed in the hope that it will be useful,
457 but WITHOUT ANY WARRANTY; without even the implied warranty of
458 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
459 GNU General Public License for more details.
461 You should have received a copy of the GNU General Public License
462 along with this program; if not, write to the Free Software
463 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.