Though it may be broken in the sense of "does not do what I want it to do",
it is not broken in the sense of "does not conform to its definition":
...transform[s] subexpressions of the form `a1*log(b1) + a2*log(b2) +
c' into `log(ratsimp(b1^a1 * b2^a2)) + c'
Which is why I suggested changing its definition:
perhaps there should be a logconmode=all which contracts things like
log(x)+C
I suspect that logconmode=all is *not* the right default. One generally
doesn't want log(x)+1 to contract to log(%e*x). For that matter, Maxima
currently can't do much useful with abs(z)*exp(%i*carg(z)).
-s
PS Someone should tell Maxima that imagpart(carg(...)) = 0...
On Tue, Feb 21, 2012 at 14:02, Henry Baker <hbaker1 at pipeline.com> wrote:
> Yup, logcontract is broken:
>
> (%i1) declare(z,complex);
> (%o1) done
> (%i2) log(z);
> (%o2) log(z)
> (%i3) %,rectform;
> (%o3) log(abs(z)) + %i carg(z)
> (%i4) logcontract(%);
> (%o4) log(abs(z)) + %i carg(z)
> (%i5) %,logcontract;
> (%o5) log(abs(z)) + %i carg(z)
>
> At 08:56 AM 2/21/2012, Stavros Macrakis wrote:
> >Well, log(%i) and log(-%i) have all the same issues as log(-1) (except
> for (2)). If you convert log(%i*x)+log(%i) to log(%i*x)+%i*%pi/2, you
> have the same contraction problem as before. That is why I'm suggesting
> that solving this reasonable may involve adding some functionality to
> logcontract as well as changing the default simplifications for log.
> >
> > -s
> >
> >On Tue, Feb 21, 2012 at 11:43, Henry Baker <hbaker1 at pipeline.com> wrote:
> >But I asked about log(-%i), which should be pretty non-controversial.
> >
> >If there is a switch for log, it should indicate what your favorite
> branch is: e.g., [-%pi,+%pi), [0,2*%pi), etc.
> >
> >At 08:30 AM 2/21/2012, Stavros Macrakis wrote:
> >>Good question. For that matter, log(-1) only simplifies to %i*%pi if
> lognegint = true (default is false).
> >>
> >>Here are the possible arguments I can think of for this behavior (I
> don't guarantee that they correspond to the original rationale...):
> >>
> >>1) log is multivalued, and the user may want to control whether log(-1)
> => %pi or -%pi etc.
> >>2) Maxima assumes the user is working in the real domain, so shouldn't
> introduce %i unless explicitly asked to. But domain:complex doesn't change
> the behavior.
> >>3) log(-1) may appear as an intermediate result of a real calculation
> which goes away with simplification, e.g. logcontract(log(-1)+log(-x)), so
> why confuse matters?
> >>4) Once you have an expression like log(x)+%i*%pi, converting back to
> log(-x) is slightly tricky -- actually, simply log(exp(EXPR)) will do it,
> but there is no easy way to apply that globally, like logcontract.
> >>
> >>I suspect that 3 and 4 are the most important.
> >>
> >>So perhaps the default is OK, but log(-C) and log(%i*C) should expand
> out when domain=complex or logexpand=ultra. Conversely, perhaps there
> should be a logconmode=all which contracts things like log(x)+C so that
> arguments 3 and 4 go away....
> >>
> >>Thoughts?
> >>
> >> -s
> >>
> >>On Mon, Feb 20, 2012 at 23:38, Henry Baker <hbaker1 at pipeline.com> wrote:
> >>How come log(-%i) doesn't already simplify by itself, instead of
> requiring rectform to do it?
> >>
> >>Is there some switch that Maxima uses to force log(constant) to simplify
> if it can?
> >>
> >>At 01:12 PM 2/20/2012, Stavros Macrakis wrote:
> >>>Henry,
> >>>
> >>>Yes, this derivation is essentially the same as the bottomup rectform.
> In fact:
> >>>
> >>> expr: logcontract(logarc(4*atan(1/5)-atan(1/239)));
> >>> rectform(substpart(e1:rectform(piece),expr,1,2,1)) => %pi/4
> >>>
> >>>You'll see that e1 here is -%i.
> >>>
> >>>What rectform does internally by default looks more like
> >>>
> >>> rectform(substpart(e2:polarform(piece),expr,1,2,1));
> >>>
> >>>where e2 isn't at all helpful.
> >>>
> >>>I agree that most mathematical functions (sin, etc.) and form-changing
> routines (factor etc.) should distribute over "=".
> >>>
> >>> -s
> >>>
> >>>On Mon, Feb 20, 2012 at 15:45, Henry Baker <hbaker1 at pipeline.com>
> wrote:
> >>>result=4*atan(1/5)-atan(1/239);
> >>> 1 1
> >>>(%o1) result = 4 atan(-) - atan(---)
> >>> 5 239
> >>>(%i2) lhs(%)=logcontract(logarc(rhs(%)));
> >>> 4
> >>> (%i - 5) (%i + 239)
> >>> %i log(- --------------------)
> >>> 4
> >>> (%i - 239) (%i + 5)
> >>>(%o2) result = ------------------------------
> >>> 2
> >>>(%i3) %*2/%i;
> >>> 4
> >>> (%i - 5) (%i + 239)
> >>>(%o3) - 2 %i result = log(- --------------------)
> >>> 4
> >>> (%i - 239) (%i + 5)
> >>>(%i4) exp(lhs(%))=exp(rhs(%));
> >>> 4
> >>> - 2 %i result (%i - 5) (%i + 239)
> >>>(%o4) %e = - --------------------
> >>> 4
> >>> (%i - 239) (%i + 5)
> >>>(%i5) lhs(%)=rectform(rhs(%));
> >>> - 2 %i result
> >>>(%o5) %e = - %i
> >>>(%i6) log(lhs(%))=log(rhs(%));
> >>>(%o6) - 2 %i result = log(- %i)
> >>>(%i7) rectform(lhs(%))=rectform(rhs(%));
> >>> %i %pi
> >>>(%o7) - 2 %i result = - ------
> >>> 2
> >>>(%i8) solve(%,result);
> >>> %pi
> >>>(%o8) [result = ---]
> >>> 4
> >>>
> >>>This example shows why rectform, log, exp, logcontract, logarc, etc.,
> should distribute over "=".
> >>>
> >>>At 11:20 AM 2/20/2012, Stavros Macrakis wrote:
> >>>>Consider the expression 4*atan(1/5)-atan(1/239) (Machin's formula).
> >>>>
> >>>>How can we use Maxima to simplify it to %pi/4?
> >>>>
> >>>>Well, here's one approach:
> >>>>
> >>>>atan(trigexpand(trigexpand(tan(ex))))
> >>>>
> >>>>And here's another way that doesn't depend on trig identities:
> >>>>
> >>>>(%i1) ex:4*atan(1/5)-atan(1/239);
> >>>>(%o1) 4*atan(1/5)-atan(1/239)
> >>>>(%i2) llex: logcontract(logarc(ex));
> >>>>(%o2) %i*log(-(%i-5)^4*(%i+239)/((%i-239)*(%i+5)^4))/2
> >>>>(%i3) rectform(llex);
> >>>>(%o3)
> (atan(sin(4*atan(1/5))/cos(4*atan(1/5)))-atan(sin(4*(%pi-atan(1/5)))/cos(4*(%pi-atan(1/5))))-2*atan(1/239))/2
> >>>> <<< oops, not so helpful
> >>>>(%i4) scanmap(rectform,llex,bottomup);
> >>>> <<< but reorganizing the rectform calculation gives a better
> result
> >>>> <<< makes me think that rectform could be improved...
> >>>>(%o4) %pi/4
> >>>>
> >>>>Are any of these techniques packaged into some analog of trigsimp?
> >>>>
> >>>> -s
>
>