Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
0

Can I express a function as a series of another set of functions

asked 11 years ago

Shashank gravatar image

Let me give an example

Suppose I want to expand cos(x)4 as in a series of functions Ck=(1/2cos(kx)). That is cos(4x)=k0C0+k1C1+k2C2 and I am looking for coefficients k

Now, I can use trig_reduce() to express cos(x)4 as a sum cos(kx), but how do I get get cos(x)4 in terms of Ck.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 11 years ago

tmonteil gravatar image

updated 11 years ago

To get the coefficients of cos(x)^4 in terms of the family cos(k*x), you can try:

sage: f = cos(x)^4
sage: g = f.trig_reduce() ; g
1/2*cos(2*x) + 1/8*cos(4*x) + 3/8
sage: C = [g.coefficient(cos(k*x)) for k in range(5)] ; C
[0, 0, 1/2, 0, 1/8]

But as you can see, Maxima gives a wrong answer since it is not able to understand that 3/8 is the coefficients in cos(0*x), so you have to recover it:

sage: h = sum([C[k]*cos(k*x) for k in range(len(C))]) ; h
1/2*cos(2*x) + 1/8*cos(4*x)
sage: C[0] = g-h ; C
[3/8, 0, 1/2, 0, 1/8]

On the way back, can build the sum and then simplify the sum as follows:

sage: C = [3/8, 0, 1/2, 0, 1/8]
sage: sum([C[k]*cos(k*x) for k in range(len(C))]).trig_simplify()
cos(x)^4

So we can go back and forth from cos(x)^4 to its coefficients in the family (cos(k*x)) automatically.

If you want to do the same for the family (1/2 - cos(k*x)), this is just linear algebra, going from one basis to another. For this, you just have to build the matrix M that express the family (1/2 - cos(k*x)) in terms of the family (cos(k*x)) (you should be careful of the Maxima error as well so that the coefficient 1/2 will not disapear) and apply the inverse of this matrix to C (viewed as a vector), and you get:

sage: D
(-11/8, 0, -1/2, 0, -1/8)
sage: sum([D[k]*(1/2-cos(k*x)) for k in range(len(D))]).trig_simplify()
cos(x)^4
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 11 years ago

Seen: 412 times

Last updated: Oct 08 '13