1

how are you?.

I'm having a problem to do a partial fraction expand in wxMaxima, I have the following equation which has several non integer coefficients

        3.63353804840429*10^-8*z^2-7.322452324955847*10^-8*z+3.687492572586066*10^-8
X(z) =  ----------------------------------------------------------------------------
                     1.0*z^2-1.999945180935844*z+0.9999451809358438

when I try to do a partfrac of that equation then wxMaxima simply doesn't do it as it can be seen bellow

Salida de partfrac

I know that at least the denominator has real roots because when I apply a solve then the result has two real roots very close to one like is seen bellow

float(solve(denom(PIDz))));
(%o185) [z=0.9999451810050616,z=0.9999999999307788]

I think the problems is due to the non integer coefficients or due to decimal quantity but I don't know how to solve it.

How can this be solved?.

Update 15/01/22:

The initial equation of my post is the calculated equation for making a PID control for the following plant (the following equation was obtained with Scilab)

              79.728153*z+79.433306
          -----------------------------
            z^2-1.9889465*z+0.9889465

Update 17/01/21:

Following the method teached by @Robert Dodier but with x(z) then I found the relation between the coefficients of the denominator of x(z), then I replace those coefficients with algebraic ones like follows

dd1: z^2 - (cd - 2)*z + cd;
(dd1)  z^2-(cd-2)*z+cd

nn1: nn1: an*z^2 + bn*z + cn;
(nn1)  an*z^2+bn*z+cn

nn1/dd1;
(%o3) (an*z^2+bn*z+cn)
     -------------------
      (z^2-(cd-2)*z+cd)

partfrac (nn1/dd1, z);
%o4   (an*cd+bn-2*an)*z+cn-an*cd)
     -----------------------------  + an
           (z^2-(1 + cd)*z+cd)

I've tested it with several combinations in the numerator, I mean, first order equation and second order equation having all coefficients on the numerator without any relation between them. After that and having found the relation between the coefficients of the denomintaror being the coefficient of the first order term (cd - 2) with cd being the independent term, I obtained the above %o4. That exactly the same result form that is obtained numerically like is seen in the image "Salida de partfrac"

That is, when maxima find that kind of equation in the denominator then it doesn't factorize the denominator.

Thanks in advance for the help.

vram
  • 85
  • 8
  • Hey @Robert Dodier, how are you?. can you help me with this? – vram Jan 13 '22 at 20:20
  • Hi, it looks like the coefficients should be 2 or 1 or something like that. My advice is to only use rational numbers or symbolic coefficients, instead of floating point numbers, from the very start. When Maxima tries to work with floats, they're usually converted to rational numbers with lots of digits, which obscures what's going on. It's best to avoid floats entirely if you are interested in algebraic manipulations, and only introduce floats at the very end of the calculations. – Robert Dodier Jan 14 '22 at 19:36
  • I think it would help others help you if you showed how you arrived at the equation which you showed. You can help others understand what's going on by describing the bigger picture or context around the equations you showed. – Robert Dodier Jan 14 '22 at 19:37
  • @RobertDodier well, the claculation to arrive to that point is a little bit complicated, I'm designing a PID control in discrete domain by pole-placement and the original equation comes from Scilab, then I had to use the numbers as floats because those poles are close to the unit circle and wxMaxima was approaching the numbers to the integer close to them. After that I do several procedures to put the denominator as a characteristic equation and yes, several times I explicitly convert the result to float. – vram Jan 15 '22 at 22:56
  • @RobertDodier Anyway I hard coded the rest of the procedure to obtain the partial fractions according to the specific type of equation that I have (a cuadratic equation on both numerator and denominator). In addition, if Maxima converts the numbers to rationals then I think I doesn't have another option besides keep working like that (hard codind some things) because I need the denominator as an characteristic equation. – vram Jan 15 '22 at 22:59
  • @RobertDodier Finally I put the original plant which originally comes with float numbers – vram Jan 15 '22 at 23:06

1 Answers1

0

I can't tell what's going on from what you were saying. My advice at this point is to repost in es.stackoverflow.com and I'll try again; I can read and write Spanish. I'm thinking you will able to express the problem more clearly.

Anyway here's how far I got with the equation from Scilab. I don't know if this is useful.

(%i2) dd:z^2-1.9889465*z+0.9889465;
                   2
(%o2)             z  - 1.9889465 z + 0.9889465
(%i3) dd1: z^2 - (1 + cd)*z + cd;
                       2
(%o3)                 z  - (cd + 1) z + cd
(%i4) nn:79.728153*z+79.433306;
(%o4)                79.728153 z + 79.433306
(%i5) nn1: bn*z + cn;
(%o5)                       bn z + cn
(%i6) nn1/dd1;
                           bn z + cn
(%o6)                 --------------------
                       2
                      z  - (cd + 1) z + cd
(%i7) partfrac (nn1/dd1, z);
                 cn + bn cd           cn + bn
(%o7)         ----------------- - ----------------
              (cd - 1) (z - cd)   (cd - 1) (z - 1)
(%i8) factor (dd1);
(%o8)                   (z - 1) (z - cd)

This last bit, %o8, shows the denominator has a unit root. Does that cause complications for you?

I replaced 0.9889465 by cd and then 1.9889465 by 1 + cd -- if there are any other know relations between coefficients, it's good to use them. I don't see any relations for the other coefficients, so I just replaced them with bn and cn. The intent is to do any manipulations, then replace the constants cd, bn, cn with their numerical values.

How was the result from Scilab derived? I'm thinking maybe that should be done symbolically or at least with rational numbers also.

EDIT: Here's the result I get after trying again. The one difference between this result and the one shown by OP in the edit dated 17/01/21 (I guess that must be 17/01/22) is in dd1 -- I think the coefficient of z should be -(1 + cd), not 2 - cd.

(%i2) dd1: z^2 - (1 + cd)*z + cd;
                       2
(%o2)                 z  - (cd + 1) z + cd
(%i3) nn1: an*z^2 + bn*z + cn;
                            2
(%o3)                   an z  + bn z + cn
(%i4) nn1/dd1;
                           2
                       an z  + bn z + cn
(%o4)                 --------------------
                       2
                      z  - (cd + 1) z + cd
(%i5) factor(dd1);
(%o5)                   (z - 1) (z - cd)
(%i6) partfrac (nn1/dd1, z);
                     2
           cn + an cd  + bn cd     cn + bn + an
(%o6)      ------------------- - ---------------- + an
            (cd - 1) (z - cd)    (cd - 1) (z - 1)
Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
  • @RoberDodier I understand what you tried to do by manipulating the denominator but nevertheless, the manipulation should be done with x(z), the first equation written in the post which is the PID equation. I'll do a new update with your method applied to x(z) which I've done and found that Maxima manages it in the same way that my original equation was managed, it just separates the first part of the equation but it doesn't factorize the denominator – vram Jan 17 '22 at 15:31
  • OK, I tried again, see EDIT in my answer. It's similar to what you showed except that the coefficient of `z` is `-(1 + cd)`, not `2 - cd` as you showed it. I chose `-(1 + cd)` in order to match `z^2 - 1.999945180935844*z + 0.9999451809358438`, with `cd = 0.999945...`. – Robert Dodier Jan 17 '22 at 18:26
  • By the way, I see that `factor(z^2+(2-cd)*z+cd)` doesn't factor into two terms. But you can look at `solve(z^2+(2-cd)*z+cd, z)` which gives the two roots, and so it looks like the factorization would be messy -- it would be `(z - )*(z - )`, so that's probably why `factor` didn't do it. – Robert Dodier Jan 17 '22 at 18:29
  • ...Upps, my mistake about the (2 - cd), I'll correct that inmediatly, thanks again – vram Jan 17 '22 at 20:31
  • Extracting the coefficients from x(z) and then inserting them in the rigth places at the algebraic partial fraction gives me the answer I was looking for. Thank you so much Robert – vram Jan 17 '22 at 20:43
  • One last question, several times I tried to pause a program execution by using break(something); but maxima prints "Entering a Maxima break point. Type 'exit;' to resume." but inmediatly it continues with the following lines of code. What can I do to stop that behavior?...or is a question for another post? – vram Jan 17 '22 at 21:09
  • I'm glad to hear you got it working. About the break(something) behavior, that sounds like a bug in wxMaxima. You can submit a bug report to the issue tracker at: https://github.com/wxMaxima-developers/wxmaxima Please say exactly what is your input, and also the output of `wxbuild_info();`. – Robert Dodier Jan 18 '22 at 03:19
  • Thanks again Robert, have a good day – vram Jan 18 '22 at 12:56