Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Solve Minus Sign

1 view
Skip to first unread message

Fabian

unread,
Jan 7, 2010, 2:29:27 AM1/7/10
to
Dear Group-

How can one get rid of the minus sign in:

In:
Factor[Solve[Rr/s == Rr + x, x]]

Out:
{{x -> -((Rr (-1 + s))/s)}}

We'd like Mathematica to provide answers with the minus sign
"multiplied through" (remove Factor[] doesn't solve the problem)

Thank you in advance all.

David Park

unread,
Jan 8, 2010, 4:13:22 AM1/8/10
to
A pox on those minus signs!

As far as I know, this requires doing surgery on expressions. Here are some
techniques.

step1 = Solve[Rr/s == Rr + x, x][[1, 1]] // Factor

x -> -((Rr (-1 + s))/s)

The first method is to use Minus on the two different factors that contain
the minus signs.

MapAt[Minus, step1, {{2, 1}, {2, 3}}]

x -> (Rr (1 - s))/s

A second method is to Simplify and then use Simplify again on a specific
part.

Simplify[step1]
MapAt[Together, %, {{2, 2}}]

x -> Rr (-1 + 1/s)
x -> (Rr (1 - s))/s

With Presentations you can also operate on a specific subset of level parts,
in this case the two terms in the product.

Needs["Presentations`Master`"]

step1 // MapLevelParts[Expand, {2, {1, 3}}]

x -> (Rr (1 - s))/s

As far as I know, regular Mathematica doesn't have a way of operating
together on a subset of level parts in a sum or product.

Another method with Presentations is to FactorOut a -1 from s-1 and
temporarily hold the result until the -1 can combine with the rest of the
expression.

MapAt[FactorOut[-1, HoldForm], step1, {{2, 3}}] // ReleaseHold

x -> (Rr (1 - s))/s


In general, the two main techniques for doing surgery on expressions are:

1) Operate on only selected portions of an expression using MapAt,
ReplacePart, or MapLevelParts.
2) Shield portions of a expression using HoldForm, or CreateSubexpression in
Presentations, so Mathematica won't split them up when doing simplifications
on the larger expression.


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/

dh

unread,
Jan 8, 2010, 4:18:08 AM1/8/10
to

Hi Fabian,

use e.g. Expand:

Factor[Solve[Rr/s == Rr + x, x]] // Expand

Daniel

Bob Hanlon

unread,
Jan 8, 2010, 4:18:42 AM1/8/10
to

At least in this case, just use Simplify.

Solve[Rr/s == Rr + x, x][[1]] // Simplify

{x -> Rr*(1/s - 1)}


Bob Hanlon

---- Fabian <fabian....@gmail.com> wrote:

=============

Andrzej Kozlowski

unread,
Jan 10, 2010, 3:27:47 AM1/10/10
to
Actually, in this particular case, one can do this in a simpler way:

Collect[Solve[Rr/s == Rr + x, x], Rr]

{{x -> (Rr*(1 - s))/s}}

Andrzej Kozlowski

On 8 Jan 2010, at 18:13, David Park wrote:

> A pox on those minus signs!
>
> As far as I know, this requires doing surgery on expressions. Here are some
> techniques.
>

> step1 = Solve[Rr/s == Rr + x, x][[1, 1]] // Factor

>
> x -> -((Rr (-1 + s))/s)
>

Fabian Marcel

unread,
Jan 10, 2010, 3:29:23 AM1/10/10
to
Thank you Andrzej, that was a nice little trick.
0 new messages