Question about programming the HP-71B



#7

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


#8

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.


#9

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.


#10

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


#11

Me too.


#12

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?

#13

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


#14

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.

#15

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


#16

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


#17

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.


#18

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.


#19

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.

#20

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.


#21

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.


#22

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

#23

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.


#24

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.

#25

Hi Namir,

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

J-F


#26

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.


#27

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

#28

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


#29

You have email!

Namir


#30

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


#31

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.

#32

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.


#33

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.

#34

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.


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

Forum Jump: