From 155c2b0f7a301dbd9d77256ffccd6575a4304523 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Thu, 25 Nov 1999 17:06:57 +0000 Subject: [PATCH] - added one more sample for our friends at NASA. :-) --- doc/tutorial/tutorial.sgml.in | 57 +++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/doc/tutorial/tutorial.sgml.in b/doc/tutorial/tutorial.sgml.in index f9281dfc..aa0cb900 100644 --- a/doc/tutorial/tutorial.sgml.in +++ b/doc/tutorial/tutorial.sgml.in @@ -44,22 +44,19 @@ together with more established areas of computer science (like computation-intense numeric applications, graphical interfaces, etc.) under one roof. -This tutorial is intended for the novice user who is new to GiNaC -but already has some background in C++ programming. However, since a -hand made documentation like this one is difficult to keep in sync -with the development the actual documentation is inside the sources in -the form of comments. That documentation may be parsed by one of the -many Javadoc-like documentation systems. The generated HTML -documenatation is included in the distributed sources (subdir -doc/reference/) or can be accessed directly at URL -http://wwwthep.physik.uni-mainz.de/GiNaC/reference/. +This tutorial is intended for the novice user who is new to +GiNaC but already has some background in C++ programming. However, +since a hand made documentation like this one is difficult to keep in +sync with the development the actual documentation is inside the +sources in the form of comments. That documentation may be parsed by +one of the many Javadoc-like documentation systems. If you fail at +generating it you may access it directly at URL http://www.ginac.de/reference/. It is an invaluable resource not only for the advanced user who wishes to extend the system (or chase bugs) but for everybody who wants to comprehend the inner workings of GiNaC. This little tutorial on the other hand only covers the basic things that are unlikely to change in -the near future. - +the near future. License @@ -242,9 +239,10 @@ allow one to conclude that 42*Pi is equal to 0.) Linear equation systems can be solved along with basic linear -algebra manipulations over symbolic expressions. In C++ there is a -matrix class for this purpose but we can see what it can do using -ginsh's notation of double brackets to type them in: +algebra manipulations over symbolic expressions. In C++ GiNaC offers +a matrix class for this purpose but we can see what it can do using +ginsh's notation of double brackets to type them +in: > lsolve(a+x*y==z,x); y^(-1)*(z-a); @@ -276,10 +274,9 @@ polynomials): - -You can differentiate functions and expand them as Taylor or Laurent -series (the third argument of series is the evaluation point, the -fourth defines the order): +You can differentiate functions and expand them as Taylor or +Laurent series (the third argument of series is the evaluation point, +the fourth defines the order): > diff(tan(x),x); tan(x)^2+1 @@ -290,6 +287,20 @@ x^(-1)-1/3*x+Order(x^2) +If you ever wanted to convert units in C or C++ and found this +is cumbersome, here is the solution. Symbolic types can always be +used as tags for different types of objects. Converting from wrong +units to the metric system is therefore easy: + +> in=.0254*m; +0.0254*m +> lb=.45359237*kg; +0.45359237*kg +> 200*lb/in^2; +140613.91592783185568*kg*m^(-2) + + + @@ -411,7 +422,7 @@ picky and full assertions switched on: $ export CXX=/usr/local/gnu/bin/c++ $ export CPPFLAGS="${CPPFLAGS} -I${HOME}/include" -$ export CXXFLAGS="${CXXFLAGS} -ggdb -Wall -ansi -pedantic -O2 -DDO_GINAC_ASSERT" +$ export CXXFLAGS="${CXXFLAGS} -DDO_GINAC_ASSERT -ggdb -Wall -ansi -pedantic -O2" $ export LDFLAGS="${LDFLAGS} -L${HOME}/lib" $ ./configure --disable-shared --prefix=${HOME} @@ -592,7 +603,7 @@ int main() Here, e1 will actually be referenced three times while e2 will be referenced two times. When the power of an expression is built, that expression needs not be -copied. Likewise, since the derivative of a power of an expression can +copied. Likewise, since the derivative of a power of an expression can be easily expressed in terms of that expression, no copying of e1 is involved when e3 is constructed. So, when e3 is constructed it will @@ -1396,7 +1407,7 @@ calculated using the chain rule and the product rule. Consider, for instance the expression 1/cosh(x). Since the derivative of cosh(x) is sinh(x) and the derivative of pow(x,-1) is --pow(x,-2) GiNaC can readily compute the +-pow(x,-2), GiNaC can readily compute the composition. It turns out that the composition is the generating function for Euler Numbers, i.e. the so called nth Euler number is the coefficient of @@ -1466,7 +1477,7 @@ int main() As an instructive application, let us calculate the numerical value of Archimedes' constant (for which there already exists the built-in constant Pi) using Méchain's -wonderful formula Pi==16*atan(1/5)-4*atan(1/239). +mysterious formula Pi==16*atan(1/5)-4*atan(1/239). We may expand the arcus tangent around 0 and insert the fractions 1/5 and 1/239. But, as we have seen, a series in GiNaC carries an order term with it. -- 2.44.0