X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=doc%2Ftutorial%2Fginac.texi;h=5183e465fb8a993e6b1ebe26437011e964332c3b;hp=e43b4bb32c20ffaa79526927e225316ef6149596;hb=01bbb5bbad3545dd3fdcb21158ca4e715625f01f;hpb=b40bb4ef533e40d4cd619b74fc2916a5255fd633 diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index e43b4bb3..5183e465 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -684,8 +684,8 @@ ex MyEx4 = sin(x + 2*y) + 3*z + 41; // containing a function ex MyEx5 = MyEx4 + 1; // similar to above @end example -Expressions are handles to other more fundamental objects, that many -times contain other expressions thus creating a tree of expressions +Expressions are handles to other more fundamental objects, that often +contain other expressions thus creating a tree of expressions (@xref{Internal Structures}, for particular examples). Most methods on @code{ex} therefore run top-down through such an expression tree. For example, the method @code{has()} scans recursively for occurrences of @@ -707,36 +707,26 @@ mathematical objects, all of which (except for @code{ex} and some helpers) are internally derived from one abstract base class called @code{basic}. You do not have to deal with objects of class @code{basic}, instead you'll be dealing with symbols, numbers, -containers of expressions and so on. You'll soon learn in this chapter -how many of the functions on symbols are really classes. This is -because simple symbolic arithmetic is not supported by languages like -C++ so in a certain way GiNaC has to implement its own arithmetic. +containers of expressions and so on. @cindex container @cindex atom To get an idea about what kinds of symbolic composits may be built we -have a look at the most important classes in the class hierarchy. The -oval classes are atomic ones and the squared classes are containers. -The dashed line symbolizes a `points to' or `handles' relationship while -the solid lines stand for `inherits from' relationship in the class -hierarchy: +have a look at the most important classes in the class hierarchy and +some of the relations among the classes: @image{classhierarchy} -Some of the classes shown here (the ones sitting in white boxes) are -abstract base classes that are of no interest at all for the user. They -are used internally in order to avoid code duplication if two or more -classes derived from them share certain features. An example would be -@code{expairseq}, which is a container for a sequence of pairs each -consisting of one expression and a number (@code{numeric}). What -@emph{is} visible to the user are the derived classes @code{add} and -@code{mul}, representing sums of terms and products, respectively. -@xref{Internal Structures}, where these two classes are described in -more detail. - -At this point, we only summarize what kind of mathematical objects are -stored in the different classes in above diagram in order to give you a -overview: +The abstract classes shown here (the ones without drop-shadow) are of no +interest for the user. They are used internally in order to avoid code +duplication if two or more classes derived from them share certain +features. An example is @code{expairseq}, a container for a sequence of +pairs each consisting of one expression and a number (@code{numeric}). +What @emph{is} visible to the user are the derived classes @code{add} +and @code{mul}, representing sums and products. @xref{Internal +Structures}, where these two classes are described in more detail. The +following table shortly summarizes what kinds of mathematical objects +are stored in the different classes: @cartouche @multitable @columnfractions .22 .78 @@ -749,8 +739,8 @@ $\pi$ @math{Pi} @end ifnottex @item @code{numeric} @tab All kinds of numbers, @math{42}, @math{7/3*I}, @math{3.14159}@dots{} -@item @code{add} @tab Sums like @math{x+y} or @math{a+(2*b)+3} -@item @code{mul} @tab Products like @math{x*y} or @math{a*(x+y+z)*b*2} +@item @code{add} @tab Sums like @math{x+y} or @math{a-(2*b)+3} +@item @code{mul} @tab Products like @math{x*y} or @math{2*a^2*(x+y+z)/b} @item @code{power} @tab Exponentials such as @math{x^2}, @math{a^b}, @tex $\sqrt{2}$ @@ -759,15 +749,14 @@ $\sqrt{2}$ @code{sqrt(}@math{2}@code{)} @end ifnottex @dots{} -@item @code{pseries} @tab Power Series, e.g. @math{x+1/6*x^3+1/120*x^5+O(x^7)} +@item @code{pseries} @tab Power Series, e.g. @math{x-1/6*x^3+1/120*x^5+O(x^7)} @item @code{function} @tab A symbolic function like @math{sin(2*x)} @item @code{lst} @tab Lists of expressions [@math{x}, @math{2*y}, @math{3+z}] @item @code{matrix} @tab @math{n}x@math{m} matrices of expressions @item @code{relational} @tab A relation like the identity @math{x}@code{==}@math{y} -@item @code{color} @tab Element of the @math{SU(3)} Lie-algebra +@item @code{color}, @code{coloridx} @tab Element and index of the @math{SU(3)} Lie-algebra @item @code{isospin} @tab Element of the @math{SU(2)} Lie-algebra -@item @code{idx} @tab Index of a tensor object -@item @code{coloridx} @tab Index of a @math{SU(3)} tensor +@item @code{idx} @tab Index of a general tensor object @end multitable @end cartouche @@ -1408,7 +1397,9 @@ table: @item @code{crational_polynomial} @tab @dots{}a polynomial with (possibly complex) rational coefficients (such as @math{2/3+7/2*I}) @item @code{rational_function} -@tab @dots{}a rational function +@tab @dots{}a rational function (@math{x+y}, @math{z/(x+y)}) +@item @code{algebraic} +@tab @dots{}an algebraic object (@math{sqrt(2)}, @math{sqrt(x)-1}) @end multitable @end cartouche @@ -1480,7 +1471,7 @@ bool ex::is_zero(); for checking whether one expression is equal to another, or equal to zero, respectively. -@strong{Warning:} You will also find a @code{ex::compare()} method in the +@strong{Warning:} You will also find an @code{ex::compare()} method in the GiNaC header files. This method is however only to be used internally by GiNaC to establish a canonical sort order for terms, and using it to compare expressions will give very surprising results. @@ -2050,6 +2041,8 @@ GiNaC contains the following predefined mathematical functions: @tab exponential function @item @code{log(x)} @tab natural logarithm +@item @code{Li2(x)} +@tab Dilogarithm @item @code{zeta(x)} @tab Riemann's zeta function @item @code{zeta(n, x)} @@ -2077,10 +2070,17 @@ GiNaC contains the following predefined mathematical functions: @cindex branch cut For functions that have a branch cut in the complex plane GiNaC follows -the conventions for C++ as defined in the ANSI standard. In particular: -the natural logarithm (@code{log}) and the square root (@code{sqrt}) -both have their branch cuts running along the negative real axis where -the points on the axis itself belong to the upper part. +the conventions for C++ as defined in the ANSI standard as far as +possible. In particular: the natural logarithm (@code{log}) and the +square root (@code{sqrt}) both have their branch cuts running along the +negative real axis where the points on the axis itself belong to the +upper part (i.e. continuous with quadrant II). The inverse +trigonometric and hyperbolic functions are not defined for complex +arguments by the C++ standard, however. Here, we follow the conventions +used by CLN, which in turn follow the carefully designed definitions +in the Common Lisp standard. Hopefully, future revisions of the C++ +standard incorporate these functions in the complex domain in a manner +compatible with Common Lisp. @node Input/Output, Extending GiNaC, Built-in Functions, Methods and Functions @@ -2350,11 +2350,13 @@ provided by @acronym{CLN} are much better suited. @section Symbolic functions The easiest and most instructive way to start with is probably to -implement your own function. Objects of class @code{function} are -inserted into the system via a kind of `registry'. They get a serial -number that is used internally to identify them but you usually need not -worry about this. What you have to care for are functions that are -called when the user invokes certain methods. These are usual +implement your own function. GiNaC's functions are objects of class +@code{function}. The preprocessor is then used to convert the function +names to objects with a corresponding serial number that is used +internally to identify them. You usually need not worry about this +number. New functions may be inserted into the system via a kind of +`registry'. It is your responsibility to care for some functions that +are called when the user invokes certain methods. These are usual C++-functions accepting a number of @code{ex} as arguments and returning one @code{ex}. As an example, if we have a look at a simplified implementation of the cosine trigonometric function, we first need a @@ -2409,7 +2411,7 @@ enough to know how to differentiate. But if the function you want to implement does have a pole somewhere in the complex plane, you need to write another method for Laurent expansion around that point. -Now that all the ingrediences for @code{cos} have been set up, we need +Now that all the ingredients for @code{cos} have been set up, we need to tell the system about it. This is done by a macro and we are not going to descibe how it expands, please consult your preprocessor if you are curious: @@ -2970,9 +2972,9 @@ AC_PROG_CXX AC_PROG_INSTALL AC_LANG_CPLUSPLUS -AM_PATH_GINAC(0.4.0, [ +AM_PATH_GINAC(0.6.0, [ LIBS="$LIBS $GINACLIB_LIBS" - CPPFLAGS="$CFLAGS $GINACLIB_CPPFLAGS" + CPPFLAGS="$CPPFLAGS $GINACLIB_CPPFLAGS" ], AC_MSG_ERROR([need to have GiNaC installed])) AC_OUTPUT(Makefile)