]> www.ginac.de Git - ginac.git/blobdiff - doc/tutorial/ginac.texi
- expressions can now be read from streams; the input expression can contain
[ginac.git] / doc / tutorial / ginac.texi
index 89a7b29da32d4df2d78f6bf9654f5c15efc38a02..ae19fbaaaf9915903156a7c507cd4e32ee4a68cc 100644 (file)
@@ -376,24 +376,25 @@ polynomials):
 @end example
 
 You can differentiate functions and expand them as Taylor or Laurent
-series (the third argument of @code{series} is the evaluation point, the
-fourth defines the order):
+series in a very natural syntax (the second argument of @code{series} is
+a relation defining the evaluation point, the third specifies the
+order):
 
 @cindex Zeta function
 @example
 > diff(tan(x),x);
 tan(x)^2+1
-> series(sin(x),x,0,4);
+> series(sin(x),x==0,4);
 x-1/6*x^3+Order(x^4)
-> series(1/tan(x),x,0,4);
+> series(1/tan(x),x==0,4);
 x^(-1)-1/3*x+Order(x^2)
-> series(Gamma(x),x,0,3);
+> series(Gamma(x),x==0,3);
 x^(-1)-gamma+(1/12*Pi^2+1/2*gamma^2)*x+
 (-1/3*zeta(3)-1/12*Pi^2*gamma-1/6*gamma^3)*x^2+Order(x^3)
 > evalf(");
 x^(-1)-0.5772156649015328606+(0.9890559953279725555)*x
 -(0.90747907608088628905)*x^2+Order(x^3)
-> series(Gamma(2*sin(x)-2),x,Pi/2,6);
+> series(Gamma(2*sin(x)-2),x==Pi/2,6);
 -(x-1/2*Pi)^(-2)+(-1/12*Pi^2-1/2*gamma^2-1/240)*(x-1/2*Pi)^2
 -gamma-1/12+Order((x-1/2*Pi)^3)
 @end example
@@ -1192,7 +1193,8 @@ They are created by simply using the C++ operators @code{==}, @code{!=},
 the @code{.subs()} method show how objects of class relational are used
 as arguments.  There they provide an intuitive syntax for substitutions.
 They can also used for creating systems of equations that are to be
-solved for unknown variables.
+solved for unknown variables.  More applications of this class will
+appear throughout the next chapters.
 
 
 @node Archiving, Important Algorithms, Relations, Basic Concepts
@@ -1604,13 +1606,13 @@ int main()
     symbol v("v"), c("c");
     
     ex gamma = 1/sqrt(1 - pow(v/c,2));
-    ex mass_nonrel = gamma.series(v0, 10);
+    ex mass_nonrel = gamma.series(v==0, 10);
     
     cout << "the relativistic mass increase with v is " << endl
          << mass_nonrel << endl;
     
     cout << "the inverse square of this series is " << endl
-         << pow(mass_nonrel,-2).series(v0, 10) << endl;
+         << pow(mass_nonrel,-2).series(v==0, 10) << endl;
     
     // ...
 @}
@@ -1648,7 +1650,7 @@ using namespace GiNaC;
 ex mechain_pi(int degr)
 @{
     symbol x;
-    ex pi_expansion = series_to_poly(atan(x).series(x,0,degr));
+    ex pi_expansion = series_to_poly(atan(x).series(x,degr));
     ex pi_approx = 16*pi_expansion.subs(x==numeric(1,5))
                    -4*pi_expansion.subs(x==numeric(1,239));
     return pi_approx;
@@ -1666,7 +1668,11 @@ int main()
 @}
 @end example
 
-When you run this program, it will type out:
+Note how we just called @code{.series(x,degr)} instead of
+@code{.series(x==0,degr)}.  This is a simple shortcut for @code{ex}'s
+method @code{series()}: if the first argument is a symbol the expression
+is expanded in that symbol around point @code{0}.  When you run this
+program, it will type out:
 
 @example
 2:      3804/1195