HP Forums

Full Version: Bugs about simpilfy function in the cas
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I have found a bug of the simplify function, just try simplify sqrt((sqrt(46)+1)/2) and you'll find the bug.
(09-03-2017 01:31 PM)wangchong01 Wrote: [ -> ]Hello, I have found a bug of the simplify function, just try simplify sqrt(sqrt(46)+1) and you'll find the bug.

Please tell us what firmware version you're using, and what result you're getting. Six HP Primes, all with different firmware versions in them, all return sqrt(sqrt(46)+1), which as far as I can tell is what should be expected. I'm assuming that you're in CAS view with default settings, of course.
I'm sorry that I typed the wrong expression. It should be sqrt((sqrt(46)+1)/2) instead of sqrt(sqrt(46)+1).
Woo hoo! Wow, that's an interesting bug! It returns this amazing result:

√2*√(√72639657109063867246+1256631601)/70898

My checking shows that the bug apparently was introduced sometime in early 2015 and has been there ever since, because it's not in rev 6975 (2014 12 3) or earlier, but it is in rev 7829 (2015 4 27) and later.
if you do an approx() on the original and the "simplified" answer, you get the same result, so it's correct, although not really simplified.... :-)
The CAS also will return "simplified" results even if the Simplify setting is "None."

For an example, you can experiment with the following function, (especially interesting to calculus students), by cycling through the CAS settings for Simplify: {None, Minimum, Maximum}:

[CAS] Exact[✔]
factor(((x^2-4)/(x^2+x-6))) ==> (x+2)/(x+3)

[CAS] Exact[ ]
factor(((x^2-4)/(x^2+x-6))) ==> (x-2)*(x+2)/((x-2)*(x+3))

The domain is not continuous, (at x=2), but the factor (x-2) gets masked for all simplify settings, (with Exact checked). There are work-a rounds:

factor(x^2-4) / factor(x^2 + x -6) ==> (x-2)*(x+2)/((x-2)*(x+3))

or uncheck the Exact setting:
factor(((x^2-4)/(x^2+x-6))) ==> (x-2.)*(x+2.)/((x-2.)*(x+3.))

Shouldn't a Simplify setting of "None" fully factorize the functions, and not mask the (x-2) term? Including all the singularities is important, for this kind of example. Attention to the subject matter at the student level can be difficult enough, and requiring special settings, or command variations, only diverts attention from the specific learning environment.
(09-11-2017 11:32 AM)DrD Wrote: [ -> ]The CAS also will return "simplified" results even if the Simplify setting is "None."

For an example, you can experiment with the following function, (especially interesting to calculus students), by cycling through the CAS settings for Simplify: {None, Minimum, Maximum}:

[CAS] Exact[✔]
factor(((x^2-4)/(x^2+x-6))) ==> (x+2)/(x+3)

[CAS] Exact[ ]
factor(((x^2-4)/(x^2+x-6))) ==> (x-2)*(x+2)/((x-2)*(x+3))

The domain is not continuous, (at x=2), but the factor (x-2) gets masked for all simplify settings, (with Exact checked). There are work-a rounds:

factor(x^2-4) / factor(x^2 + x -6) ==> (x-2)*(x+2)/((x-2)*(x+3))

or uncheck the Exact setting:
factor(((x^2-4)/(x^2+x-6))) ==> (x-2.)*(x+2.)/((x-2.)*(x+3.))

Shouldn't a Simplify setting of "None" fully factorize the functions, and not mask the (x-2) term? Including all the singularities is important, for this kind of example. Attention to the subject matter at the student level can be difficult enough, and requiring special settings, or command variations, only diverts attention from the specific learning environment.

The simplify will ignore approx expressions such as (1.1*x)/x. You can you normal() to "simplify" the function and then simplify().
Yes so sqrt() is not behaving well in general and especially with nested sqrt(). This has been an going challenge for a long time, e.g. try to simplify nested radicals of complex numbers and it gets eve worse, like:

simplify(√((1+i)+√(1+i))) results something horrendous.

Search the forum for some more references...
(09-11-2017 06:53 AM)Joe Horn Wrote: [ -> ]Woo hoo! Wow, that's an interesting bug! It returns this amazing result:

√2*√(√72639657109063867246+1256631601)/70898

My checking shows that the bug apparently was introduced sometime in early 2015 and has been there ever since, because it's not in rev 6975 (2014 12 3) or earlier, but it is in rev 7829 (2015 4 27) and later.
Must be some missing factorization on the Prime, because 1256631601=35449^2 and sqrt(72639657109063867246)=sqrt(46)*1256631601
(09-11-2017 01:27 PM)wangchong01 Wrote: [ -> ]
(09-11-2017 11:32 AM)DrD Wrote: [ -> ][CAS] Exact[✔]
factor(((x^2-4)/(x^2+x-6))) ==> (x+2)/(x+3)

[CAS] Exact[ ]
factor(((x^2-4)/(x^2+x-6))) ==> (x-2)*(x+2)/((x-2)*(x+3))

Shouldn't a Simplify setting of "None" fully factorize the functions, and not mask the (x-2) term?

The simplify will ignore approx expressions such as (1.1*x)/x. You can you normal() to "simplify" the function and then simplify().

The objective is to quickly obtain a fully factorized result, such as might be needed by a student interested in evaluating continuity, and limits. I was hoping to show that the machine is making work, instead of saving work, by requiring the extra student interaction to satisfy the machine, in order to reach the objective.

I'm not sure I have a valid concern here. It may well be that the (x-2) term in numerator and denominator are 'artificial' singularities. I see them as necessary for domain clarity. Diverting attention from the study of a problem, to a study of the machine, may find students frustrated with both; and educators frustrated with the machine.

-Dale-
(09-12-2017 11:17 AM)parisse Wrote: [ -> ]Must be some missing factorization on the Prime, because 1256631601=35449^2 and sqrt(72639657109063867246)=sqrt(46)*1256631601
Fixed in source code.
f:=(3*x^2-4)^100;
simplify(diff(f));
(09-13-2017 02:43 PM)DrD Wrote: [ -> ]f:=(3*x^2-4)^100;
simplify(diff(f));
I don't see any bug, simplify expands polynomials. Run factor to get a more readable expression.
(09-13-2017 06:05 PM)parisse Wrote: [ -> ]
(09-13-2017 02:43 PM)DrD Wrote: [ -> ]f:=(3*x^2-4)^100;
simplify(diff(f));
I don't see any bug, simplify expands polynomials. Run factor to get a more readable expression.

The example (above) has to do with "more readable expression." Somehow "Simplify" and the result obtained, don't translate well.
Then it's a misunderstanding of what simplify does.
Clearly so. Even more so, when one reads the provided Help description, and reviews the provided Help example. When I encountered the problem above, and the returned "simplification'," it was then I realized, " I have yet to learn the definition of simple."

One of the most difficult aspects (for me), especially of American language, is how frequently we use the same word for multiple meanings. Politicians, news reporters, and children are great at this.

At least I know what is meant by simplify in this case! What seems (sort of) ironic is that using the expand() command returns the same thing. Yet expand seems (to me) so much more descriptive of the result than simplify. Almost to the point of being antonyms.

((simplify(f'))==(expand(f'))); ==> 1
They are not synonyms in general. Unlike simplify, expand does not search relations between non rational variables. By default, expand just expands neg, product and power. Try for example with sin(2x)/sin(x).
Another bug about simplify:
simplify(asin(a*b)/abs(a))
What did you expect?
Reference URL's