Post Reply 
An extra + sign added to the results of subst
07-08-2017, 02:28 AM
Post: #1
An extra + sign added to the results of subst
From the examples I am going through, this one is for substitution:

The example says:
subst( 2*x^2 – x, x = a + 3 ) returns 2*(a + 3)^2 – a – 3

but I'm getting:
returns 2*(a + 3)^2 + – a – 3

Any idea why I am getting the "+ - a" ? I realize it means the same thing as "-a" but I don't know why the extra + is added.

Thanks,
Jim
Find all posts by this user
Quote this message in a reply
07-08-2017, 08:02 PM
Post: #2
RE: An extra + sign added to the results of subst
(07-08-2017 02:28 AM)Skyblues Wrote:  From the examples I am going through, this one is for substitution:

The example says:
subst( 2*x^2 – x, x = a + 3 ) returns 2*(a + 3)^2 – a – 3

but I'm getting:
returns 2*(a + 3)^2 + – a – 3

Any idea why I am getting the "+ - a" ? I realize it means the same thing as "-a" but I don't know why the extra + is added.

Thanks,
Jim

Without knowing why you are getting the extra +, I would just like to quibble with your assumption that +-a is the same as -a.

Mathematically, perhaps, I can see why you might think so.
But whenever I have written such maths, I have used +(-a) or +(-a+b), making it clear what is being added. I have always queried +-a in documentation, because it looks too much like it is supposed to read +c-a and c has been omitted in a typo.
Furthermore, when reading +-a it can be misread/misunderstood as "plus or minus a", unless you are familiar with what the result should be.

(In the computer languages I am experienced in, there is only one "-" which serves as both negate and subtract... +- is not so confusing if the "-" is a different negate symbol - but even if that is so in the code/calculation, its not always clear in the documentation).

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
07-09-2017, 01:31 AM (This post was last modified: 07-09-2017 01:32 AM by Skyblues.)
Post: #3
RE: An extra + sign added to the results of subst
> I would just like to quibble with your assumption that +-a is the same as -a.
> Mathematically, perhaps, I can see why you might think so.

I agree with you completely and the reason I said they were the same is because, mathematically, it is the same and, hence, the Prime is not giving incorrect result, just a bit unusual.

> But whenever I have written such maths, I have used +(-a) or +(-a+b)

Exactly and if the result had been shown with parentheses (as you point out) I woudn't have thought too much about it.

I found it very confusing and almost missed it (it's pretty small). Actually, the "-" sign before the 'a is a little higher than the "+' sign that comes before it so I had to really look at it to see if it was actually trying to imply +(-a).

I took a screen shot in a larger skin so you can see it. It's strange, for sure.

Jim


Attached File(s)
.zip  PlusMinus.zip (Size: 1.13 KB / Downloads: 7)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)