couple of questions about complex expressions



I agree it's a mess, and we should clean it up.

One case where it's not clear what to do is <neg>^<float> with domain=real
or m1pbranch=false cases, since the oddness of the denominator of a float
is not well-defined.

Results like 0.3333*%pi make me wonder if arithmetic between approximate
numbers (floats or bfloats) and constants shouldn't return numbers.

About (-8.0)^(1/2) being different from
(-8.0)^(1/2),numer:true,domain:complex,m1pbranch:true
-- that doesn't shock me.  However, it does surprise me that
(-8.0)^(0.5),domain:complex,m1pbranch:true
isn't the same as the same with numer:true!

Re the products and quotients of complex numbers being expanded, Maxima
currently offers a lot of control over this:

(%i24) qq: (-4*%i-22)/(4*%i-2);
(%o24) (-4*%i-22)/(4*%i-2)
(%i25) rat(qq);
(%o25) -(2*%i+11)/(2*%i-1)
(%i26) rat(qq),algebraic;
(%o26) (24*%i+7)/5
(%i27) rectform(qq);
(%o27) 24*%i/5+7/5

In general, Maxima seems to err on the side of preserving the original form
of expressions, so 2*(x+1), (2*x+2)/2, and (2*x+4)/2 are considered
simplified (by the general simplifier) -- whether x is a constant (e.g. %i)
or a variable.  An argument for this is that this may best demonstrate the
structure of the expression.  (cf. Moses' "political spectrum" of
simplification in his classic "Algebraic Simplification: A Guide for the
Perplexed<http://groups.csail.mit.edu/mac/users/gjs/6.945/readings/simplification/moses-simp.pdf>;
")

Do I always want to see (1-%i)*(1+%i) as 2?  Maybe not if I have a factor
of (1+%i) elsewhere.  Conversely, there are many other structures which
have canonical forms, e.g. (1+sqrt(2))/(1-sqrt(2)) => 2*sqrt(2)+3 -- if we
simplify quadratic numbers over sqrt(-1), why not over sqrt(2)?

             -s

On Tue, Sep 25, 2012 at 6:38 AM, Barton Willis <willisb at unk.edu> wrote:

>  It's a mess. I think domain : complex and  m1pbranch : true is supposed
> to give the principle branch,
> and domain : real and m1pbranch : false the real branch, I think. But
> sometimes numer matters (and maybe
> radexpand too)
>
> OK -- real branch:
>
>   (%i8) block([domain : real, m1pbranch : false], (-8)^(1/3));
>   (%o8) -2
>
> Not OK -- principle branch (more-or-less)
>
>   (%i9) block([domain : real, m1pbranch : false, numer : true],
> (-8)^(1/3));
>   (%o9) 2.0*(-1)^0.33333333333333
>
>   (%i10) rectform(%);
>   (%o10) 2.0*%i*sin(0.33333333333333*%pi)+2.0*cos(0.33333333333333*%pi)
>
> Sometimes numer makes a difference:
>
>   (%i38) block([domain : complex, m1pbranch : true, numer : true],
> (-8.0)^(1/2));
>   (%o38) 2.82842712474619*%i+1.7318549141438711*10^-16
>
>   (%i39) block([domain : complex, m1pbranch : true, numer : false],
> (-8.0)^(1/2));
>   (%o39) 2.82842712474619*%i
>
>   (%i46) block([domain : complex, m1pbranch : true,numer : false],
> (-8.0)^(0.5));
>   (%o46) (-8.0)^0.5
>
> The user documentation for the (obscurely named) option variable m1bpranch
> is clear enough,
> but a user doesn't know when a (-1)^power is  going to be generated.
>
> I think that domain : larry and m1pbranch : sally gives the principal
> branch too:
>
>   (%i48) block([domain : larry, m1pbranch : sally], (-8)^(1/3));
>   (%o48) 2*((sqrt(3)*%i)/2+1/2)
>
> Surely one option variable (say use_real_branch) should control all this.
> And
> quotients of complex numbers should automatically simplify to a
> rectangular form.
>
> The function simpexpt is about 345 lines with about 20 calls to go :(
>
> --Barton
>
> ________________________________________
>
>
> Hi, I've run into a couple of things that I'm wondering about.
>
> (1) principal branch for (-x)^(1/n) when n is an odd integer. I know
> we've gone back and forth on this one, and at present it looks like the
> real branch is chosen. Is there a way to choose the principal branch?
> For the record, m1pbranch doesn't seem to have any effect here.
>
> (2) division of complex literals: how can I get (a + b*%i)/(c + d*%i) =>
> e + %i*f when a, b, c, and d are numbers.
>
> I can't seem to cause it to happen. realpart(foo) + %i*imagpart(foo) has
> the expected result but it just seems clumsy.
>
> (%i2) foo : (5 + %i)/(3 - 2*%i);
> (%o2) (%i+5)/(3-2*%i)
> (%i3) expand (foo);
> (%o3) %i/(3-2*%i)+5/(3-2*%i)
> (%i4) ratsimp (foo);
> (%o4) -(%i+5)/(2*%i-3)
> (%i5) radcan (foo);
> (%o5) -(%i+5)/(2*%i-3)
> (%i6) foo, numer;
> (%o6) (%i+5)/(3-2*%i)
> (%i7) float (foo);
> (%o7) (%i+5.0)/(3.0-2.0*%i)
> (%i8) expand (float (foo));
> (%o8) %i/(3.0-2.0*%i)+5.0/(3.0-2.0*%i)
>
> Thanks for your help,
>
> Robert Dodier
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>