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