HP Prime crashes in Function and Graph 3D App.
11-17-2020, 09:33 PM (This post was last modified: 11-17-2020 09:41 PM by lyuka.)
Post: #1
 lyuka Junior Member Posts: 48 Joined: May 2014
HP Prime crashes in Function and Graph 3D App.
Hi guys

I encountered a wired behavior of the HP Prime emulator in the Function App.
With a program named 'cs' in Function App. is invisible, however,
the cursor moves as if it's on the correct plot and the numerical plot is OK.
The formula -- replaced a constant to Y variable -- is OK in the Graph 3D App.
On the phisical HP Prime BS, it shows visible plot -- no problem.

And one other problem is calling a CAS version of the program (LW0C) from Home version of a program crashes on both the emulator and the Physical HP Prime.

What is wrong? usage? or an any kind of bug?

Code:
 EXPORT cs(Ir, Tj, Rd) // cs -- current source  // Ir : reference current // Tj : junction temperature (in Centigrade) // Rd : degeneration resistance BEGIN   LOCAL k, q, Vt;   k := 1.380649e-23; // Boltzmann constant   q := 1.602176634e-19; // elementary charge   Vt := k * (273.15 +  Tj) / q; // Thermal voltage   IF Rd == 0 THEN return Ir; END;   return Vt * LW0(Ir * Rd / Vt) / Rd; END;

Code:
 //LW0 - Principal branch of the Lambert W function //Rev.1.40 (Nov. 12, 2020) (c) Takayuki HOSODA (aka Lyuka) //Acknowledgments: Thanks to Albert Chan for his informative suggestions. EXPORT LW0(x) BEGIN   LOCAL y, p, s, t;   LOCAL q, r;   HComplex := 1; // Enable complex result from a real input.   r := 1 / e;   s := simplify(x + r);   IF s == 0 THEN return -1; END;   q := e - sqrt(2) - 1;   y := ln(r + sqrt((r + r) * s) + q * s); // approximation near x=-1/e   r := MAXREAL;   REPEAT     p := y;     q := r;     t := exp(y);     s := y * t;     t := (1 + 0.5 * y) * (s + x) + t;     IF (0 == t) THEN break; END;     y := y - (y + 1) * (s - x) / t; // Halley's method     r := abs(y - p); // correction radius;   UNTIL 0 == r OR q <= r; // convergence check   return p; END;

HP Prime Graphing Calculator
Software Version: 2.1.14425 (2020 01 16)
Hardware Version: Emu
CAS Version: 1.5.0
Operating System: Windows 7 SP 1 (6.1)

P.S.
Atteched file is the backup of the Emulator under test.

P.P.S.
Some conditional test results.
1) A home program 'cs' that uses 'LW0' home program is OK in Graph 3D app, however, in Function App. it shows invisible plot but its value at the cursor is OK and the Function Numeric View is OK as well.
2) A home program 'csB' that uses 'LW0C' CAS program crashes in Graph 3D App. and in Function App.
3) A CAS program 'csBW' that uses LW0C CAS program is OK and plots well in both Function App. and Graph 3D App.
4) 'cs' is OK in Function App. and in Graph 3D App. with pysical HP Prime G2.
5) 'csB' is OK in Function App. with pysical HP Prime G2, however, it crashes in Graph 3D App. to show "... had a problem and will reboot in 3 seconds".
6) 'csBW' is OK in Function App. in Graph 3D App. with pysical HP Prime G2.
11-18-2020, 12:12 PM
Post: #2
 Albert Chan Senior Member Posts: 2,516 Joined: Jul 2018
RE: HP Prime crashes in Function and Graph 3D App.
Hi lyuka

After some usage, I was unable to purge variable y, even after a restart

CAS> restart
CAS> [y, z] := [1, 2]
CAS> purge(y,z) ﻿ ﻿ ﻿ ﻿ → "No such variable y", 2
CAS> [y, z] ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ → [1, z]

To "fix" it, I had to do a hard reset (via. menu Calculator, Reset)

Code:
//LW0 - Principal branch of the Lambert W function     ...     r := abs(y - p); // correction radius;   UNTIL 0 == r OR q <= r; // convergence check   return p; END;

Off topics: Why did you change convergence check ?
q <= r should be (q < 1 and q <= r), to avoid false positives.
11-18-2020, 02:02 PM
Post: #3
 Joe Horn Senior Member Posts: 1,998 Joined: Dec 2013
RE: HP Prime crashes in Function and Graph 3D App.
The purge command only purges CAS variables, not Home variables. If you create a Home variable called 'y', you can delete it in several ways:

1: DelHVars("y")
2: Vars, User, User Variables, then highlight y and backspace it (it will ask if you're sure).
3: Mem / User Variables / up / highlight y and backspace it (this method does not ask if you're sure).

<0|ɸ|0>
-Joe-
11-18-2020, 02:54 PM
Post: #4
 lyuka Junior Member Posts: 48 Joined: May 2014
RE: HP Prime crashes in Function and Graph 3D App.
Hi Albert

As the HP Prime emulator crashes so offten, I'm getting tired of it.

(11-18-2020 12:12 PM)Albert Chan Wrote:  Off topics: Why did you change convergence check ?
q <= r should be (q < 1 and q <= r), to avoid false positives.

In short, I had some convergence problems.

-- off topic But I'm sorry it's getting longer --
Talking about the convergence, the condition check
(q < 1 and q <= r)
assume the convergence radius become smaller than 1.

However, in some convergence tests, the radius of convergence never fell below 1,
and sometimes stayed well above 9 for some very large complex inputs.

If the calculation numerically oscillates but the radius does not change in large value,
then the calculation converges within the accuracy of the calculator, but the program cannot finish the calculation.
And it happened, but unfortunately I lost the value of that special case.

Instead of using the iteration counter, I changed the initial radius to MAXREAL or Infinity to ensure that the calculation ends.

As long as using Halleys method or Householders method of order 4 with my approximation as the initial guess,
the convergence at the first stage is monotonous and I think a proof* is needed,
but no false positives occur. No false jumps to other branches than W0 will occur.

* a Proof -- I think it's necessary, but it's beyond my (complex analysis) capabilities.
11-18-2020, 06:48 PM (This post was last modified: 11-18-2020 07:16 PM by Albert Chan.)
Post: #5
 Albert Chan Senior Member Posts: 2,516 Joined: Jul 2018
RE: HP Prime crashes in Function and Graph 3D App.
(11-18-2020 02:54 PM)lyuka Wrote:  However, in some convergence tests, the radius of convergence never fell below 1,
and sometimes stayed well above 9 for some very large complex inputs.

For small x, W e^W ≈ W = x
For large x, W e^W ≈ e^W = x ⇒ W(x) ≈ log(x)

Even with |x| = 10^1000, |W| ≈ 2300, not a huge number.
-> W radius of convergence will fall below 1.

Quote:And it happened, but unfortunately I lost the value of that special case.

You might mistakenly using the same test for e^W
For e^W, we need to convert back to radius of convergence of W, not e^W

//eW : exponential of Lambert W0 function

> r := abs(y/p);
> IF r < 1 THEN r := 1/r; END; // e^(W correction radius)
> UNTIL y == p OR (q < e and q <= r); // convergence check
11-18-2020, 09:34 PM
Post: #6
 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: HP Prime crashes in Function and Graph 3D App.
Out of curiosity, what firmware are you using?

Graph 3D | QPI | SolveSys
 « Next Oldest | Next Newest »

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