Skip to main content

simplifying expressions - HornerForm of polynomials in terms of E^(i x)


I want to know how to get the HornerForm of the following expression in terms of E^(I x):


 E^(I x) + 2 E^(2 I x) + 3 E^(3 I x) + 4 E^(4 I x) + 5 E^(5 I x) + 
6 E^(6 I x) + 7 E^(7 I x) + 8 E^(8 I x) + 9 E^(9 I x) + 10 E^(10 I x)

HornerForm[ expr, E^(I x)] doesn't work as well as something like Collect[ expr, E^(I x]].

How can I get the desired form?



Answer



The most straightforward way appears to be using carefully simple replacement rules involving RuleDelayed rather than Rule:


HornerForm[ E^(I x) + 2 E^(2 I x) + 3 E^(3 I x) + 4 E^(4 I x) + 5 E^(5 I x) 
+ 6 E^(6 I x) + 7 E^(7 I x) + 8 E^(8 I x) + 9 E^(9 I x) + 10 E^(10 I x) /.
E^(Complex[0, b_] x) :> z^b, z] /. z :> E^(I x)

enter image description here


% // TraditionalForm


enter image description here


We should remember one subtlety using patterns in replacement rules involving complex (imaginary) factors, which we can illustrate with e.g.:


FullForm @ Unevaluated[ 5 I x]
FullForm[ 5 I x]


 Unevaluated[ Times[5, I, x]]
Times[ Complex[0, 5], x]

namely: built-in rewriting rules of the system automatically evaluate Times[ 5, I] to Complex[0, 5] being an atom:



AtomQ[ Complex[0, 5]]


True

therefore we couldn't make our rule simpler and had used E^(Complex[0, b_] x) :> z^b instead of something like apparently simpler E^(I b_ x) :> z^b.


Comments