       Re: Re: canonical mathematical expression represenation?

• To: mathgroup at smc.vnet.net
• Subject: [mg52548] Re: [mg52511] Re: [mg52484] canonical mathematical expression represenation?
• From: DrBob <drbob at bigfoot.com>
• Date: Wed, 1 Dec 2004 05:58:46 -0500 (EST)
• References: <200411301024.FAA01367@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```To use that kind of solution, you'd probably have to look at FullForm to decide what indices to use in MapAt. In this case, for instance:

Sum[a^k,{k,0,M}]//FullForm

Times[Power[Plus[-1,a],-1],Plus[-1,Power[a,Plus[1,M]]]]

The denominator is Plus[-1,a] at position {1,1} in the expression, and the numerator is Plus[-1, Power[a, Plus[1, M]]] at position {2}.

A more automatic but somewhat bulky option is:

expr /. {Denominator[expr] ->
-Denominator[expr],
Numerator[expr] ->
-Numerator[expr]}

(1 - a^(1 + M))/(1 - a)

Here's a simpler solution, though not as general:

expr /. {-1 + x_ :> 1 - x}

(1 - a^(1 + M))/(1 - a)

And finally, try this one:

expr /. {x_ + y_ /; x < 0 -> (-x) + (-y)}

(1 - a^(1 + M))/(1 - a)

That's less general than the Numerator/Denominator solution, but more general than the others.

Bobby

On Tue, 30 Nov 2004 05:24:27 -0500 (EST), David Park <djmp at earthlink.net> wrote:

>
> Yes it is annoying the way Mathematica tends to get the minus signs where we
> would prefer not to have them. One way to fix this, in simple expressions at
> least, is to Map Minus to the two factors you would wish to change.
>
> Sum[a^k, {k, 0, M}]
> MapAt[Minus, %, {{1, 1}, {2}}]
> (-1 + a^(1 + M))/(-1 + a)
> (1 - a^(1 + M))/(1 - a)
>
> I find that it is almost always possible to manipulate expressions to the
> form you want, textbook form say, but it is a bit of an art and sometimes
> even I have to come to MathGroup to learn the trick.
>
>
> David Park
>
> From: nospam nospam [mailto:nospam_please at nospam.com]
To: mathgroup at smc.vnet.net
>
> I noticed that Mathematica represents expressions with
> some specific 'way' or order.
>
> For example,
>
> Sum[a^k, {k, 0, M}]
>
> gives
>           -1 + a^(1+M)
>          -------------
>             -1 + a
>
>
> How can I make it display the expression, in what I would consider
> a more 'natural' way, as follows
>
>            1 - a^(1+M)
>          -------------
>             1 - a
>
> I am sure there is a way to do, and why do you think
> Mathematica does it the way it does? what is the logic
> of how it represents things? is there a command to convert
> the first output to the second? I tried few commands, but
> can not figure it out.
>
> thank you,
> --nospam
>
>
>
>
>
>

--
DrBob at bigfoot.com
www.eclecticdreams.net

```

• Prev by Date: Re: launching a kernel on a remote linux machine through ssh from a linux machine
• Next by Date: Inserting user material in the HelpBrowser
• Previous by thread: Re: canonical mathematical expression represenation?
• Next by thread: Re: use of orderless