]> www.ginac.de Git - ginac.git/blobdiff - doc/tutorial/ginac.texi
[BUGFIX] Fix crash in parser.
[ginac.git] / doc / tutorial / ginac.texi
index 17080bc12fed595d3abd1aa2d46ccdd893e3c01d..52c5828e95a178e8d2de18d3e66d3fb3c7fb2adb 100644 (file)
@@ -24,7 +24,7 @@
 This is a tutorial that documents GiNaC @value{VERSION}, an open
 framework for symbolic computation within the C++ programming language.
 
-Copyright (C) 1999-2020 Johannes Gutenberg University Mainz, Germany
+Copyright (C) 1999-2024 Johannes Gutenberg University Mainz, Germany
 
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
@@ -52,7 +52,7 @@ notice identical to this one.
 
 @page
 @vskip 0pt plus 1filll
-Copyright @copyright{} 1999-2020 Johannes Gutenberg University Mainz, Germany
+Copyright @copyright{} 1999-2024 Johannes Gutenberg University Mainz, Germany
 @sp 2
 Permission is granted to make and distribute verbatim copies of
 this manual provided the copyright notice and this permission notice
@@ -135,7 +135,7 @@ the near future.
 
 @section License
 The GiNaC framework for symbolic computation within the C++ programming
-language is Copyright @copyright{} 1999-2020 Johannes Gutenberg
+language is Copyright @copyright{} 1999-2024 Johannes Gutenberg
 University Mainz, Germany.
 
 This program is free software; you can redistribute it and/or
@@ -1194,7 +1194,7 @@ For storing numerical things, GiNaC uses Bruno Haible's library CLN.
 The classes therein serve as foundation classes for GiNaC.  CLN stands
 for Class Library for Numbers or alternatively for Common Lisp Numbers.
 In order to find out more about CLN's internals, the reader is referred to
-the documentation of that library.  @inforef{Introduction, , cln}, for
+the documentation of that library.  @xref{Top,,, cln, The CLN Manual}, for
 more information. Suffice to say that it is by itself build on top of
 another library, the GNU Multiple Precision library GMP, which is an
 extremely fast library for arbitrary long integers and rationals as well
@@ -1866,13 +1866,31 @@ substitutions.  They are also used as arguments to the @code{ex::series}
 method, where the left hand side of the relation specifies the variable
 to expand in and the right hand side the expansion point.  They can also
 be used for creating systems of equations that are to be solved for
-unknown variables.  But the most common usage of objects of this class
+unknown variables.
+
+But the most common usage of objects of this class
 is rather inconspicuous in statements of the form @code{if
 (expand(pow(a+b,2))==a*a+2*a*b+b*b) @{...@}}.  Here, an implicit
 conversion from @code{relational} to @code{bool} takes place.  Note,
 however, that @code{==} here does not perform any simplifications, hence
 @code{expand()} must be called explicitly.
 
+Simplifications of
+relationals may be more efficient if preceded by a call to
+@example
+ex relational::canonical() const
+@end example
+which returns an equivalent relation with the zero
+right-hand side. For example:
+@example
+possymbol p("p");
+relational rel = (p >= (p*p-1)/p);
+if (ex_to<relational>(rel.canonical().normal()))
+       cout << "correct inequality" << endl;
+@end example
+However, a user shall not expect that any inequality can be fully
+resolved by GiNaC.
+
 @node Integrals, Matrices, Relations, Basic concepts
 @c    node-name, next, previous, up
 @section Integrals
@@ -3224,7 +3242,8 @@ element, which defaults to 4.
 The @code{dirac_trace()} function is a linear functional that is equal to the
 ordinary matrix trace only in @math{D = 4} dimensions. In particular, the
 functional is not cyclic in
-@tex $D \ne 4$
+@tex
+$D \ne 4$
 @end tex
 @ifnottex
 @math{D != 4}
@@ -3235,7 +3254,8 @@ expressions containing @samp{gamma5}, so it's not a proper trace. This
 @cite{The Role of gamma5 in Dimensional Regularization} (@ref{Bibliography}).
 
 The value of the trace itself is also usually different in 4 and in
-@tex $D \ne 4$
+@tex
+$D \ne 4$
 @end tex
 @ifnottex
 @math{D != 4}
@@ -3308,15 +3328,16 @@ You can use this to compare two expressions or for further simplifications:
 @subsubsection A generic Clifford algebra
 
 A generic Clifford algebra, i.e. a
-@tex $2^n$
+@tex
+$2^n$
 @end tex
 @ifnottex
 2^n
 @end ifnottex
-dimensional algebra with
-generators 
-@tex $e_k$
-@end tex 
+dimensional algebra with generators
+@tex
+$e_k$
+@end tex
 @ifnottex
 e_k
 @end ifnottex
@@ -5361,6 +5382,27 @@ some care with subsequent processing of the result:
 Note also, how factors with the same exponents are not fully factorized
 with this method.
 
+@subsection Square-free partial fraction decomposition
+@cindex square-free partial fraction decomposition
+@cindex partial fraction decomposition
+@cindex @code{sqrfree_parfrac()}
+
+GiNaC also supports square-free partial fraction decomposition of
+rational functions:
+@example
+ex sqrfree_parfrac(const ex & a, const symbol & x);
+@end example
+It is called square-free because it assumes a square-free
+factorization of the input's denominator:
+@example
+    ...
+    symbol x("x");
+
+    ex rat = (x-4)/(pow(x,2)*(x+2));
+    cout << sqrfree_parfrac(rat, x) << endl;
+     // -> -2*x^(-2)+3/2*x^(-1)-3/2*(2+x)^(-1)
+@end example
+
 @subsection Polynomial factorization
 @cindex factorization
 @cindex polynomial factorization
@@ -5682,7 +5724,7 @@ using namespace GiNaC;
 ex machin_pi(int degr)
 @{
     symbol x;
-    ex pi_expansion = series_to_poly(atan(x).series(x,degr));
+    ex pi_expansion = series_to_poly(atan(x).series(x==0,degr));
     ex pi_approx = 16*pi_expansion.subs(x==numeric(1,5))
                    -4*pi_expansion.subs(x==numeric(1,239));
     return pi_approx;
@@ -8764,12 +8806,12 @@ program use @footnote{If GiNaC is installed into some non-standard
 directory @var{prefix} one should set the @var{PKG_CONFIG_PATH}
 environment variable to @var{prefix}/lib/pkgconfig for this to work.}
 @example
-g++ -o simple `pkg-config --cflags --libs ginac` simple.cpp
+g++ -o simple simple.cpp `pkg-config --cflags --libs ginac`
 @end example
 
 This command line might expand to (for example):
 @example
-g++ -o simple -lginac -lcln simple.cpp
+g++ -o simple simple.cpp -lginac -lcln
 @end example
 
 Not only is the form using @command{pkg-config} easier to type, it will