Post Reply 
DB48X: HP48-like RPL implementation for DM42
07-31-2023, 04:18 PM
Post: #62
RE: DB48X: HP48-like RPL implementation for DM42
(07-31-2023 02:46 PM)TomC Wrote:  Thank you!

(07-29-2023 06:30 PM)c3d Wrote:  To a large extent, yes, including symbolic complex numbers. See https://youtu.be/I5jgLzw_0-o?t=1780.

Well, I noticed during the demo recording a number of weird behaviours, like `conj` giving me bogus results. The bottom line is that I completely broke the polar representation when I added support for angles modes in it.

Below are the details, since you care about complex numbers.

DB48X has two representation for complex numbers, polar and rectangular. Initially, polar had the angles in radians, but this causes rounding errors. So I switched to fractions of pi, which are exact. In other words, 3i in polar form is now represented as (3, 1), where "3" is the modulus and 1 is means an argument of 1xpi. I correctly implemented the parsing and rendering of that, but I failed to realize that many places, notably the implementation of re() and im() for the polar form, relied on the arg() function returning radians and not the current angle mode or fractions of pi or whatever.

There are some subtleties to this. For example, exp(a+ib) is computed using the polar form as mod = exp(a), arg = b... except that in that case, b really has to be "real" radians, not fractions of pi or degrees. When I tried to fix these cases, I noticed that I would often get approximate results on fairly simple cases, e.g. the real part of a polar on the imaginary axis would not be exactly zero, because the cos of 90 degrees after radian conversion was inexact. So a lot of tiny details to adjust to make it work better.

I did most of these fixes yesterday late (and early this morning, as in about 1AM). But I still need to post a release with these fixes in. That will be 0.4.1. Maybe tonight, if my testing of this problem does not expose more rabbit holes to follow.

There were many other glitches that I noticed in the demo video. Most of them are much simpler fixes than this semi-pervasive angle unit problem, and do not impact complex numbers. Like the month is displayed off-by-one...
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: DB48X: HP48-like RPL implementation for DM42 - c3d - 07-31-2023 04:18 PM
DB48X v0.4.8 is out - c3d - 10-22-2023, 11:31 PM
Release v0.5.0: Statistics and flags - c3d - 11-20-2023, 08:57 AM
v0.6.5: Minor bug fixes - c3d - 02-11-2024, 11:23 PM
Release 0.7.1 "Whip" - Bug fixes - c3d - 03-04-2024, 12:46 AM
DB48X v0.7.4 release is out - c3d - 04-14-2024, 03:05 PM
DB48X v0.7.6: Solving menu - c3d - 05-13-2024, 12:04 AM



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