]> www.ginac.de Git - ginac.git/blob - cint/ginaccint.1
More features for GiNaC-cint:
[ginac.git] / cint / ginaccint.1
1 .TH ginaccint 1 "January, 2000" "GiNaC"
2 .SH NAME
3 GiNaC-cint \- An interactive interface for GiNaC based on the Cint C/C++ interpreter
4 .SH SYNPOSIS
5 .B ginaccint
6 [file ...]
7 .SH DESCRIPTION
8 .B ginaccint
9 is an interactive frontend for the GiNaC symbolic computation
10 framework.  It is a tool that lets you write interactive programs
11 (scripts) in C++ that directly make use of GiNaC's classes.  Thus it
12 is a more complete replacement for traditional interactive computer
13 algebra systems than \fBginsh\fP(1) is.  Programs may be composed as
14 scripts and later compiled with the native compiler and linked into
15 the system.
16 .SH USAGE
17 .SS INPUT FORMAT
18 After startup, GiNaC-cint reads and executes the files given as 
19 command line arguments. If any of these files contains a
20 .BR .quit
21 command, GiNaC-cint exits at this point.
22 Otherwise it displays a prompt signifying that it is ready to
23 accept your input. All C++ statements are valid as input, extended by
24 GiNaC's numeric or symbolic expressions.  E.g.
25 .BR fibonacci(24)/1104;
26 returns a GiNaC object of class
27 .BR ex,
28 , which in this case represents the numeric 42.  Symbols are declared by 
29 statements as
30 .nf 
31 GiNaC> symbol x("x"), y("y"), z;
32 .fi
33 which defines two named symbols and an anonymous one for later usage.
34 All GiNaC methods and functions are available as they would be coded
35 in C++.  It is not necessary to explicitly invoke a print command as
36 the last expression is automatically printed:
37 .nf
38 GiNaC> pow(x+y,4).expand();
39 Out2 = x^4+4*x^3*y+6*x^2*y^2+4*x*y^3+y^4
40 .fi
41 Statements are generally closed either when a closing brace 
42 .RB ( } )
43 matches the first opening brace
44 .RB ( { ) 
45 or a semicolon
46 .RB ( ; )
47 is encountered.
48
49 .SS SPECIAL COMMANDS
50 .IP "\fB.cint\fR"
51 Switch to cint's interactive mode.
52
53 .IP "\fB.function\fR"
54
55 Allow a function definition in interactive mode.  GiNaC-cint must be
56 put into a special mode in order to define a function. After that any
57 function definition in valid C++ syntax may be typed in.  It becomes
58 immediatly available for usage.
59
60 .IP "\fB.help\fB"
61
62 List a short summary of available commands.
63
64 .IP "\fB.quit\fR"
65 Exit from GiNaC-cint.  Same as 
66 .BR ".bye" ,
67 .BR ".exit" ,
68 .BR ".q" ,
69 .BR "bye;" ,
70 .BR "exit; " or
71 .BR "quit;" .
72
73 .IP "\fB.read filename\fB"
74
75 Read a file from disk and execute it in GiNaC-cint
76 (recursive call is possible).
77
78 .IP "\fB.redirect [filename]\fB"
79
80 Redirect
81 .BR "\fBOut\fP\fInum\fP" 
82 output to a file (
83 .BR .redirect
84 alone redirects output to console).
85
86 .IP "\fB.restart\fB"
87
88 Restart GiNaC-cint (does not re-read command line files).       
89
90 .IP "\fB.save filename\fB"
91
92 Save the commands you have entered so far in a file.
93
94 .IP "\fB.silent\fB"
95
96 suppress
97 .BR "\fBOut\fP\fInum\fP" 
98 output (variables are still accessible).
99
100 .IP "\fB.> [filename]\fB"
101
102 same as
103 .BR "\fB.redirect [filename]\fB"
104 .
105
106 .IP "\fBOut\fP\fInum\fP"
107 Returns the expression whose output was marked
108 .BR "\fBOut\fP\fInum\fP" 
109 as a handle.
110
111 .IP "\fBLAST\fP, \fBLLAST, \fP\fBLLLAST\fP"
112 Return the last, second last and third last expression, 
113 respectively.
114
115 .SH EXAMPLES
116 .nf
117 GiNaC> symbol x("x"), y("y"), z("z");
118 GiNaC> ex a = pow(x,2)-x-2;
119 GiNaC> ex b = pow(x+1,2);
120 GiNaC> ex s = a/b;
121 GiNaC> s.diff(x);
122 Out1 = -2*(1+x)^(-3)*(-2-x+x^2)+(-1+2*x)*(1+x)^(-2)
123 GiNaC> s.normal();
124 Out2 = (-2+x)*(1+x)^(-1)
125 GiNaC> for (int i=2; i<20; i+=2) {
126      >     cout << "B(" << i << ")==" << bernoulli(i) << endl;
127      > }
128 B(2)==1/6
129 B(4)==-1/30
130 B(6)==1/42
131 B(8)==-1/30
132 B(10)==5/66
133 B(12)==-691/2730
134 B(14)==7/6
135 B(16)==-3617/510
136 B(18)==43867/798
137 GiNaC> .function
138 next expression can be a function definition
139 GiNaC> ex EulerNumber(unsigned n)
140      > {
141      >     symbol xi;
142      >     const ex generator = pow(cosh(xi),-1);
143      >     return generator.diff(xi,n).subs(xi==0);
144      > }
145 creating file /tmp/ginac26197caa
146 GiNaC> EulerNumber(42);
147 Out3 = -10364622733519612119397957304745185976310201
148 GiNaC> ex f = expand((x*y*z-1)*(x*y*z+3));
149 GiNaC> ex g = expand((x*y*z-1)*(x*y*z-3));
150 GiNaC> cout << "The GCD of " << f << " and " << g << endl
151      >      << " is " << gcd(f, g) << endl
152      >      << " so " << f/g << endl
153      >      << " is " << normal(f/g) << endl;
154 The GCD of -3+2*x*z*y+x^2*z^2*y^2 and 3-4*x*z*y+x^2*z^2*y^2
155  is -1+x*z*y
156  so (-3+2*x*z*y+x^2*z^2*y^2)*(3-4*x*z*y+x^2*z^2*y^2)^(-1)
157  is (-3+x*z*y)^(-1)*(3+x*z*y)
158 GiNaC> .quit
159 .fi
160
161 .SH BUGS
162 Cint accepts most of K&R and ANSI C/C++ language construct but not
163 perfect.  In fact, Cint is not aimed to be a 100% ANSI/ISO compliant
164 C/C++ language processor.  It rather is a portable script language
165 environment which is close enough to the standard C++.  See the file 
166 .BR limitati.txt
167 in your Cint distribution.  Please take the time to track down any bug
168 you encounter as far as possible and contact Masaharu Goto
169 <MXJ02154@niftyserve.or.jp> for Cint-related bugs and
170 <ginac-bugs@ginac.de> for any bugs in the GiNaC engine.
171
172 Only expressions (class
173 .BR ex )
174 are typed out and available through 
175 .BR "\fBOut\fP\fInum\fP" 
176 and 
177 .BR LAST
178 after declaring them.  This accounts for some funny behaviour, like
179 .BR fibonacci(7)
180 doesn't print, but
181 .BR fibonacci(7)*1
182 does, since this is not a naked number but an expression holding
183 that number. A warning message is printed in this case only for
184 the first occurence.
185
186 .SH AUTHOR
187 .TP
188 The GiNaC Group
189 .br
190 Christian Bauer <Christian.Bauer@uni-mainz.de>
191 .br
192 Alexander Frink <Alexander.Frink@uni-mainz.de>
193 .br
194 Richard Kreckel <Richard.Kreckel@uni-mainz.de>
195 .TP
196 Agilent Technologies Japan
197 .br
198 Masaharu Goto <MXJ02154@niftyserve.or.jp>
199 .SH SEE ALSO
200 GiNaC Tutorial \- An open framework for symbolic computation within the
201 C++ programming language
202 .PP
203 CLN \- A Class Library for Numbers, Bruno Haible
204 .PP
205 \fBginsh\fP(1)
206 .SH COPYRIGHT
207 .SS GINAC COPYRIGHT
208 Copyright \(co 1999-2000 Johannes Gutenberg Universit\(:at Mainz, Germany
209
210 This program is free software; you can redistribute it and/or modify
211 it under the terms of the GNU General Public License as published by
212 the Free Software Foundation; either version 2 of the License, or
213 (at your option) any later version.
214
215 This program is distributed in the hope that it will be useful,
216 but WITHOUT ANY WARRANTY; without even the implied warranty of
217 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
218 GNU General Public License for more details.
219
220 You should have received a copy of the GNU General Public License
221 along with this program; if not, write to the Free Software
222 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
223 .SS CINT COPYRIGHT
224 Copyright \(co of Cint and associated tools are owned by Agilent
225 Technologies Japan Company and the author.  Acknowledgement to the
226 author by e-mail is recommended at installation.  Source code, binary
227 executable or library of Cint and associated tools can be used,
228 modified and distributed free of charge for any purpose provided that
229 the copyright notice appear in all copies and that both that copyright
230 notice and this permission notice appear in documentation.
231 Registration is requested, at this moment, for commercial use.  Send
232 e-mail to the author <MXJ02154@niftyserve.or.jp>.  The registration is
233 free.