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