HP Forums

Full Version: CAS.numer; denom; lcoeff; degree... ??!! [It's OK NOW ! :o)]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I can't find a way to use lcoeff; degree; coeff in a home program...

Code:

CAS.numer("(2+x^2)/(1+x)") is ok => x^2+2
CAS.denom("(2+x^2)/(1+x)") is ok => x+1

but :
CAS.coeff("x^2+2,2") =>0
CAS.lcoeff("3*x^3+2*x") => 3*x^2+2 in place of 3
CAS.degree("3*x^3+2*x") => 0 !!

CAS.froot("(1+x^2)/(1-x)") =>[] !!

In my mind string inside CAS.cas_stuff("...") is the good practice ?


these code doesn't work...
Code:

f:="numer((1+x^2)/(1+x))";
num:=CAS(f);
I need these functions in a home program because i'd like to compute symbolicaly the phase \(\varphi\) of a transfer functions \(\dfrac{P(s)}{Q(s)}\cdot e^{-k\cdot s}\) initially placed in F0 to F9 var in term of 'X' in a FUNCTION APP like

"froot" from CAS give me all roots of numerator and denom with multiplicity so :

\(F(s)=K\cdot\dfrac{(s-r1)...(s-r_n)}{(s-p_1)...(s-p_m)}\cdot e^{-k\cdot s}\) with \(n \leq m\)

\(\varphi=arg(F(i\cdot \omega) \)

lcoeff(numer)/lcoeff(denom) give me \(K\) so first term of \(\varphi\) is known

I can easily compute the major terms of the sum of \( \varphi\) : \(+/-m_i\cdot atan \dfrac{\beta_i-\omega}{\alpha_i}\) where \(\omega \) is the pulsation ; \(\alpha_i; \beta_i ;m_i \) are resp the real part the imaginary part and multiplicity of roots and poles of \(F(s)\)
I need to test if an exp term is there to add the last term in the phase sum... Don't know how to parse yet...

At the end I want to place these phase functions in F_i var's in term of 'X' for plot...

I try these way to plot bode phase without +/- pi discontinuity... At the end I want to keep benefits of the function app plot facility (max, zero etc...)
(02-14-2015 07:35 PM)dg1969 Wrote: [ -> ]I can't find a way to use lcoeff; degree; coeff in a home program...

Code:

CAS.numer("(2+x^2)/(1+x)") is ok => x^2+2
CAS.denom("(2+x^2)/(1+x)") is ok => x+1

but :
CAS.coeff("x^2+2,2") =>0
CAS.lcoeff("3*x^3+2*x") => 3*x^2+2 in place of 3
CAS.degree("3*x^3+2*x") => 0 !!

CAS.froot("(1+x^2)/(1-x)") =>[] !!

In my mind string inside CAS.cas_stuff("...") is the good practice ?


these code doesn't work...
Code:

f:="numer((1+x^2)/(1+x))";
num:=CAS(f);

Tried with the emulator, and everything works properly here for me. As for

CAS.coeff("x^2+2,2") =>0

are you sure you didn't mean

CAS.coeff("x^2+2","2")

Notice the quotes around each argument (the second set of quotes is unnecessary since the 2 is not symbolic)
Han. You are absolutely irreplaceable ! Thank you for your endless patience.
I just found something you already knew. Integrated help does not give the exact syntax for the HOME side which is in fact different from the CAS side.


In CAS side:
Code:

froot((1+x^3)/(1+2*x))
is ok not need the second argument: 'x'

but it is essential in the "home" side. The aid does not indicate

expect for :
Code:

CAS.coeff("x^2+3-2*x","x","2")
(I am the only guilty 3 args clearly mentioned in the help)

so
Code:

CAS.froot("(1+x^2)/(2*x+x^3)","x")
or with a single string :
Code:

CAS.froot("(1+x^2)/(2*x+x^3),x") working perfectly !

It's the same thing for other commands that I mentioned...

Han, you know what ? You are my best cyber-friend :o)
Reference URL's