Question about programming the HP-71B
#1

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

#2

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.

#3

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.

#4

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

#5

Me too.

#6

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?

#7

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

#8

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.

#9

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.

#10

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

#11

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

#12

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.

#13

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

#14

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.

#15

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.

#16

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.

#17

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.

#18

Hi Namir,

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

J-F

#19

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.

#20

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

#21

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

#22

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.

#23

You have email!

Namir

#24

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

#25

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.

#26

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.

#27

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.

#28

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.



Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple? programming question [WP34S] Shawn Gibson 3 1,414 03-15-2013, 11:56 AM
Last Post: Didier Lachieze
  WP-34S Programming Question Matt Agajanian 2 1,220 08-04-2012, 02:04 PM
Last Post: Matt Agajanian
  WP 34S programming question Nigel J Dowrick 35 7,972 04-10-2012, 02:23 AM
Last Post: Walter B
  HP-71B HP-IL module question J-F Garnier 9 2,405 03-31-2012, 07:12 AM
Last Post: J-F Garnier
  15C programming question Eric Zoob 7 2,155 03-28-2012, 03:14 PM
Last Post: C.Ret
  HP-IL 71B to 71B via HPIL Geoff Quickfall 11 3,036 12-01-2010, 06:55 PM
Last Post: Michael Meyer
  question on 12c programming Don Shepherd 2 1,131 12-24-2008, 06:33 PM
Last Post: Egan Ford
  17bII programming question Dewdman42 28 6,070 10-07-2008, 11:33 PM
Last Post: Dewdman42
  U Watch programming question.. Geoff Quickfall 12 2,852 06-07-2008, 05:57 PM
Last Post: Geoff Quickfall
  33s - programming question Frank Rottgardt 4 1,462 05-15-2008, 08:27 PM
Last Post: Don Shepherd

Forum Jump: