Post Reply 
HP Prime complex division problem in CAS
11-18-2020, 11:51 PM (This post was last modified: 11-20-2020 03:05 AM by lyuka.)
Post: #1
HP Prime complex division problem in CAS
Hi guys

I found a problem with CAS -- Maybe a bug in HP PRIME -- It is that CAS returns undef-undef*i in somewhat large complex-to-complex divisions, such as:

(1.e154 + 2.e154 * i) / (2.e154 + 1.e154 * i) → undef-undef * i

If it happens in the program, the calculator will finish the calculation without warning, regardless of whether it is a physical calculator or an emulator.
Also, if you try to PRINT a variable which contains it -- undef-undef*i --, the calculator will crash.

[Image: complex-division-NG-in-CAS.png]
The behavior did not change with the CAS setting flag "Exact".

If complex division is implemented in the following way in CAS, it makes sense that complex division can cause problems at half the size of MAXREAL.
Code:
complex cdiv(complex x, complex y)  {
    complex z;
    z.r = (x.r * y.r + x.i * y.i) / (y.r * y.r + y.i * y.i);
    z.i = (x.i * y.r - x.r * y.i) / (y.r * y.r + y.i * y.i);
    return z;
}

On the other hand, at home, it is calculated correctly up to near MAXREAL.
[Image: complex-division-OK-at-Home.png]

-- HP Prime Graphics Calculator Third Edition: December 2017, p.533 --
MAXREAL
Returns the maximum real number that the HP Prime calculator is capable of representing in Home and CAS
views: In the CAS, MAXREAL=1.79769313486*10^308 In Home view, MAXREAL=9.99999999999E499
--

Lyuka
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP Prime complex division problem in CAS - lyuka - 11-18-2020 11:51 PM



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