HP Forums
An extra + sign added to the results of subst - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: An extra + sign added to the results of subst (/thread-8647.html)



An extra + sign added to the results of subst - Skyblues - 07-08-2017 02:28 AM

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


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

(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).


RE: An extra + sign added to the results of subst - Skyblues - 07-09-2017 01:31 AM

> 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