HP Prime undef for Limes. Maybe a Bug? - 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: HP Prime undef for Limes. Maybe a Bug? (/thread-11569.html) HP Prime undef for Limes. Maybe a Bug? - blevita - 10-10-2018 08:58 PM 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-calculator/%5Clim_%7Bx%5Cto2.5%7D%5Cleft(%5Cfrac%7B%5Cleft(5-2x%5Cright)%7D%7B2x%5E%7B2%7D-3x-5%7D%5Cright) Do i have to set some settings? Or what can i do to solve the problem? Thank you RE: HP Prime undef for Limes. Maybe a Bug? - roadrunner - 10-10-2018 09:32 PM 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] -road RE: HP Prime undef for Limes. Maybe a Bug? - blevita - 10-11-2018 06:47 AM 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... RE: HP Prime undef for Limes. Maybe a Bug? - parisse - 10-11-2018 07:01 AM 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. RE: HP Prime undef for Limes. Maybe a Bug? - blevita - 10-11-2018 07:05 AM 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. RE: HP Prime undef for Limes. Maybe a Bug? - blevita - 10-11-2018 08:39 AM 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. RE: HP Prime undef for Limes. Maybe a Bug? - Tim Wessman - 10-11-2018 10:22 AM Glad my answer over there was helpful. 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. RE: HP Prime undef for Limes. Maybe a Bug? - parisse - 10-12-2018 06:17 AM (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. RE: HP Prime undef for Limes. Maybe a Bug? - roadrunner - 10-12-2018 03:11 PM 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 RE: HP Prime undef for Limes. Maybe a Bug? - CyberAngel - 10-12-2018 08:08 PM (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 RE: HP Prime undef for Limes. Maybe a Bug? - Albert Chan - 10-13-2018 07:04 PM 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 RE: HP Prime undef for Limes. Maybe a Bug? - roadrunner - 10-14-2018 12:18 AM 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 RE: HP Prime undef for Limes. Maybe a Bug? - Albert Chan - 10-14-2018 01:42 AM 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;``` RE: HP Prime undef for Limes. Maybe a Bug? - roadrunner - 10-14-2018 02:17 PM 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] -road RE: HP Prime undef for Limes. Maybe a Bug? - CyberAngel - 10-14-2018 04:29 PM (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! RE: HP Prime undef for Limes. Maybe a Bug? - Albert Chan - 10-14-2018 04:58 PM 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 RE: HP Prime undef for Limes. Maybe a Bug? - roadrunner - 10-15-2018 12:04 PM (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 RE: HP Prime undef for Limes. Maybe a Bug? - CyberAngel - 10-16-2018 09:35 PM (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.