How to obtain the co-efficient of a trigonometric equations?

I have a polynomial equation like consider f(x) = x^6+5x^4+x^2, and x is 2cos(A/2). After substituting in the equation, the equation is solved in terms of a0+a1*cos(A)+a2*cos(2A)+a2*cos(3A)..... I need the values for a0,a1,a2..... Do we have any instruction to obtain co-efficient in this case? Please let me know
Thank you

Answers (2)

This can be done using indets() and some complicated type expressions. (Maple does a better job with type expressions, in my opinion.)
Easier is probably
newf = subs(f, {cos(A),cos(2*A),cos(3*A)}, {cosA, cos2A, cos3A});
Then you can use
coeff(newf, cos3A)
to find the coefficient corresponding to cos(3*A) (for example.) Just a simple change of variables.
How to define the polynomial equation that i asked in previous question?

5 Comments

syms x A
f = x^6 + 5*x^4 + x^2;
fnew = simplify(subs(f, x, 2*cos(A/2)));
fnew2 = subs(fnew, {cos(A),cos(2*A),cos(3*A)}, {cosA, cos2A, cos3A});
Note: simplify() might not be enough to force the trig substitution in MuPad. In Maple, one would use combine(EXPRESSION,'trig') to do that substitution, but I have not yet found the MuPad equivalent of `combine/trig`
after running the code you gave me, there was error as
"??? Undefined function or variable 'cosA'."
so thought that they should be used as cos(A),cos(2*A)....
but when I did that and obtained the coefficients using 'coeffs' the answer in terms of cos(A). Please let me what to do
Thank you for your response again...
Hi Walter,
This is the code i have written
syms x A
syms cosA cos2A cos3A
f = 32*(x^6)-48*(x^4)+18*(x^2)-1;
fnew = simplify(subs(f, x, 1.25*cos(A/2)));
fnew2 = subs(fnew, {cos(A),cos(2*A),cos(3*A)}, {cosA, cos2A, cos3A});
OUTPUT:
>> fnew
fnew =
(15625*cos(A)^3)/1024 + (16875*cos(A)^2)/1024 + (1275*cos(A))/1024 - 999/1024
>> fnew2
fnew2 =
(15625*cosA^3)/1024 + (16875*cosA^2)/1024 + (1275*cosA)/1024 - 999/1024
>> coeffs(fnew2,cosA)
ans =
[ -999/1024, 1275/1024, 16875/1024, 15625/1024]
>> coeffs(fnew2,cos2A)
ans =
(15625*cosA^3)/1024 + (16875*cosA^2)/1024 + (1275*cosA)/1024 - 999/1024
>>
I am unable to get the coefficients
Well, as I indicated above:
Note: simplify() might not be enough to force the trig substitution in MuPad. In Maple, one would use combine(EXPRESSION,'trig') to do that substitution, but I have not yet found the MuPad equivalent of `combine/trig`

Sign in to comment.

Asked:

on 4 Oct 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!