Post Reply 
HP Prime undef for Limes. Maybe a Bug?
10-10-2018, 08:58 PM
Post: #1
HP Prime undef for Limes. Maybe a Bug?
Hello

I try to calculate the limit for a certain expression.
Unfortunately i dont get a result with the prime.

It should be -0.285

See here: https://www.symbolab.com/solver/limit-ca...D%5Cright)

Do i have to set some settings?
Or what can i do to solve the problem?

Thank you


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
10-10-2018, 09:32 PM
Post: #2
RE: HP Prime undef for Limes. Maybe a Bug?
Indeed, if you type:

limit((5-2*x)/(2*x^2-3*x-5),x,25/10)

you get the correct answer, but if you type:

limit((5-2*x)/(2*x^2-3*x-5),x,2.5)

you get undef.

   

-road
Find all posts by this user
Quote this message in a reply
10-11-2018, 06:47 AM
Post: #3
RE: HP Prime undef for Limes. Maybe a Bug?
THank you so much!

I never thought that decimal numbers could be a problem.
Is there an obvious reason to not allow decimal numbers or to force the user to enter it as a fraction?

Just for others: you can also use exact(2.5) instead of 25/10.
It should not be very hard for the HP-Team to implement the usage of the exact function behind the lim operation.

Anyway thank you very much Smile
Now i can do the excercises from our math lessons...
Find all posts by this user
Quote this message in a reply
10-11-2018, 07:01 AM
Post: #4
RE: HP Prime undef for Limes. Maybe a Bug?
Of course there is a reason:-)
The reason is that limit requires exact input to make simplifications (this is required here otherwise you get 0.0/0.0 or 0/0), with approx input, you could have rounding errors.
Find all posts by this user
Quote this message in a reply
10-11-2018, 07:05 AM
Post: #5
RE: HP Prime undef for Limes. Maybe a Bug?
Ok i see Smile

I also understand the requirement for exact inputs.
But sometimes, 2.5 is already exact as possible ^^

Here i would be happy if the HP would automatically convert the input to an exact fraction by themself.
Find all posts by this user
Quote this message in a reply
10-11-2018, 08:39 AM
Post: #6
RE: HP Prime undef for Limes. Maybe a Bug?
I got an answer in the oficcial HP Forum.
There is also an even simpler way to do this.

You first enter the "unexact" form of the lim with 2.5
Then press enter.
You get the undef answer
Now click on the lim in the history once and then press the a b/c key.
Now you see a converted version of the expression.
Click the converted expression and press enter twice.
Now you see the correct result.
Find all posts by this user
Quote this message in a reply
10-11-2018, 10:22 AM (This post was last modified: 10-11-2018 10:24 AM by Tim Wessman.)
Post: #7
RE: HP Prime undef for Limes. Maybe a Bug?
Glad my answer over there was helpful. Wink

Really is more just a way to quickly get to "exact" forms when you have decimals to ensure the cas behaves nicely when decimals are involved.

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
10-12-2018, 06:17 AM
Post: #8
RE: HP Prime undef for Limes. Maybe a Bug?
(10-11-2018 07:05 AM)blevita Wrote:  Ok i see Smile

I also understand the requirement for exact inputs.
But sometimes, 2.5 is already exact as possible ^^

Here i would be happy if the HP would automatically convert the input to an exact fraction by themself.

This is dangerous. I added automatic conversion of floating points that look like integers (I mean for example 2.0, that looks like the integer 2 especially in Home), but 2.5 is *never* considered to be exact in the CAS, it might represent any real in a small interval around 2.5. If 2.5 is exact in your problem, you must enter it as 5/2.
Find all posts by this user
Quote this message in a reply
10-12-2018, 03:11 PM
Post: #9
RE: HP Prime undef for Limes. Maybe a Bug?
You can always make a CAS program to do that, such as:

Code:
#cas
limit_exact(a,b,c,d):=
BEGIN
 c:=exact(c);
 retrun subst(limit(a,b,c,d),b=c);
END;
#end

limit_exact(((5-2*x)/(2*x^2-3*x-5)),x,2.5,0)

will return -2/7.

-road
Find all posts by this user
Quote this message in a reply
10-12-2018, 08:08 PM
Post: #10
RE: HP Prime undef for Limes. Maybe a Bug?
(10-12-2018 03:11 PM)roadrunner Wrote:  You can always make a CAS program to do that, such as:

Code:
#cas
limit_exact(a,b,c,d):=
BEGIN
 c:=exact(c);
 retrun subst(limit(a,b,c,d),b=c);
END;
#end

limit_exact(((5-2*x)/(2*x^2-3*x-5)),x,2.5,0)

will return -2/7.

-road

It works only if I subst
retrun
with
return
;-)
VPN
Find all posts by this user
Quote this message in a reply
10-13-2018, 07:04 PM
Post: #11
RE: HP Prime undef for Limes. Maybe a Bug?
Hi, roadrunner

On your limit_exact(), why is subst(...) needed ?
Also, I think limit_exact() had a bug:

f(x) := ((5-2x) + sin(5-2x)) / (2x^2 - 3x - 5)

limit(f(x), x, 5/2, 0) ==> -4/7

limit_exact(f(x), x, 2.5, 0) ==> undef
limit_exact(f(x), x, 5/2, 0) ==> undef

BTW, exact(...) may not always return exactly what you wanted.
Returned rationals were an approximation (based on config epsilon setting) of float.

Example, with epsilon = 1e-6, exact(500000.5) return 500001
Find all posts by this user
Quote this message in a reply
10-14-2018, 12:18 AM
Post: #12
RE: HP Prime undef for Limes. Maybe a Bug?
Hi Albert,

You are right. It's not working for your function, f(x). The call to limit in the function seems to be getting the second parameter incorrectly. I'm not sure why; it seems to be getting a "b" instead an "x"

I thought using the subst command fixed that, but apparently not in all cases.

-road
Find all posts by this user
Quote this message in a reply
10-14-2018, 01:42 AM (This post was last modified: 10-14-2018 02:46 AM by Albert Chan.)
Post: #13
RE: HP Prime undef for Limes. Maybe a Bug?
This work, but first argument had to be function of 1 argument ...

Code:
limit_exact(f, v, d) :=
begin
    local x; 
    assume(x, symbol);
    return limit(f(x), x, exact(v), d);
end;
Find all posts by this user
Quote this message in a reply
10-14-2018, 02:17 PM
Post: #14
RE: HP Prime undef for Limes. Maybe a Bug?
Check out this version:

Code:
#cas
limit_exact(a,b,c,d):=
BEGIN
 local x;
 assume(x,symbol);
 limit(subst(a,b=x),x,exact(c),d);
END;
#end

Now,

f(x) := ((5-2x) + sin(5-2x)) / (2x^2 - 3x - 5)
limit_exact(f(x), x, 2.5, 0) returns -4/7
limit_exact(f(t), t, 2.5, 0) also returns -4/7

It should work with any independent variable.

   

-road
Find all posts by this user
Quote this message in a reply
10-14-2018, 04:29 PM
Post: #15
RE: HP Prime undef for Limes. Maybe a Bug?
(10-14-2018 02:17 PM)roadrunner Wrote:  Check out this version:

Code:
#cas
limit_exact(a,b,c,d):=
BEGIN
 local x;
 assume(x,symbol);
 limit(subst(a,b=x),x,exact(c),d);
END;
#end

Now,

f(x) := ((5-2x) + sin(5-2x)) / (2x^2 - 3x - 5)
limit_exact(f(x), x, 2.5, 0) returns -4/7
limit_exact(f(t), t, 2.5, 0) also returns -4/7

It should work with any independent variable.



-road

Great! - No coyote can catch you!
Find all posts by this user
Quote this message in a reply
10-14-2018, 04:58 PM
Post: #16
RE: HP Prime undef for Limes. Maybe a Bug?
Hi, roadrunner

I suggest not using x for the symbolic local variable.
Preferably some name that will never be used ...

limit_exact(x + y, x, 1, 0) ==> y+1, OK
limit_exact(x + y, y, 1, 0) ==> 2, BAD
Find all posts by this user
Quote this message in a reply
10-15-2018, 12:04 PM
Post: #17
RE: HP Prime undef for Limes. Maybe a Bug?
(10-14-2018 04:58 PM)Albert Chan Wrote:  I suggest not using x for the symbolic local variable.
Preferably some name that will never be used ...

That's also true for the variables a, b, c, and d. I have run into that issue before with CAS programs.

-road
Find all posts by this user
Quote this message in a reply
10-16-2018, 09:35 PM
Post: #18
RE: HP Prime undef for Limes. Maybe a Bug?
(10-14-2018 04:58 PM)Albert Chan Wrote:  Hi, roadrunner

I suggest not using x for the symbolic local variable.
Preferably some name that will never be used ...

limit_exact(x + y, x, 1, 0) ==> y+1, OK
limit_exact(x + y, y, 1, 0) ==> 2, BAD

Code:

#cas
exact_limit(Expr,Var,Val,Dir):=
BEGIN
  LOCAL ¬x;
  assume(¬x,symbol);
  limit(subst(Expr,Var=¬x),¬x,exact(Val),Dir);
END;
#end

Try that with any example.
CHAR(172) is that "hook" character.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)