09-22-2021, 07:10 PM
A couple of years ago I posted about a problem with the diff() command (https://www.hpmuseum.org/forum/thread-13532.html). The problem still exists in the most recent firmware.
I guess I had forgotten about the issue because I ran into the problem again yesterday, only it's worse than I original thought. The problem arises when you try to evaluate a derivative at a value, which is something that frequently comes up in calculus and physics.
For instance, evaluating the 2nd derivative of x^3 at x=4.
diff(x^3,x,2)|x = 4
which should evaluate to 6*x|x=4 which is 24. However, the CAS substitutes 4 in for x BEFORE differentiating, so the expression is interpreted as
diff(4^3,4,2) = diff(64,4,2)
which is meaningless.
Even worse than no answer is giving the wrong answer. If the value of x contains pi, then you get incorrect results.
diff(x^3+π^4,x)|x = π
should result in 3*x^2|x=π which is 3*π^2. Instead, the line is interpreted as
diff(π^3+π^4,π)
and now π is treated as a variable. So the result is 3*π^2+4*π^3.
This issue came to light yesterday when I was checking my test answer key and entered this (using primes which is equivalent to diff).
(x^2*cos(x))''|x = π
evaluated to -2 instead of π^2-2. I assumed that I had made some silly mistake in my work by hand. It took several repeated attempts before I concluded that I was correct and the calculator was wrong.
I realize I could use the d/dx template which works correctly, but there is no template for 2nd or higher order derivatives and
(∂(∂(x^2*cos(x),x),x)|(x = π))
looks really awkward (especially in Textbook mode) and using the ' (primes) is so very convenient. It's really an order of operations issue in which |x=a should be applied AFTER the diff() command has completed, not BEFORE.
And it seems only natural that the HP "Prime" should be able to correctly work with "primes".
I guess I had forgotten about the issue because I ran into the problem again yesterday, only it's worse than I original thought. The problem arises when you try to evaluate a derivative at a value, which is something that frequently comes up in calculus and physics.
For instance, evaluating the 2nd derivative of x^3 at x=4.
diff(x^3,x,2)|x = 4
which should evaluate to 6*x|x=4 which is 24. However, the CAS substitutes 4 in for x BEFORE differentiating, so the expression is interpreted as
diff(4^3,4,2) = diff(64,4,2)
which is meaningless.
Even worse than no answer is giving the wrong answer. If the value of x contains pi, then you get incorrect results.
diff(x^3+π^4,x)|x = π
should result in 3*x^2|x=π which is 3*π^2. Instead, the line is interpreted as
diff(π^3+π^4,π)
and now π is treated as a variable. So the result is 3*π^2+4*π^3.
This issue came to light yesterday when I was checking my test answer key and entered this (using primes which is equivalent to diff).
(x^2*cos(x))''|x = π
evaluated to -2 instead of π^2-2. I assumed that I had made some silly mistake in my work by hand. It took several repeated attempts before I concluded that I was correct and the calculator was wrong.
I realize I could use the d/dx template which works correctly, but there is no template for 2nd or higher order derivatives and
(∂(∂(x^2*cos(x),x),x)|(x = π))
looks really awkward (especially in Textbook mode) and using the ' (primes) is so very convenient. It's really an order of operations issue in which |x=a should be applied AFTER the diff() command has completed, not BEFORE.
And it seems only natural that the HP "Prime" should be able to correctly work with "primes".