Post Reply 
An extra + sign added to the results of subst
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
Post Reply 


Messages In This Thread
RE: An extra + sign added to the results of subst - StephenG1CMZ - 07-08-2017 08:02 PM



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