Differentiating and substituting series
Alexander Heide
heide at ra.physik.uni-halle.de
Wed Aug 7 18:57:08 CEST 2002
Hello,
I've tried to replicate calculations involving series expansions that I
did with Mathematica. Here are some comments:
The following program
#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
int main()
{
symbol x("x"), a("a");
cout << (1 + a*x + Order(pow(x, 2))).series(x == 0, 2).diff(a) << endl;
cout << (1 + Order(x) + Order(pow(x,2))).series(x == 0, 2) << endl;
ex series1 = (a + Order(pow(x,2))).series(x == 0, 2);
ex series2 = (1 + Order(x)).series(x == 0, 1);
cout << series1.subs(a == series2) << endl;
return 0;
}
prints out:
1+(a)*x+Order(x^2)
1+Order(x)
(1+Order(x))+Order(x^2)
I would like to obtain 'x+Order(x^2)' in the first line. That is what
Mathematica does when differentiating a series with respect to some
parameter.
The second line is exactly what I expect but the third line should be the
same as the second. Mathematica behaves in the same way as GiNaC so that I
had to write an extra function 'SeriesUnnest' that would expand the third
expression into the second. Unfortunatly I don't have time and skills to
make an suggestion how to hande this situation in GiNaC...
Greetings,
Alexander Heide
More information about the GiNaC-list
mailing list