Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

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.

share|improve this answer
    
Oops apparently we took almost the same approach! :P –  Leo Fang Oct 10 '13 at 1:10
    
@Artes Great! Rule Replace, I got that –  matheorem Oct 10 '13 at 1:16
    
@Artes Great! But it seems that ` Times[a_, Power[E, Times[Complex[0, b_], x]]] :> a z^b ` is rebundant, right? –  matheorem Oct 10 '13 at 1:22
    
@matheorem yes, that was redundant, just improved. –  Artes Oct 10 '13 at 1:26
1  
@LeoFang You had to map Power[E, Times[Complex[0, #], x]] -> y^# & because you had used Rule (->) instead of RuleDelayed (:>) –  Artes Oct 10 '13 at 1:34
show 1 more comment

This only works for the special case given in your post:

input =  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[input/. (Power[E, Times[Complex[0, #], x]] -> y^# & /@ 
 Range[1, 10])] /. y -> Exp[I x]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.