Saturday, September 30, 2017

Adventures in Python: Installing and Matplotlib Package

Adventures in Python: Installing and Matplotlib Package

October: Adventures in Python

I am going to spend some of October concentrating on programming in the popular program Python.  Python is available on most operating systems:  Windows, iOS (such as Pythonista), Android (most popular QPython), and Linux.  

Python comes in two versions, 2 and 3.  The latest version is 3.6.

My focus is on mathematics and mathematical application.  I plan to use a Windows version of Python and the iOS Python.

Python comes with several expansion modules out of the box:  math (mathematics), random (random numbers and generation), statistics, cmath (complex numbers), and time (time functions). 

However, if we want to generate plots, including histograms and box plots, we will need to download and add an appropriate package.  The package that I am going to use is matlibplot, which also contains the module numpy which allows for matrices and matrix calculations.  The file format of matlibplot is .whl (wheel). 

Download – Windows

Download Python here:  https://www.python.org/ 


I downloaded the Win32 verison.

When downloading, make sure you use custom installation. I recommend watching this YouTube video by APMonitor here:  https://www.youtube.com/watch?v=Ju6zw83PoKo&feature=youtu.be

The video saved me a lot of headaches when I tried to download and install Python, along with downloading and installing mathlibplot.  For instance, to install mathlibplot (which includes numpy), you will need to work with the Windows command prompt.

Note:  To install matplotlib, you must install pip and matplotlib thorugh the Windows Command Prompt, not the program itself.

For the Windows version, I am going to use the IDLE program which allows me to run Python both on the module and also create and run scripts. 




Android – installing matplotlib – Help Needed!

I tried to install matplotlib on QPython3 without success.  There documentation for this is scare and often not a help at all.   If anyone knows how to do it, please share.  I need type of version (Linux, win32, etc) is needed, what folder, etc. 

Download Pythonista – Apple iOS

For portable Python I am going to use the Pythonista app for Apple iOS engine.  It costs $9.99.  The best part about Pythonista is that numpy and matplotlib are both included.

More information about the app can be found here:  http://omz-software.com/pythonista/

Eddie

This blog is property of Edward Shore, 2017.



HP 12C: Prime Factoring (by Don Shepard)

HP 12C:  Prime Factoring (by Don Shepard)

Introduction – Cash Flow Registers to Simulate Indirect Addressing

This program uses what is called indirect addressing on the HP 12C, which can be simulated by the use of the cash flow registers. 

Cash flow registers can be registered by using the cash flow [ g ] [PMT] (CFj)  and frequency [ g ] [ FV ] (Nj) registers.  Every time a cash flow is stored, the counter is increased by 1.  The counter can be recalled by press [RCL] [ n ].

Similarly, you can recall the cash flows by the use of [RCL] [ g ] [PMT] (CFj) and the attached frequencies by the use of [RCL] [ g ] [ FV ] (Nj).  Each time a cash flow is recalled, the counter is decreased by 1. 

Each cash flow can have a frequency up to 99 copies. 

Fun fact:  the first 20 cash flows can be stored into registers R0 through R19, with the 20th flow stored in FV (future value).  The cash flow 0 is the initial cash flow, CF0 (accessed by [ g ] [ PV ] (CF0)). 

This is kind of storing values in a list and recalling them whenever necessary.

Program:

Enter the integer and press [ R/S ].  Keep pressing [ R/S ] to reveal more factors.  The factorization ends when a zero appears.

(Remember if you program using a HP 12C Platinum, step numbers are three digits instead of two.)

Step
Code
Key
01
44, 0
STO 0
02
42, 32
Clear Σ
03
2
2
04
44, 11
STO n
05
6
6
06
43, 14
[ g ] CFj
07
2
2
08
43, 15
[ g ] Nj
09
6
6
10
43, 14
[ g ] CFj
11
4
4
12
43, 15
[ g ] Nj
13
2
2
14
43, 14
[ g ] CFj
15
4
4
16
43, 15
[ g ] Nj
17
2
2
18
43, 14
[ g ] CFj
19
4
4
20
43, 15
[ g ] Nj
21
2
2
22
43, 14
[ g ] CFj
23
43, 15
[ g ] Nj
24
1
1
25
43, 14
[ g ] CFj
26
2
2
27
43, 15
[ g ] Nj
28
0
0
29
44, 12
STO i
30
45, 43, 15
RCL [ g ] Nj
31
43, 33, 56
GTO 56
32
1
1
33
44, 12
STO i
34
45, 43, 14
RCL [ g ] CFj
35
43, 33, 56
GTO 56
36
45, 11
RCL n
37
3
3
38
43, 34
x≤y
39
43, 33, 28
GTO 28
40
45, 0
RCL 0
41
43, 23
LN
42
43, 35
x=0
43
43, 33, 00
GTO 00
44
6
6
45
44, 11
STO n
46
45, 0
RCL 0
47
45, 1
RCL 1
48
36
ENTER
49
20
*
50
43, 34
x≤y
51
43, 33, 28
GTO 28
52
45, 0
RCL 0
53
31
R/S
54
0
0
55
43, 33, 00
GTO 00
56
44, 40, 1
STO+ 1
57
45, 0
RCL 0
58
45, 1
RCL 1
59
10
÷
60
43, 24
FRAC
61
43, 35
x=0
62
43, 33, 67
GTO 67
63
45, 12
RCL i
64
43, 35
x=0
65
43, 33, 32
GTO 32
66
43, 33, 36
GTO 36
67
45, 1
RCL 1
68
44, 10, 0
STO÷ 0
69
31
R/S
70
0
0
71
43, 33, 56
GTO 56


** Line 34 has been corrected.  10/3/2017


Example 1:

Factoring 148:

148 [R/S]
Display:  2, Press [R/S]
Display:  2, Press [R/S]
Display:  37, Press [R/S]
Display: 0

Result:  148 = 2 * 2 * 37 = 2^2 * 37

Example 2:

Factoring 976:

976
Display:  2, Press [R/S]
Display:  2, Press [R/S]
Display:  2, Press [R/S]
Display:  2, Press [R/S]
Display:  61, Press [R/S]
Display:  0, Press [R/S]

Result:  976 = 2 * 2 * 2 * 2 * 61 = 2^4 * 61


Special thanks to Don Shephard for letting me post his program on this blog.  Shepard attended HHC 2017, where he spoke about punch cards and their history.


Eddie


This blog is property of Edward Shore, 2017.

Sunday, September 24, 2017

HHC 2017 In Review

HHC 2017 In Review

Hello Nashville, TN!


HHC 2017 took place on September 16 and 17, 2017 in Brentwood, TN.  If you have not gone to a HHC conference, and you love calculators and math, I strongly encourage you to attend.  The conferences take place typically around the latter half of September. 


Disclaimer

I will give a summary of each of the talks here, accompanied by a YouTube video produced by http://www.hpcalc.org/.  The hpcalc.org website is run by Eric Rechlin.  I am under a non-disclosure agreement, which means that I will not be able to discuss certain details of the conference due to confidentiality.

Programming Contests

There were two programming contests, which is presented during the conference, both for the conference attendees and the MoHPC forum.  For fun, please click on the links below.

Subject:  Happy Numbers

Subject: Egyptian Fractions


Day 1:  September 16, 2017

Jim Johnson:  HP 25-LP Panamatik’s New Woodstock Low-Power Upgrade Kit


The classic HP Woodstock Calculators (HP-21, PP-22, HP-25, HP-25C, HP-27, HP-29C) had rechargeable battery packs that also came with the AC plug in battery pack.  The ACT chip in the Woodstock calculators could get damaged if the AC plugged in without the battery or the faulty battery.  Panamatik created a new HP-25 LP kit to replace the ACT chip.  The ACT chip not only revives your Woodstock calculator but also adds features such as:

* 80 character alpha-numeric text.  When you are reviewing your programs, you will see the function name rather than the character code.
* The calculator will have a sleep mode.  This allows the calculator to last up to 10 days before recharging.
* A clock is added, which also adds the ability to set alarms.
* All memory becomes continuous (saved when shut off).

Gene Wright – Non-HP Desktop Scientific Calculators


During the height of scientific calculators in the 1970s, desktop versions of scientific calculators were manufactured.  Aside from the HP-9820, HP-9805A, HP-9815A, HP-9815S, and HP-9825A, Wright highlighted the follow scientific desktops:

* Compucorp 324G:  portable scientific calculator

* Rockwell 350:  8 digit calculator, algebraic

* Monroe 1920:  14 digit calculator, algebraic, linear regression.  Two keys, [ I ] and [ II ] are mapped to two switch selectors. 

The [ I ] key can either execute DMS>θ, r>θ (convert to degrees), xy>θr (rectangular to polar), π, Clr 1-3 (clear registers 1, 2, and 3), Σ (add data points). 

The [ II ] key can used for θ>DMS, θ>r (convert to radians), θr>xy (polar to rectangular), LOG (common logarithm, antilog is available via [INV] [ II ]), σ/mean (calculates standard deviation – stored in register 9 and mean – stored in register 8), -Σ (remove data points).
 
* Electronika MK-45:  features factorial and storage arithmetic, algebraic

* Sharp PC 1001: programmable calculator, 64 steps

* Victor VS 230:  extremely rare desktop scientific calculator

* Commodore 1540:  10 digits with 2 digit exponents, 2 memory registers

Gene Wright – New ROMs for the HP-41CL


An update on the HP 41CL, a replacement CPU board for the fullnut versions for the HP 41C.  The new version of the HP 41CL includes:

* Formula evaluation with an equation library
* Total Rekall:  adds additional function such as XEQ+ and LAST_F (last 5 operations).  There is an additional 5 registers available for emergency purposes.
* HP 67 Fun:  game programs ported from the HP 67.  Chess, Moon Lander, One Arm Bandit, and other games.
* Partial Differential Equations
* Differential Geometry
* Recursive FROOT (root) and FINTG (integrals)
* XROM rom
* Ladybug rom:  makes the 41C is an integer binary calculator
* Test Statistics Solution Rom
* PPC 9: PPC Statistics ROM

Sylvian Cote – 41CL Self-Update


Sylvian’s presentation is very detailed about the 41CL.  A 41CL version 5 is being currently developed with the target date to be released in late 2017-early 2018.  It is the going to be the last version produced.  Version 5 will have the RAM size of 1,024 KB, with flash size of 8 MB, and the number of flash pages will increase to 1,024, the largest of the 41CL. 

The update can be completed all at once or in parts. 


Daniel McDonald – The End Is Near or I Love Pessimism


McDonald addresses a very important question:  what is going to happen to our calculator collection when we die?  How can we ensure the knowledge we gained won’t be lost to future generations? 

Hopefully, when the planet finally switches to an all-app world, there will still be room for handheld calculators with keyboards, or at the very least, enjoy a renaissance (or several) like Model T cars, typewriters, and vinyl albums.

Bob Prosperi – Searching… for calculators


Want that latest calculator or trying to find the elusive calculator for your collection?  Look no further than the tips and tricks presented by Bob Propseri.  Search terms, wildcards, what phrases get the best results (be specific, most of the time), and the use of quotes and minus signs are discussed here. 

Sometimes, the information you are looking for is on a website that is no longer currently maintained.  A tool to try the Wayback Machine, https://archive.org/web/ where over 305 billion archived sites have been achieved.  Your mileage may vary.

On the next eBay or auction site search, if the description contains “I don’t know how to test”, Prosperi suggest just to skip that item because it is most likely broken.

Namir Shammas – PRNGs For Calculators


There is a method on how calculators and computers generate random numbers, typically between 0 and 1 on calculators. Calculators and computers use a PRNG, a pseudo-random number generator to generate random numbers.  While computers use integer-based methods, calculators use floating number-based methods.  The latter generates less “random” values but is forgiven because we call for less random numbers on calculators. 

Regarding integer-based methods, a large integer is generated, then it is divided by another large integer to arrive at the random number. 

Using Matlab, Shammas tested various PRNGs for the ability to generate random numbers.  Patricianly, a million random numbers were generated on each test.  The PRNGs were scored by a penalty factor. 

Some examples of PRNGs are:

* frac(( 1111 + (9997 -1111)*r) * r)
* frac(997 * r)
* frac(π + r)^3
* frac(111/(π + r))

Where frac is the fraction function and r is a seed number.  PRNGs can get really complex, some involve IF-THEN-ELSE routines while others involve more than one seed.

Eric Rechlin – HP Calculator Achieve Twentieth Anniversary


Rechlin tells the history of www.hpcalc.org, launched on August 21, 1997.  Rechlin also accounts about the beginnings of storing HP calculator programs on websites.  Congratulations on 20 years, Eric!

Definitely check out this site www.hpcalc.org.

Note:  Any of my HP Prime programs that I do on this blog is also available for download (author:  Eddie Shore).  Much appreciation and thanks Eric!

Gene Wright – Don’t Make Me Wait


Wright discusses the mathematical perils of waiting, particularly situations where there is a long line and only one server.  Wright discusses queueing theory and the weighing the costs of service (number of servers, which is seen) and the cost of waiting (unseen).  Calculations quickly get complex where more than one server is involved.

Gene Wright – Commodore Scientific Calculators


Did you know that Commodore (1954 – 1994) made computers and calculators?  They did.  Watch this video and learn about the Commodore 1489, SR-37, SR-4148, SR-7919, PR-50, and others.  My personal favorite is the M 55. 

The M 55 (1976) stands out because it offered the error function, Bessel functions, log gamma, matrix operations, and Leguerre polynomials.  The N-60 (1976) specialized in navigation.  The S-61 (1976) specialized in statistics.  The SR-4921 (1975) was Commodore’s RPN model.

A good place for older calculator manuals, including Commodore, is Katie Wesserman’s site http://www.wass.net/manuals/

Richard Nelson – Not So Simple Power Calculations


This talk covers Ohm’s Law, calculating effective power, and the problem with load power versus pot rotation.  The pot is referred to a potientmeter, an electrical contact that serves a voltage divider.  In the case that the potientmeter is used in a system of two terminals, then the potientmeter becomes a rheostat (resistance adjustor).  Nelson covers a subject that is not discussed in electronic engineering class.

End of Day 1 – we’ve been going from 8:00 AM to 9:00 PM. 

Day 2:  September 17, 2017

Richard Schwartz – Log Tables


Before handheld calculators (1970s) we had to use tables and slide rules to assist us in calculations.  Log tables were provided by the government to students which had calculated common logarithms (base 10) to four decimal places.  Schwartz discusses the rounding errors found in the tables and how they can be addressed.

Bob Prosperi – HP 75 Update


The HP 75 (1982 – 1986) is enjoying a Renaissance.  There were two versions of the HP 75:  the HP 75C (1982) and the HP 75D (1983 – 1986).  There are also several emulators of the HP 75.  The hardware is large but is a beauty to hold. 

Original specs of the HP 75:

* Programming Language:  BASIC
* CMOS Capricorn CPU coprocessor
* 16,000 byte memory plus 8,000 bytes module available
* AC Port with 3 ROM slots
* Works with the HP-IL and PIL-BOX

You can join a discussion group for the HP 75:  https://groups.io/g/hp75

Namir Shammas – Halley-Ostrowski Root-Seeking Method


Dedicated to Bill Zimmerly.

Methods are numerically finding the root of the equation f(x) = 0 include the well-known Bisection Method, Newton’s Method (the most famous and used), Halley’s Method, and Ostrowski’s Method.

Shammas talks about combing methods to get generate a method to get to the solution faster (less iterations) and more accurately.  Highlighted are the Halley-Ostrowski Method and the Ostrowski-Lagrange Method. 

Jack Schwartz – EduCalc: A Look Back


Schwartz talks and reminiscences about EduCalc, a well embraced store that operated in Laguna Niguel, CA from May 24, 1976 to December 31, 1997.  EduCalc was one of the places to go and contact for HP calculators and documentation. 

Fun fact:  Richard Nelson used to work for EduCalc, and he did voices message detailing events and news for EduCalc.  Go to the video in this section and go to the 50:36 to hear a sample.  Really neat.

If only I visited EduCalc when it was open before it closed its doors in 1997.  And I live near Laguna Niguel! 

Eddie Shore – Extending the HP-12C: Programming for Scientific Applications
This is my first time I talked at an HHC conference, where I covered how we can use the programming features of the HP-12C to take it beyond financial applications and to save as much space as possible.  I covered how to type π, absolute value, the modulus function, finding the number of digits in an integer, how to simulate subroutines, and other topics.


Documentation:

Another check mark off of my bucket list. 

Don Shepherd – Do Not Fold, Spindle, or Mutilate

Punch Cards

Punch cards had a long history, the first design in 1725, with automated processing available in the late 1800’s.  At first, punch cards stored vital data and statistics, until around the 1950s where punch cards became command programming statements. 

Although punch cards came in various shapes and sizes, the typical punch card had eight rows of the digits 0 through 9, with space on top.  The space on top held punches that dictate which characters were used, first the alphabet (A-Z), then numbers (0-9), finally assorted characters (. , $).

To run a program or store information, a lot of cards were used. 


A particular card was the Wang Calculator card, where each punch card had seventy nine rows of numbers in Octal base (0, 1, 2, 4, 10 (8 in decimal), 20 (16 in decimal), and 40 (32 in decimal)).

A particularly neat way to punch cards was to use the IBM Port-A-Punch.  The stylus was used to punch holes in the cards without mess. 

I didn't know that HP Manuals from the 1970s were pretty small and handheld.  Here is two of them for the HP 33E and early financial calculators.

 Goodies:  Radio Shack EC-4000 (TI-57), TI-35 Plus, Sharp EL-506G.  This conference always have excellent door prizes.


Can’t wait for HHC 2018!

Eddie


This blog is property of Edward Shore, 2017.

Sum of Sequential Integers (featuring Swiss Micros DM32)

  Sum of Sequential Integers ( featuring Swiss Micros DM32) What is the sum of the following: 100 + 101 + 102 + 103 + 104 + 105 + … + ...