[GiNaC-list] Problem simplifying exponents in polynomials
Chris.Dams at mi.infn.it
Chris.Dams at mi.infn.it
Fri Jun 1 22:12:03 CEST 2007
Dear Gerry,
> I've not managed to make the expand() & collect() functions do this, it
> seems to not want to perform something like:
>
> e^t*e^(1-t)=e^1
Yes, this is not included in the automatic simplifications, so you will
have to do it yourself. In cases like this I usually use a function that I
call simplify and that is defined as
ex simplify(const ex&x,const exmap &m)
{ if (is_a<mul>(x))
{ ex y=x;
ex xprev;
do
{ xprev = y;
y = y.subs(m, subs_options::subs_algebraic).expand();
} while(xprev != y);
return y;
}
if (is_a<add>(x))
{ exvector ev;
for(size_t i=0;i<x.nops();++i)
ev.push_back(simplify(x.op(i), m));
return add(ev);
}
return x;
}
This can be used by doing
exmap m;
m[power(e,wild(0))*power(e,wild(1))] = power(e, wild(0)+wild(1));
f = simplify(f, m)
Good luck,
Chris
More information about the GiNaC-list
mailing list