HP Forums
I think there is a bug in CAS mode using "zeros", "solve" - 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: I think there is a bug in CAS mode using "zeros", "solve" (/thread-2566.html)



I think there is a bug in CAS mode using "zeros", "solve" - John P - 12-05-2014 09:25 PM

I think there is a bug in CAS mode using "zeros", "solve". I have fn: "-e^x*(-cos(x)+sin(x))" and I need zeros of that fn. I use zeros(-e^x*(-cos(x)+sin(x)),x) and I get the error: "Unable to isolate x in cos(x)-sin(x)" but when I use zeros(e^x*(-cos(x)+sin(x)),x) I get the zeros [1/4*Pi,5/4*Pi] and no error. What I've done I changed the minus sign in front of e to plus sign and there is no error. It looks like the "-" in front of "e" makes all the difference. On plot both functions have the same zeros. Using "solve" does the same thing.


RE: I think there is a bug in CAS mode using "zeros", "solve" - Helge Gabert - 12-05-2014 10:44 PM

Consider putting parenthesis around -e, like so

solve ((-e)^x*(-cos(x)+sin(x))=0,x) returns {1/4*pi, 5/4*pi}.


RE: I think there is a bug in CAS mode using "zeros", "solve" - John P - 12-05-2014 11:39 PM

(12-05-2014 10:44 PM)Helge Gabert Wrote:  Consider putting parenthesis around -e, like so

solve ((-e)^x*(-cos(x)+sin(x))=0,x) returns {1/4*pi, 5/4*pi}.

Yes, but I also use diff(e^x*cos(x),x) inside program and the differentiation gives me e^x*cos(x)-e^x*sin(x) and when I want zeros I get the same error so parenthesis will not solve my problem. Thanks.


RE: I think there is a bug in CAS mode using "zeros", "solve" - Helge Gabert - 12-06-2014 02:15 AM

I see the problem . . . if your exponential expression is an intermediate result in a program.


RE: I think there is a bug in CAS mode using "zeros", "solve" - John P - 12-06-2014 04:13 AM

(12-06-2014 02:15 AM)Helge Gabert Wrote:  I see the problem . . . if your exponential expression is an intermediate result in a program.

Yes, but even though it is a bug in spite what you have proposed as a band aid.


RE: I think there is a bug in CAS mode using "zeros", "solve" - Helge Gabert - 12-06-2014 04:41 AM

I don't disagree with you . . . it seems a bug to me as well.

Try collect() on the intermediate expression, i.e.

collect(e^x*cos(x)-e^x*sin(x)) returns e^x*(cos(x)-sin(x)).

Okay, now try solve() or zeros(). That works, but returns [-3/4*pi 1/4*pi]. ???


RE: I think there is a bug in CAS mode using "zeros", "solve" - John P - 12-06-2014 05:31 AM

(12-06-2014 04:41 AM)Helge Gabert Wrote:  I don't disagree with you . . . it seems a bug to me as well.

Try collect() on the intermediate expression, i.e.

collect(e^x*cos(x)-e^x*sin(x)) returns e^x*(cos(x)-sin(x)).

Okay, now try solve() or zeros(). That works, but returns [-3/4*pi 1/4*pi]. ???

Funny thing. When I do what you propose in CAS on the command line: differentiating "e^x*cos(x)" and then collecting I get e^x(cos(x)-sin(x)) and it works but when I do the same thing but in program and collect the 1st derivative I get -e^x(-cos(x)+sin(x)) and then the error using "zeros" or "solve". I did return(fd) after collecting in the program. Lets hope that somebody from HP Prime group reads this post and maybe they will fix it someday. Just for curiosity I have iPod 5g and on it PocketCAS and it works without a hitch so the problem must be related to HP Prime implementation of xCAS not to xCAS itself. Thank you for your time.


RE: I think there is a bug in CAS mode using "zeros", "solve" - parisse - 12-06-2014 04:03 PM

solve/zeros/etc. can handle polynomial equations and equations that the system can rewrite as a polynomial equation. The problem is rewrite the expression as a polynomial equation. From one version to another, I try to improve the rewriting rules but sometimes it fails...


RE: I think there is a bug in CAS mode using "zeros", "solve" - John P - 12-06-2014 05:48 PM

(12-06-2014 04:03 PM)parisse Wrote:  solve/zeros/etc. can handle polynomial equations and equations that the system can rewrite as a polynomial equation. The problem is rewrite the expression as a polynomial equation. From one version to another, I try to improve the rewriting rules but sometimes it fails...

Yes, I understand. It works in PocketCAS with no problem but in HP Prime there is a problem. Both PosketCAS and HP Prime use the same xCAS as I understand.