1 .TH ginsh 1 "October, 1999" "GiNaC"
3 ginsh \- GiNaC Interactive Shell
8 is an interactive frontend for the GiNaC symbolic computation framework.
9 It is intended as a tool for testing and experimenting with GiNaC's
10 features, not as a replacement for traditional interactive computer
11 algebra systems. Although it can do many things these traditional systems
12 can do, ginsh provides no programming constructs like loops or conditional
13 expressions. If you need this functionality you are advised to write
14 your program in C++, using the "native" GiNaC class framework.
17 After startup, ginsh displays a prompt ("> ") signifying that it is ready
18 to accept your input. Acceptable input are numeric or symbolic expressions
19 consisting of numbers (e.g.
20 .BR 42 ", " 2/3 " or " 0.17 ),
22 .BR x " or " result ),
23 mathematical operators like
26 .BR sin " or " normal ).
27 ginsh will evaluate the expression and print the result to stdout. Every
28 input expression must be terminated by a semicolon
30 and it is possible to enter multiple expressions on one line. Whitespace
31 (spaces, tabs, newlines) can be applied freely between tokens. To quit ginsh,
33 .BR quit " or " exit ,
34 or type an EOF (Ctrl-D) at the prompt.
36 ginsh accepts numbers in all formats accepted by CLN (the Class Library for
37 Numbers, that is the foundation of GiNaC's numerics). This includes arbitrary
38 precision integers and rationals as well as floating point numbers in standard
39 or scientific notation (e.g.
41 The general rule is that if a number contains a decimal point
43 it is an (inexact) floating point number; otherwise it is an (exact) integer or
46 Symbols are made up of a string of alphanumeric characters and the underscore
48 with the first character being non-numeric. E.g.
50 are acceptable symbol names, while
52 is not. It is possible to use symbols with the same names as functions (e.g.
54 ginsh is able to distinguish between the two.
56 Symbols can be assigned values by entering
58 .IB symbol " = " expression ;
61 To unassign the value of an assigned symbol, type
63 .BI unassign(' symbol ');
66 Assigned symbols are automatically evaluated (= replaced by their assigned value)
67 when they are used. To refer to the unevaluated symbol, put single quotes
69 around the name, as demonstrated for the "unassign" command above.
71 The following symbols are pre-defined constants that cannot be assigned
82 Euler-Mascheroni Constant
88 an object of the GiNaC "fail" class
91 There is also the special
95 symbol that controls the numeric precision of calculations with inexact numbers.
96 Assigning an integer value to digits will change the precision to the given
97 number of decimal places.
98 .SS LAST PRINTED EXPRESSIONS
99 ginsh provides the three special symbols
103 that refer to the last, second last, and third last printed expression, respectively.
104 These are handy if you want to use the results of previous computations in a new
107 ginsh provides the following operators, listed in falling order of precedence:
126 non-commutative multiplication
159 All binary operators are left-associative, with the exception of
161 which are right-associative. The result of the assignment operator
163 is its right-hand side, so it's possible to assign multiple symbols in one
165 .BR "a = b = c = 2;" ).
167 Lists are used by the
171 functions. A list consists of an opening square bracket
173 a (possibly empty) comma-separated sequence of expressions, and a closing square
177 A matrix consists of an opening double square bracket
179 a non-empty comma-separated sequence of matrix rows, and a closing double square
182 Each matrix row consists of an opening double square bracket
184 a non-empty comma-separated sequence of expressions, and a closing double square
187 If the rows of a matrix are not of the same length, the width of the matrix
188 becomes that of the longest row and shorter rows are filled up at the end
189 with elements of value zero.
191 A function call in ginsh has the form
193 .IB name ( arguments )
197 is a comma-separated sequence of expressions. ginsh provides a couple of built-in
198 functions and also "imports" all symbolic functions defined by GiNaC and additional
199 libraries. There is no way to define your own functions other than linking ginsh
200 against a library that defines symbolic GiNaC functions.
202 ginsh provides Tab-completion on function names: if you type the first part of
203 a function name, hitting Tab will complete the name if possible. If the part you
204 typed is not unique, hitting Tab again will display a list of matching functions.
205 Hitting Tab twice at the prompt will display the list of all available functions.
207 A list of the built-in functions follows. They nearly all work as the
208 respective GiNaC methods of the same name, so I will not describe them in
209 detail here. Please refer to the GiNaC documentation.
212 .BI beta( expression ", " expression )
214 .BI charpoly( matrix ", " symbol )
216 .BI coeff( expression ", " symbol ", " number )
218 .BI collect( expression ", " symbol )
220 .BI content( expression ", " symbol )
222 .BI degree( expression ", " symbol )
224 .BI denom( expression )
226 .BI determinant( matrix )
228 .BI diag( expression... )
230 .BI diff( expression ", " "symbol [" ", " number] )
232 .BI divide( expression ", " expression )
234 .BI eval( "expression [" ", " number] )
236 .BI evalf( "expression [" ", " number] )
238 .BI expand( expression )
240 .BI gcd( expression ", " expression )
242 .BI has( expression ", " expression )
244 .BI inverse( matrix )
247 \- returns "1" if the
249 is true, "0" otherwise (false or undecided)
251 .BI lcm( expression ", " expression )
253 .BI lcoeff( expression ", " symbol )
255 .BI ldegree( expression ", " symbol )
257 .BI lsolve( list ", " list )
259 .BI nops( expression )
261 .BI normal( "expression [" ", " number] )
263 .BI numer( expression )
265 .BI op( expression ", " number )
267 .BI power( expression ", " expression )
269 .BI prem( expression ", " expression ", " symbol )
271 .BI primpart( expression ", " symbol )
273 .BI quo( expression ", " expression ", " symbol )
275 .BI rem( expression ", " expression ", " symbol )
277 .BI series( expression ", " "symbol [" ", " "number [" ", " number]] )
279 .BI sqrfree( expression ", " symbol )
281 .BI sqrt( expression )
283 .BI subs( expression ", " relation-or-list )
285 .BI subs( expression ", " list ", " list )
287 .BI tcoeff( expression ", " symbol )
289 .BI time( expression )
290 \- returns the time in seconds needed to evaluate the given
295 .BI transpose( matrix )
297 .BI unassign( symbol )
299 .BI unit( expression ", " symbol )
313 .BI print( expression );
315 will print a dump of GiNaC's internal representation for the given
317 This is useful for debugging and for learning about GiNaC internals.
319 Finally, the shell escape
322 .RI [ "command " [ arguments ]]
328 to the shell for execution. With this method, you can execute shell commands
329 from within ginsh without having to quit.
337 (x+1)^(\-2)*(\-x+x^2\-2)
339 (2*x\-1)*(x+1)^(\-2)\-2*(x+1)^(\-3)*(\-x+x^2\-2)
343 717897987691852588770249
345 717897987691852588770247/717897987691852588770250
349 0.999999999999999999999995821133292704384960990679L0
353 (x+1)^(\-2)*(\-x+x^2\-2)
354 > lsolve([3*x+5*y == 7], [x, y]);
355 [x==\-5/3*y+7/3,y==y]
356 > lsolve([3*x+5*y == 7, \-2*x+10*y == \-5], [x, y]);
358 > M = [[ [[a, b]], [[c, d]] ]];
359 [[ [[\-x+x^2\-2,(x+1)^2]], [[c,d]] ]]
361 \-2*d\-2*x*c\-x^2*c\-x*d+x^2*d\-c
363 (\-d\-2*c)*x+(d\-c)*x^2\-2*d\-c
368 .RI "parse error at " foo
369 You entered something which ginsh was unable to parse. Please check the syntax
370 of your input and try again.
372 .RI "argument " num " to " function " must be a " type
377 must be of a certain type (e.g. a symbol, or a list). The first argument has
378 number 0, the second argument number 1, etc.
383 Christian Bauer <Christian.Bauer@uni-mainz.de>
385 Alexander Frink <Alexander.Frink@uni-mainz.de>
387 Richard B. Kreckel <Richard.Kreckel@uni-mainz.de>
389 GiNaC Tutorial \- An open framework for symbolic computation within the
390 C++ programming language
392 CLN \- A Class Library for Numbers, Bruno Haible
394 Copyright \(co 1999 Johannes Gutenberg Universit\(:at Mainz, Germany
396 This program is free software; you can redistribute it and/or modify
397 it under the terms of the GNU General Public License as published by
398 the Free Software Foundation; either version 2 of the License, or
399 (at your option) any later version.
401 This program is distributed in the hope that it will be useful,
402 but WITHOUT ANY WARRANTY; without even the implied warranty of
403 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
404 GNU General Public License for more details.
406 You should have received a copy of the GNU General Public License
407 along with this program; if not, write to the Free Software
408 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.