1 | initial version |
You 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
2 | No.2 Revision |
You To get the coefficients in cos(k*x)
, you can:
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 is not able to understand that 3/8 is the oefficients 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
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.
3 | No.3 Revision |
To get the coefficients in of cos(x)^4
in terms of the family cos(k*x)
, you can: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 oefficients 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
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.
4 | No.4 Revision |
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
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. 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.
(1/2 - cos(k*x))
in terms of the family (cos(k*x))
and take its inverse. 5 | No.5 Revision |
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
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 write build the matrix that express the family (1/2 - cos(k*x))
in terms of the family (cos(k*x))
and take apply its inverse.
6 | No.6 Revision |
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 that express the family (1/2 - cos(k*x))
in terms of the family (cos(k*x))
and apply its inverse to F (viewed as a vector).
7 | No.7 Revision |
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 that express the family (1/2 - cos(k*x))
in terms of the family (cos(k*x))
and apply its the inverse to F of this matrix to C (viewed as a vector).
8 | No.8 Revision |
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).
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