Ask Your Question
0

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

asked 2013-10-08 02:01:30 +0200

Shashank gravatar image

Let me give an example

Suppose I want to expand $\cos(x)^{4}$ as in a series of functions $C_{k}=(1/2-\cos(kx))$. That is $\cos(4x)=k_0 C_0+k_1 C_1 + k_2 C_2 \cdots$ 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 $C_{k}$.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-10-08 07:38:03 +0200

tmonteil gravatar image

updated 2013-10-08 09:07:52 +0200

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
edit flag offensive delete link more

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: 2013-10-08 02:01:30 +0200

Seen: 328 times

Last updated: Oct 08 '13