HP Forums
CAS problem with solution - 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: CAS problem with solution (/thread-3260.html)



CAS problem with solution - Teresa - 03-04-2015 09:14 PM

Hello all, I just bought a Prime and tried some things out. So I tried to get a solution in CAS mode for the equation lim X->infinity of (sqrt(X*X+2X+1)-sqrt(X*X)). I think the solution should be 1 but i get -infinity. [attachment=1720]
The plot of the function gives also 1. I tried it in the simulator (rev6975) and the calculator (rev.6975 CASvers. 1.1.2-11) same result.
What do i do wrong?
Thanks for your help Teresa


RE: CAS problem with solution - Mark Hardman - 03-04-2015 10:16 PM

(03-04-2015 09:14 PM)Teresa Wrote:  Hello all, I just bought a Prime and tried some things out. So I tried to get a solution in CAS mode for the equation lim X->infinity of (sqrt(X*X+2X+1)-sqrt(X*X)). I think the solution should be 1 but i get -infinity.
The plot of the function gives also 1. I tried it in the simulator (rev6975) and the calculator (rev.6975 CASvers. 1.1.2-11) same result.
What do i do wrong?
Thanks for your help Teresa

WolframAlpha would agree with your answer:

limit(v(x^2+2*x+1)-vx^2,x,8)

If you give the CAS just a little bit of help, it will give you the correct answer:

[Image: attachment.php?aid=1723]

It seems a bit odd that the CAS doesn't perform the trivial reduction of √x^2 = x. Perhaps it's reducing it to |x|. But even that shouldn't change the solution. Though, depending on the direction of the limit, the answer might be -1 or 1:

[Image: attachment.php?aid=1724]


RE: CAS problem with solution - Tim Wessman - 03-04-2015 10:20 PM

Interestingly enough, the equation as you have it written does actually work. The ^2 seems to be doing something strange here.

limit(√(x*x+2*x+1)-(√(x*x)),x,∞) ----> 1
limit(√(x^2+2*x+1)-(√(x^2)),x,∞) ----> -∞


RE: CAS problem with solution - Mark Hardman - 03-04-2015 10:38 PM

(03-04-2015 10:20 PM)Tim Wessman Wrote:  Interestingly enough, the equation as you have it written does actually work. The ^2 seems to be doing something strange here.

limit(√(x*x+2*x+1)-(√(x*x)),x,∞) ----> 1
limit(√(x^2+2*x+1)-(√(x^2)),x,∞) ----> -∞

The CAS must be reducing the √(x^2) to just x (rather than |x|). In that case, the limit as x--> -∞ would be -∞:

[Image: attachment.php?aid=1725]

But, regardless of which direction you force the limit it always gives the limit as x goes to -∞:

limit(√(x^2+2*x+1)-(√(x^2)),x,∞,-1) = -∞
limit(√(x^2+2*x+1)-(√(x^2)),x,∞,1) = -∞


RE: CAS problem with solution - Helge Gabert - 03-04-2015 11:08 PM

What are your cas settings? I get 1.

[attachment=1726]


RE: CAS problem with solution - Teresa - 03-04-2015 11:35 PM

My CAS settings are standard at least in the simulator (new install and reset). Is there an easy way to print those settings so i could post them?

Thanks for your replies. Learned new things about inputting formulas and that i did not too bad on my own. Even though i would not have spotted the problem when the answer would have been something positive.

Teresa


RE: CAS problem with solution - Helge Gabert - 03-04-2015 11:41 PM

My CAS settings are:

Angle radians
Number standard 12
Integers Decimal check
Simplify Minimum
Exact check
Use sqrt check
principal check
complex no check
use i check
increasing no check
recursive eval 5
recursive replace 1
recursive function 9
epsilon .00000000001
probability 1E-15
Newton 40

If you want, try it again with these settings. Do you still get -infinity?


RE: CAS problem with solution - Mark Hardman - 03-04-2015 11:42 PM

(03-04-2015 11:08 PM)Helge Gabert Wrote:  What are your cas settings? I get 1.

Excellent. If you check "Use i" in the CAS settings, you get the correct result.

But why would that make a difference?

Bernard?


RE: CAS problem with solution - Mark Hardman - 03-05-2015 12:12 AM

(03-04-2015 11:42 PM)Mark Hardman Wrote:  
(03-04-2015 11:08 PM)Helge Gabert Wrote:  What are your cas settings? I get 1.

But why would that make a difference?

To answer my own question.

With "Use i" unchecked:

simplify(√(x^2)) ----> |x|

With "Use i" checked:

simplify(√(x^2)) ----> x


RE: CAS problem with solution - parisse - 03-05-2015 08:31 AM

OK, I have found why it does not work: it's sqrt(x^2+2x+1) that is wrongly rewritten as -x-1, there is a missing renormalization of square roots in the series/limit code. You can see it if you do
partfrac(sqrt(x^2+2x+1)-sqrt(x^2))
I'm going to fix that before the end of the week in Xcas.
It was never spotted before because nobody tried limit with the difference of two square roots of perfect squares.


RE: CAS problem with solution - salvomic - 03-05-2015 08:37 AM

(03-05-2015 08:31 AM)parisse Wrote:  I'm going to fix that before the end of the week in Xcas.
always thank you! Smile

Quote:It was never spotted before because nobody tried limit with the difference of two square roots of perfect squares.

so, thanks to Teresa for having found it...

It works with "i" checked in the CAS Settings: what's, precisely, the difference with "i" checked or not, please?

Salvo


RE: CAS problem with solution - Helge Gabert - 03-05-2015 03:20 PM

What is the difference? Try factoring polynomials with complex solutions with "use i" checked and unchecked, e.g.

factor(x^4 +1), or

solve(x^4+1=0,x)


RE: CAS problem with solution - salvomic - 03-05-2015 03:33 PM

(03-05-2015 03:20 PM)Helge Gabert Wrote:  What is the difference? Try factoring polynomials with complex solutions with "use i" checked and unchecked, e.g.

factor(x^4 +1), or
solve(x^4+1=0,x)

yes, I see (it introduces complex calculation and i in the factorization), but in some cases it can be simplified, like with factor() above (not the solve following)...
With sqrt(X*X+2X+1)-sqrt(X*X) with or without, we have different results.

So, I really don't know what's better Smile


RE: CAS problem with solution - Helge Gabert - 03-05-2015 05:05 PM

I'd say it is better to have "use i" checked in CAS settings (at least for now, see parisse's note above).


RE: CAS problem with solution - salvomic - 03-05-2015 05:06 PM

(03-05-2015 05:05 PM)Helge Gabert Wrote:  I'd say it is better to have "use i" checked in CAS settings (at least for now, see parisse's note above).

in fact I keep it checked...


RE: CAS problem with solution - parisse - 03-05-2015 07:31 PM

Actually, I would recommend keeping i not checked unless you know exactly what you do, and run cfactor or csolve if you need complex factorization/solutions. Some operations behave really differently if complex mode is enabled, for example sqrt(x^2) becomes x instead of abs(x).


RE: CAS problem with solution - salvomic - 03-05-2015 07:57 PM

(03-05-2015 05:06 PM)salvomic Wrote:  in fact I keep it checked...

(03-05-2015 07:31 PM)parisse Wrote:  Actually, I would recommend keeping i not checked unless you know exactly what you do...

ok, I've unchecked it Smile
thank you, Parisse, for your precious advise!