The Museum of HP Calculators

HP Forum Archive 19

[ Return to Index | Top of Index ]

Question about programming the HP-71B
Message #1 Posted by Namir on 26 Nov 2010, 9:00 p.m.

Hi All,

I am using an HP-71B with a MATH Pac module. This module supports the COMPLEX type. How can I declare a SUB subroutine to have a parameter with the COMPLEX type?

Thanks!

Namir

      
Re: Question about programming the HP-71B
Message #2 Posted by Jerry Raia on 26 Nov 2010, 9:27 p.m.,
in response to message #1 by Namir

Here is one way:

Main Program

10 COMPLEX A ! declare type
20 A=-5
30 CALL TESTSUB(A) ! call and pass the variable

Sub Program

10 SUB TESTSUB(A)  ! sub program with variable passed
20 DISP SQRT(A)  ! take the sqrt of the negative number
you should get (0,2.2360679775)

Edited: 26 Nov 2010, 9:29 p.m.

            
Re: Question about programming the HP-71B
Message #3 Posted by Namir on 27 Nov 2010, 6:10 a.m.,
in response to message #2 by Jerry Raia

Hi!

I am using the EMU71 (since I am away from home) and get the following value!

(0,5)

Matlab gives me your answer of 0 + 2.2361i.

Any explanation why I am getting (0,5) with EMU71?

Namir

Edited: 27 Nov 2010, 6:11 a.m.

                  
Re: Question about programming the HP-71B
Message #4 Posted by Jerry Raia on 27 Nov 2010, 7:17 a.m.,
in response to message #3 by Namir

That's odd, I just tried it on EMU71 and got the correct result.

                        
Re: Question about programming the HP-71B
Message #5 Posted by Egan Ford on 27 Nov 2010, 12:53 p.m.,
in response to message #4 by Jerry Raia

Me too.

                              
Re: Question about programming the HP-71B
Message #6 Posted by Namir on 27 Nov 2010, 3:47 p.m.,
in response to message #5 by Egan Ford

When I type VER$ on my EMU71 I get:

HP71:2CDCC MATH:1A JPC:Ex HPIL:1B HELP:C FACTR:A STRU:A RCPY:E

The EMU71.INI file is:

; emu71.ini        Emu71 initialisation file
;
[MODULES]
; 10 softwired modules max., plus 1 hardwired module
; main RAM in port 0 only
; port(1-5) type(ROM,RAM,HRD) size(Ko) file
0 RAM 32 ram00.bin
1 ROM 16 hpilrom.bin
2 ROM 16 mathrom.bin
3 ROM 32 jpcromx.bin
5 RAM 32 iram50.bin
;
[DEVICES]
DISPLAY
HDRIVE1
HDRIVE2
DOSLINK
LPRTER1

Maybe the above info helps?

                  
Re: Question about programming the HP-71B
Message #7 Posted by Katie Wasserman on 27 Nov 2010, 4:10 p.m.,
in response to message #3 by Namir

On a real 71b with Math ROM I can confirm that the answer is (0,2.236...).

                        
Re: Question about programming the HP-71B
Message #8 Posted by Namir on 27 Nov 2010, 4:23 p.m.,
in response to message #7 by Katie Wasserman

Sounds like an emulator bug, given the INI configuration I am using. The good news is that the polynomial-root program I wrote (which heavily uses complex math and complex variables and arrays) works just fine!!

Edited: 27 Nov 2010, 4:24 p.m.

                        
Re: Question about programming the HP-71B
Message #9 Posted by Karl Schneider on 27 Nov 2010, 4:33 p.m.,
in response to message #7 by Katie Wasserman

Quote:
On a real 71b with Math ROM I can confirm that the answer is (0,2.236...).

I'll second Katie. I got the answer (0,2.2360679775) by modifying Jerry's program as follows and hitting "RUN" to execute:

10 COMPLEX A 
20 A=(-5,0)
30 CALL TESTSUB(A) 
40 SUB TESTSUB(A) 
50 DISP SQRT(A)  

ADDENDUM: The following program also works. It proves passage of the complex-valued variable, undeclared in the subroutine.

10 COMPLEX A 
20 A=(-5,0)
30 CALL TESTSUB(A)
35 END 
40 SUB TESTSUB(B) 
50 DISP SQRT(B)  

-- KS

Edited: 28 Nov 2010, 3:38 p.m. after one or more responses were posted

                              
Re: Question about programming the HP-71B
Message #10 Posted by Namir on 27 Nov 2010, 5:26 p.m.,
in response to message #9 by Karl Schneider

I typed you code, line for line, and got (0,5).

                                    
(deleted post)
Message #11 Posted by deleted on 27 Nov 2010, 6:14 p.m.,
in response to message #10 by Namir

This Message was deleted. This empty message preserves the threading when a post with followup(s) is deleted. If all followups have been removed, the original poster may delete this post again to make this placeholder disappear.

                                          
Re: Question about programming the HP-71B
Message #12 Posted by Namir on 27 Nov 2010, 7:31 p.m.,
in response to message #11 by deleted

i will certainly test the program with a real HP-71B and Math rom by the end of the week, when i am back home.

                                                
Re: Question about programming the HP-71B
Message #13 Posted by geoff quickfall on 28 Nov 2010, 5:25 p.m.,
in response to message #12 by Namir

Both real versions of my HP71B with math roms give the correct answer:(0,2.236...)

Haven't tried the emulator yet.

Cheers,

HP71:2cdcc clk:ms hpil:1b math:1a

HP71:1bbbb clk:a hpil:1b math:1a

Edited: 28 Nov 2010, 5:31 p.m.

            
Re: Question about programming the HP-71B
Message #14 Posted by Namir on 27 Nov 2010, 4:19 p.m.,
in response to message #2 by Jerry Raia

My main goal was to write SUB routines that have parameters that are complex arrays and variables. The good news is that the approach you suggest WORKS!! It seems that with the MATH module, the HP-71B does not require a special syntax for COMPLEX parameters. When the arguments passed to the SUB routines are complex, the routine treats them as COMPLEX within its scope.

I was trying to implement the Aberth–Ehrlich method that simultaneously solves for all the roots (real and complex) of polynomials. The good news is that the implementation works!

Namir

Edited: 27 Nov 2010, 6:05 p.m.

                  
Re: Question about programming the HP-71B
Message #15 Posted by Jerry Raia on 27 Nov 2010, 6:06 p.m.,
in response to message #14 by Namir

I'm glad it works! Still it's odd I can't seem to duplicate your result of (0,5) on either of my computers with EMU71.

                        
Re: Question about programming the HP-71B
Message #16 Posted by Namir on 27 Nov 2010, 6:08 p.m.,
in response to message #15 by Jerry Raia

I am equally baffled about the result. The program I wrote does not use the SQRT, so I guess I am fine.

                        
Re: Question about programming the HP-71B
Message #17 Posted by Namir on 27 Nov 2010, 7:39 p.m.,
in response to message #15 by Jerry Raia

I downloaded the latest version of EMU71 and ran the code. Same result. Also when I type SQR((-144,0)) I get (0,144). Also when I execute SQR((144,0)) I get (144,0). Moreover, when I execute SQR((144,144) I get (20808,3,46020761246E-3). The correct answeris 13.1842 + 5.4611i.

Seems like a bug to me?????

Namir

Edited: 27 Nov 2010, 7:44 p.m.

                              
Re: Question about programming the HP-71B
Message #18 Posted by Jerry Raia on 27 Nov 2010, 8:38 p.m.,
in response to message #17 by Namir

Yes something is wrong. When I execute the examples you just tried on EMU71, I get the correct results. Not the results you are getting.

                              
Re: Question about programming the HP-71B
Message #19 Posted by J-F Garnier on 28 Nov 2010, 3:46 a.m.,
in response to message #17 by Namir

Hi Namir,

Are you running Emu71 on a native Windows computer, or in a Windows (or DOS) emulation?

J-F

                                    
Re: Question about programming the HP-71B
Message #20 Posted by Namir on 28 Nov 2010, 5:52 a.m.,
in response to message #19 by J-F Garnier

Hi!

I usually launch a DOS box in Windows 7 and then run your emulator. I tried running the emulator directly and I get the same error. I am running a 32-bit Windows 7 on my (traveling) laptop.

I also noticed that raising complex number to integer power does not work!

Thank you for responding to my query!

Namir

Edited: 28 Nov 2010, 6:29 a.m.

                                          
Re: Question about programming the HP-71B
Message #21 Posted by Raymond Del Tondo on 28 Nov 2010, 8:16 a.m.,
in response to message #20 by Namir

Have you tried without the JPC, just to be sure ?
IIRC the JPC listens to some interrupts, so maybe it's a matter of a Mode setting?

HTH

Ray

                                          
Re: Question about programming the HP-71B
Message #22 Posted by J-F Garnier on 28 Nov 2010, 8:41 a.m.,
in response to message #20 by Namir

Namir,

Very strange. I doubt this is a problem from Emu71 but can you send me your complete Emu71 folder with all your files so I can check ? jeffcalc (at] wanadoo <dot> fr thanks.

J-F

                                                
Re: Question about programming the HP-71B
Message #23 Posted by Namir on 28 Nov 2010, 3:10 p.m.,
in response to message #22 by J-F Garnier

You have email!

Namir

                                                      
Re: Question about programming the HP-71B
Message #24 Posted by J-F Garnier on 28 Nov 2010, 4:15 p.m.,
in response to message #23 by Namir

Found it :-))

In emu71.in, replace "2 ROM 16 mathrom.bin" by "2 ROM 32 mathrom.bin". Math module is a 32bB ROM.

What is strange is that Emu71 didn't crash with just half of the ROM loaded...

J-F

                                                            
Re: Question about programming the HP-71B
Message #25 Posted by Namir on 28 Nov 2010, 5:31 p.m.,
in response to message #24 by J-F Garnier

Jean-Francois,

It worked!!! thank you!! Now I get the correct results with EMU71. The power operator for complex numbers also works properly. I guess it was part of the ROM that was not loaded.

Many thanks for taking the time to look into it.

Namir

Edited: 28 Nov 2010, 6:27 p.m.

                                                            
Re: Question about programming the HP-71B
Message #26 Posted by Jerry Raia on 28 Nov 2010, 10:54 p.m.,
in response to message #24 by J-F Garnier

Perhaps no calls were made within the ROM half that was missing. Although I wonder why the SQRT result Namir originally got didn't cause a crash. It is interesting.

                                                                  
Re: Question about programming the HP-71B
Message #27 Posted by Namir on 29 Nov 2010, 4:53 a.m.,
in response to message #26 by Jerry Raia

The ^ operator also did not work! I had to recode the program and apply work-arounds.

When I used the SQRT with complex values I got (wrong) answers. The emulator never crashed.

namir

Edited: 29 Nov 2010, 4:54 a.m.

                                    
Re: Question about programming the HP-71B
Message #28 Posted by Egan Ford on 28 Nov 2010, 1:50 p.m.,
in response to message #19 by J-F Garnier

Quote:
(or DOS) emulation?
I tested with DOS emulation without issue. I tested the latest EMU71 with DOSBox on OS/X and on my iPad.
10 COMPLEX A
20 A=-5
30 CALL TESTSUB(A)
40 END
100 SUB TESTSUB(A)
110 DISP SQRT(A)
120 END SUB
Results:
(0,2.2360679775)
VER$:
HP71:2CDCC RPN:C FACTR:A MATH:1A JPC:Ex HPIL:1B HELP:C FACTR:A STRU:A RCPY:E FTH41:1A EDT:A

Edited: 28 Nov 2010, 1:54 p.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall