HP Forums
Command 'coeff' (CAS Mode) - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Command 'coeff' (CAS Mode) (/thread-21822.html)



Command 'coeff' (CAS Mode) - hp-zl - 05-31-2024 07:05 PM

There is a trigonometric series (screenshot):
a:=(5*q+1)*sin(2*v)+(6*q^2+2)*sin(4*v)

We want to find the coefficient of sin(2*v), so we do:
coeff(a, sin(2*v),1) we get the correct result: 5*q+1.

But when we type:
coeff(a, sin(v*2),1) then we get zero.

With 'sin(4*v)' similarly (see screenshot).

The same results are given by both the physical calculator (with the latest firmware 2.1.14730) and the virtual calculator (HP_Prime_Virtual_Calculator-x86_64.AppImage, firmware 2.1.14288).

What do you think about it?
[attachment=13595]


RE: Command 'coeff' (CAS Mode) - komame - 05-31-2024 07:51 PM

This problem also occurs for much simpler cases.
Assigning the expressions:
5*sin(2*x) and 5*sin(x*2) to the variables "a" and "b" results in "a" and "b" containing exactly the same expression: 5*sin(2*x).
However, applying the coeff function to each of these variables yields different results => screenshot.
[attachment=13597]


RE: Command 'coeff' (CAS Mode) - parisse - 05-31-2024 08:24 PM

coeff is meant to work on polynomials with respect to an identifier, not with respect to a subexpression. It will work only if the subexpression is written exactly the same way in an expression.
If you run b:=sin(x*2) then the answer is displayed according to autosimplify mode, but b is not autosimplified.


RE: Command 'coeff' (CAS Mode) - komame - 05-31-2024 08:54 PM

(05-31-2024 08:24 PM)parisse Wrote:  coeff is meant to work on polynomials with respect to an identifier, not with respect to a subexpression. It will work only if the subexpression is written exactly the same way in an expression.
If you run b:=sin(x*2) then the answer is displayed according to autosimplify mode, but b is not autosimplified.

That's right. The syntax for the coeff in the help states that the second parameter should be [Var]. Moreover, setting the simplify parameter to 'None' in the CAS settings and repeating these operations explains everything. Thank you for the clarification.