# Factoring expression involving exponentials

I've got a complicated expression, which looks like: e(4ik+3iω+ip)−e(4ik+2iω+2ip)−e(4ik+2iω)+e(4ik+iω+ip)+2e(2ik+4iω+ip)−e(2ik+3iω+2ip)−e(2ik+3iω) + ...

How would you do to factor the exponentials with the same power of k, i.e. e(4ik)(...) + e(2ik)(...) and so on?

edit retag close merge delete

Sort by » oldest newest most voted

Using both ideas we can formulate a complete answer (assume that expr(k) is the expression in terms of phases in powers of k that we want to factor):

f1(k) = expr(-I*log(k)); f1
g1(k).coefficient(k,4)

more

Maybe by a change of variables:

sage: var('k,w,p')

sage: expr(k,w,p)=exp(4ik+3iw+ip)-exp(4ik+2iw+2ip)-exp(4ik+2iw)+exp(4ik+iw+ip)+2exp(2ik+4iw+ip)-
exp(2
ik+3iw+2ip)-exp(2ik+3i*w)

sage: f(k,w,p)=expr(log(k),log(w),log(p))

sage: g(exp(k),exp(w),exp(p)).factor()

more

This answer was useful, thanks. But at the end factor doesn't work as expected (it just leds to the original expression). We can use instead use the coefficient function to conclude. I would probably try using the factor method.

sage: var('x,y,z')
(x, y, z)
sage: expr=exp(4*x-2*y+4*z)+exp(4*x-3*y+5*z)
sage: expr.factor()
(e^y + e^z)*e^(4*x - 3*y + 4*z)


Perhaps the manual will contain useful info on that as well.

more

Thanks, but you can see this doesn't do the job: the goal was to collect the terms in exp(4x), and so on (try adding for instance exp(2x-3y+5z) and factoring, it does something correct but is not what I need). I thought it'd be useful a previous step transforming the exp(2x) into z and exp(4x) into z^2, etc and then factoring, but I am not able to get the substitution done..