[GiNaC-list] Problem simplifying exponents in polynomials
Gerry Boland
gerboland at gmail.com
Tue Jun 5 11:46:37 CEST 2007
Dear Chris,
you've given me exactly what I needed! Many thanks
-Gerry
On 01/06/07, Chris.Dams at mi.infn.it <Chris.Dams at mi.infn.it> wrote:
>
> 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
>
> _______________________________________________
> GiNaC-list mailing list
> GiNaC-list at ginac.de
> https://www.cebix.net/mailman/listinfo/ginac-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.cebix.net/pipermail/ginac-list/attachments/20070605/8e574726/attachment.html
More information about the GiNaC-list
mailing list