CAS.numer; denom; lcoeff; degree... ??!! [It's OK NOW ! :o)]
02-14-2015, 07:35 PM (This post was last modified: 02-16-2015 08:46 PM by dg1969.)
Post: #1
 dg1969 Member Posts: 110 Joined: Apr 2014
CAS.numer; denom; lcoeff; degree... ??!! [It's OK NOW ! :o)]
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);
02-14-2015, 08:34 PM (This post was last modified: 02-15-2015 01:53 PM by dg1969.)
Post: #2
 dg1969 Member Posts: 110 Joined: Apr 2014
RE: CAS.numer; denom; lcoeff; degree... ??!!
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-16-2015, 07:53 PM
Post: #3 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: CAS.numer; denom; lcoeff; degree... ??!!
(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)

Graph 3D | QPI | SolveSys
02-16-2015, 08:45 PM
Post: #4
 dg1969 Member Posts: 110 Joined: Apr 2014
RE: CAS.numer; denom; lcoeff; degree... ??!! [IT'S OK NOW !]
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)
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)