Post Reply 
HP-71B Enhanced Math LEX
01-27-2020, 12:42 PM
Post: #17
RE: HP-71B Enhanced Math LEX
(01-27-2020 11:35 AM)Albert Chan Wrote:  
(01-27-2020 08:05 AM)J-F Garnier Wrote:  I understand that the alternate formula (x+y)*(x-y) saves a multiplication, but does it guarantee that the result will be *always* better?

Yes, I believe (x*x-y*y) is better calculated as (x+y)*(x-y)

|x| + |y| always accurate to whatever the system precision (unless it overflows)
|x| − |y| is exact if ratio of |x| and |y| = 1/2 to 2. (unless it underflows)
(see Kahans Miscalculating Area and Angles of a Needle-like Triangle, Section 4, Why Cancellation Cannot Hurt)

I tend to agree with you. (x+y)*(x-y) is better than (x*x-y*y) especially when x and y are close.
For instance:
>X=PI @ Y=PI-1E-11
>Z=(X,Y)
>Z*Z
(6.283E-11,19.7392088021)
>(X+Y)*(X-Y)
6.28318530717E-11
The last formula gives 8 more significant digits for the real part.
Note, however, than in this particular case, the involution formula gives an even worst result:
>Z^(2,0)
(6.27015817311E-11,19.7392088021)

I checked the x^2 (or SQ in RPL) function on HP Saturn-based machines up to the 49G+ and they all seem to use the x*x-y*y formula.
So I will refrain from implementing the (x+y)*(x-y) approach in the 71 Math 2 LEX, my goal is to align its performance with other machines of the time (75C, 28S, 42S), and the Z^2 case implemented as Z*Z already provides an interesting improvement.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP-71B Enhanced Math LEX - J-F Garnier - 01-09-2020, 07:30 PM
RE: HP-71B Enhanced Math LEX - rprosperi - 01-09-2020, 10:36 PM
RE: HP-71B Enhanced Math LEX - charger73 - 01-10-2020, 07:23 AM
RE: HP-71B Enhanced Math LEX - Albert Chan - 01-10-2020, 04:44 PM
RE: HP-71B Enhanced Math LEX - Albert Chan - 01-10-2020, 05:01 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 01-10-2020, 05:40 PM
RE: HP-71B Enhanced Math LEX - Albert Chan - 01-10-2020, 06:29 PM
RE: HP-71B Enhanced Math LEX - Erwin - 01-13-2020, 06:10 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 01-13-2020, 07:13 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 01-26-2020, 10:54 AM
RE: HP-71B Enhanced Math LEX - Albert Chan - 01-26-2020, 03:08 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 01-27-2020, 08:05 AM
RE: HP-71B Enhanced Math LEX - Albert Chan - 01-27-2020, 11:35 AM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 01-27-2020 12:42 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 02-12-2020, 07:55 AM
RE: HP-71B Enhanced Math LEX - rprosperi - 02-12-2020, 01:55 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 02-14-2020, 12:23 PM
RE: HP-71B Enhanced Math LEX - rprosperi - 02-14-2020, 03:04 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 03-19-2020, 07:30 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 04-27-2020, 09:42 AM
RE: HP-71B Enhanced Math LEX - Erwin - 04-27-2020, 04:50 PM
RE: HP-71B Enhanced Math LEX - Albert Chan - 03-17-2021, 09:00 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 03-18-2021, 08:22 AM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 08-08-2020, 09:37 AM
RE: HP-71B Enhanced Math LEX - Paul Dale - 08-09-2020, 11:15 AM
RE: HP-71B Enhanced Math LEX - John Keith - 08-09-2020, 02:16 PM
RE: HP-71B Enhanced Math LEX - Erwin - 08-10-2020, 08:21 PM
RE: HP-71B Enhanced Math LEX - rprosperi - 08-10-2020, 09:42 PM
RE: HP-71B Enhanced Math LEX - Erwin - 08-11-2020, 02:47 PM
RE: HP-71B Enhanced Math LEX - Erwin - 08-11-2020, 05:06 PM
RE: HP-71B Enhanced Math LEX - Gene - 08-09-2020, 01:49 AM
RE: HP-71B Enhanced Math LEX - Paul Dale - 08-09-2020, 10:10 AM
RE: HP-71B Enhanced Math LEX - John Keith - 08-09-2020, 01:04 PM
RE: HP-71B Enhanced Math LEX - Erwin - 08-13-2020, 07:35 AM
RE: HP-71B Enhanced Math LEX - Erwin - 08-13-2020, 04:00 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 08-14-2020, 07:53 AM
RE: HP-71B Enhanced Math LEX - Erwin - 08-20-2020, 08:11 PM
RE: HP-71B Enhanced Math LEX - Erwin - 08-21-2020, 05:34 PM
RE: HP-71B Enhanced Math LEX - J-F Garnier - 09-27-2020, 06:25 PM



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