# HP Forums

Full Version: HP Prime undef for Limes. Maybe a Bug?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.

[attachment=6436]

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
Now i can do the excercises from our math lessons...
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.
Ok i see

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.
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.
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.

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.
(10-11-2018 07:05 AM)blevita Wrote: [ -> ]Ok i see

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.
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.

(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.

It works only if I subst
retrun
with
return
;-)
VPN

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
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.

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;```
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.

[attachment=6467]

(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.

Great! - No coyote can catch you!

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
(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.

(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.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :