1

I have this expression in WXMAXIMA:

100/(25.00079433726757*%i+20)

How can i reduce to the form a + %i b?

I tried rectform, float, polarform... Any of those functions seem to simplify that simple calculus. Just two numbers. Dont imagine how...

Full process:

(%i2)   load("ezunits");
numer: true;
(%o1)   "/usr/share/maxima/5.45.1/share/ezunits/ezunits.mac"
(%o2)   true

(%i3)   R1: 20`ohm;
(%o3)   20 ` ohm

(%i9)   f:50`Hz;  w: 2*%pi*f;
        L1: 79.58 `mH;
        Z1: R1 + (w*L1 ``ohm) * %i;
        cabs(Z1); float(carg(Z1)) `` degree;
(%o4)   50 ` Hz
(%o5)   314.1592653589793 ` Hz
(%o6)   79.58 ` mH
(%o7)   (25.00079433726757*%i+20) ` ohm
(%o8)   32.01624146420611 ` ohm^1.0
(%o9)   51.34107977110403 ` degree



(%i81)  V: 100 ` volt;
        I1: V / Z1;
        rectform(I1);

(%o79)  100 ` volt

(%o80)  100/(25.00079433726757*%i+20) ` volt/ohm
(%o81)  realpart(100/(25.00079433726757*%i+20) `     volt/ohm)+%i*imagpart(100/(25.00079433726757*%i+20) ` volt/ohm)

As u can see at %o81, the calculus isn't simplified. Maybe unit affected? Tried to remove unit with nounit() but still everything is not simplified

(%i84)  V: 100 ` volt;
        I1: V / Z1;
        nounit(rectform(I1));

(%o82)  100 ` volt

(%o83)  100/(25.00079433726757*%i+20) ` volt/ohm
(%o84)  nounit(realpart(100/(25.00079433726757*%i+20) ` volt/ohm)+%i*imagpart(100/(25.00079433726757*%i+20) ` volt/ohm))
Robert Dodier
  • 16,905
  • 2
  • 31
  • 48

1 Answers1

0

Okay, here's what I figured out that works. I'll start with the definitions you made.

(%i2) load ("ezunits");
(%o2) /home/robert/tmp/maxima-read-only-git/maxima-code/share/ez\
units/ezunits.mac
(%i3) R1: 20`ohm;
(%o3)                       20 ` ohm
(%i4) f:50`Hz;
(%o4)                        50 ` Hz
(%i5) w: 2*%pi*f;
(%o5)                     100 %pi ` Hz
(%i6) L1: 79.58 `mH;
(%o6)                      79.58 ` mH
(%i7) Z1: R1 + (w*L1 ``ohm) * %i;
(%o7)               (7.958 %i %pi + 20) ` ohm
(%i8) V: 100 ` volt;
(%o8)                      100 ` volt
(%i9) I1: V / Z1;
                           100          volt
(%o9)               ----------------- ` ----
                    7.958 %i %pi + 20   ohm
(%i10) rectform(I1);
                       100          volt
(%o10) realpart(----------------- ` ----)
                7.958 %i %pi + 20   ohm
                                               100          volt
                          + %i imagpart(----------------- ` ----)
                                        7.958 %i %pi + 20   ohm

Okay, now %o10 is the same result you got before. The ezunits package has some rules for handling realpart and imagpart, but they weren't fully applied yet; that's probably a bug. To cause the units to move from inside realpart and imagpart, we can cause the expression to be resimplified by re-evaluating it via ''% as in %i11.

(%i11) ''%;
                        100
(%o11) (realpart(-----------------)
                 7.958 %i %pi + 20
                                              100            volt
                         + %i imagpart(-----------------)) ` ----
                                       7.958 %i %pi + 20     ohm

Now realpart and imagpart only contain numerical expressions; volt/ohm was moved outside. Now to cause realpart and imagpart to evaluate the numerical expressions, we can "verbify" realpart and imagpart via ev(...) as in %i12.

(%i12) ev (%, realpart, imagpart);
                2000           795.8000000000001 %i %pi    volt
(%o12) (-------------------- - ------------------------) ` ----
                     2                        2            ohm
        63.329764 %pi  + 400     63.329764 %pi  + 400

Now %o12 is just a numerical expression, and we can apply float.

(%i13) float (%);
                                                     volt
(%o13)  (1.951143907758894 - 2.439007378014635 %i) ` ----
                                                     ohm

So the key points were %i11 and %i12. I'm sorry that these operations are completely unintuitive; the problem you ran into is a consequence of subtle and obscure aspects of Maxima. I hope that these notes help you make progress all the same. Thanks for your interest in Maxima, and ezunits in particular (I wrote the package).

EDIT: Another thing to try when working with units. There is a function dimensionally (undocumented, sorry about that) which helps other functions, which are not aware of units, to handle the units. In this case it can help rectform. With I1 as before, I get

(%i4) dimensionally (rectform (I1));
                   2000
(%o4) (-----------------------------
                             2
       63.329764000000004 %pi  + 400
                              795.8000000000001 %i %pi       volt
                          - -----------------------------) ` ----
                                                  2          ohm
                            63.329764000000004 %pi  + 400

which is the same result as before, but a little bit sooner to get there.

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48