Sunday, July 2, 2017

App Review: Programmable Calculator (Jeff Glenn)

App Review:  Programmable Calculator (Jeff Glenn)

Programmable Calculator app screen shots

Author:  Jeff Glenn
Date: 2014
Cost:  99 cents
Version Reviewed: 1.2.0, 3/20/2015
Type: Programmable, Basic
Platform:  Android

Mathematical Programming From Scratch

The Programmable Calculator app lives up to its name.  It gives you barebones as far as features are concerned: just the four arithmetic functions (addition, subtraction, multiplication, and division) and nothing else.  Not even square root or π. 

Their website, http://igram.org/progcalc/user_manual.html, has a program to calculate square roots.

Before there were scientific calculators and scientific functions arrived on our computers, they had to all be programmed using just arithmetic functions. 

If you want to try scientific programming on this app, you may want to consult the 1975 book Scientific Analysis on the Pocket Calculator by Jon M. Smith (John Wiley & Sons), or this website by Ted Muller:  http://tedmuller.us/Math/Calculator-1'Introduction.htm 

Needless to the say, the Programmable Calculator operates on Chain logic.  That is, it doesn’t follow the algebraic order of operations ( 2, [ + ], 3,  [ * ], 4, [ = ] returns 20 instead of 14).

Press [ f ], [R/S] to access the options and user manual. Options include turning sound and vibration on for key presses, which I highly recommend. 

Programming

The programming features on this app are laid directly on the keyboard.  There are 10 memory registers (R0 through R9), 10 labels (again, 0 – 9), and the accumulator (number on the display) to use.  Programs can be saved and loaded with file names.  The limit seems to be the amount of memory on your Android device (phone).

What is weird is that certain commands, such as the comparison, store, and recall, will prompt you for either the accumulator (display, by pressing the [ . ]), a specific memory register (0 – 9), or a constant, which will require a press of the equals key [ = ] first.  This takes getting used to.

Here are some commands. 

[ IN ].  Input.  (in).   Stores the prompted value to a designated memory register.  This command also acts as a prompt.  If a print string proceeds the input command, the prompt gets attached to the end of the screen.

[ OUT ].  Output.  (out)   Displays the contents of a designated memory register.  Execution doesn’t stop on output, so if this command is the last command before eof (end of file), you’ll need either an R/S (run/stop) or sleep.  If a print string proceeds the output command, the value gets attached to the end of the print string.

[ PRT ].   Print  (prt).  Prints a string.  Without a string, this command would clear the display instead.

[ LBL] and [ GTO ].   Label (lbl) and go to (gto), respectively.

[ DSZ ].  Decrement and skip.  (dsz)  Designates a register to decrease by 1.  If the result is zero, the next command is stepped.

[ < ], [ = ], [ > ], ≤, ≠, ≥.  Comparisons.  Compares the accumulator (display) to a designated register.  If the test is true, the next command is executed.  Otherwise, the next command is skipped. Code names: lt, eq, gt, le, ne, and ge respectively.

[ SET ].  Sets the accumulator (display) to a designated value.

[ CLR ].  Clears the accumulator (display). 

[ STO ] and [ RCL ].  Store and recall.

The arithmetic keys: [ + ], [ - ], [ * ], [ ÷ ].  These keys work quite differently in program mode.  You are prompted to designate a register for the operation to work on (like recall arithmetic).  You can also choose the accumulator by pressing [ . ].  Pressing the equals key [ = ] allows for a numeric constant to be entered.  All numeric constants are shown as floating point numbers.  For example, add 1.0 would add 1, but add 1 would add the value of register 1.  Code names are add, sub, mul, and div, respectively.

[SLEEP]  This command pauses execution.  A value of 1,000 amounts to 1 second. 2,000 for 2 seconds, etc. Code name: slp.  This works similarly to the comparison and arithmetic commands.

[R/S]  Run/Stop.  Code name: stp.

[REM]  Remark, comment.

If I understand [TIME] correctly, this records the time value onto the calculator app.  I haven’t tried this yet.


Sample Programs

I suggest trying the sample programs listed below or listed online manual ( http://igram.org/progcalc/user_manual.html  ) before programing on your own.  I really got stuck with the input instruction and how to get the R/S key to work out.

Square Plus 1

This program calculates the function f(x) = x^2 + 1

Step
Line
Comment
00
prt “Number: “
Prompt
01
in 0
Input to R0
02
prt  (blank string)
Keys: [PRT], [DONE]
Clears the display
03
rcl 0

04
mul 0
R0 * R0
05
add 1.0
Keys: [ + ], [ = ], 1, [ = ]
06
sto 1
Store result in R1
07
out 1
Display R1
08
sleep 1000.0
Keys:  [ f ], [OUT] (SLEEP), [ = ], 1000, [ = ]
09
eof
End of Program

Example:
Input: 6, Result:  37
Input: 11, Result: 122

Area of a Circle

The value of π must be manually entered.  I use 10 digits.

Step
Line
Comment
00
rem “Area: Circle”
Remark
01
prt ([DONE])
Clear the display
02
prt “Radius: “
Prompt: “Radius”
03
in 0
Input to R0
04
prt

05
rcl 0

06
mul 0
R0 * R0
07
mul (=) 3.1415926535
Use [ = ] to enter the constant π
08
sto 1
Store result in R1
09
out 1
Display R1
10
eof
End of Program

Example:
Input:  2.5, Result:  19.634954084375

Power:  x^y

Conditions:  x > 0, y is an integer.  Neither condition is tested.  Since only arithmetic functions are available, a loop is used.

Step
Line
Comment
00
prt
Clear the display
01
prt “x = “
Prompt for x
02
in 0
Input R0
03
rcl 0

04
sto 2
Store R0 in R2 (copy x)
05
prt

06
prt “y (integer) = “
Prompt for y, with reminder
07
in 1
Input R1
08
lbl 0
Label 0, begin the loop
09
rcl 0

10
mul 2

11
sto 0
R0 * R2 → R0
12
rcl 1

13
sub 1.0
Keys: [ - ], [ = ], 1, [ = ]
R1 – 1
14
sto 1
R1 – 1 → R1
15
rcl 1
Put R1 in the display (accumulator)
16
gt 1.0
Keys: [ > ], [ = ], 1, [ = ]
Is R1 > 1?
17
gto 0
Goto Label 0 if R1 > 1
18
prt

19
prt “x^y = “
Start result string
20
out 0
Attach R0 (result) to string
21
eof


Examples:
Input:  x = 3, y = 5.  Result:  243
Input:  x = 2.7, y = 8.  Result: 2824.2953648100015

Modulus

This program calculates x mod y, where x and y are both positive and x > y.

Step
Line
Comment
00
prt
Clear the display
01
prt “x (>0) = “
Prompt for x
02
in 0
Input R0
03
prt

04
prt “y (>0) = “
Prompt for y
05
in 1
Input R1
06
lbl 0
Label 0, begin the loop
07
rcl 0

08
sub 1
Subtract R1
09
sto 0
R0 – R1 → R0
10
rcl 0

11
sub 1

12
ge 0.0
Keys: [ ≥ ], [ = ], 0 , [ = ]
R0 – R1 ≥ 0?
13
gto 0
Goto label 0, repeat loop if R0 ≥ R1
14
prt

15
prt “x mod y = “
Begin result string
16
out 0
Attach R0 to the result string
17
eof


Examples:
Input:  x = 44, y = 3.  Result:  44 mod 3 = 2
Input:  x = 76, y = 20.  Result:  76 mod 20 = 6

Final Verdict

The programming language seems to be clumsy at first and it will take some getting used to.  Turning on the sound and vibration made operating the app much better because the touch has to be precise.  I can see how this app can easily frustrate people. 

Also it is very unusual that the equals key is at the top row of the keyboard instead of the usual location at the bottom. 

With a lack of scientific functions, I recommend this app if:

(1) You want to engage mathematical programming from scratch.  Remember that all the scientific, financial, and advanced features had to be originally programmed using the four arithmetic functions themselves!
(2)  You want a challenge.

Eddie



This blog is property of Edward Shore, 2017.

Fun with the Casio fx-3650p

Links to previous fx-3650p programs:

5/11/2014:


Contents:
1. Circular Sectors
2. Stopping Sight Distance
3. Resistors in Parallel
4. Net Present Value
5. Rod Pendulum
6. Vectors: Dot and Cross Products


10/27/2015:


Contents for this blog:
1.  Combination with Replacement
2.  Great Circle (Distance in km) 
3.  Orbital Speed and Period 
4.  Eccentricity and Area of an Ellipse
5.  Super Factorial
6.  Escape Velocity 
7.  Finance: Payment of a Monthly Mortgage
8.  Wind Chill Factor
9.  Speed of Sound in Dry Air 

-------

Contents for this blog entry (7/2/2017)

1.  Modulus Function
2.  Normal CDF
3.  Sum:  Σ (AX + B)^C,  from X = 0 to X = Y
4.  Sun Altitude and Azimuth Based on the Vernal Equinox
5.  Trapezoid: Midsegment, Height, and Area
6.  Solar Irradiance
7.  General a list of X Random Integers from 0 to Y

Modulus Function

Calculates A mod B for A > 0 and B > 0.   Since the fx-3650p has no integer or fraction part functions, a loop of repeated subtractions are needed.

Program (25 steps):
? → A : ? → B : Lbl 1 : A – B → A : A ≥ B Goto 1 : A

Examples:
Input:  A = 77, B = 9.  Result: 5
Input:  A = 92.38, B = 2.38.  Result:  1.94 

Normal Distribution CDF

This calculates the area of a normal distribution curve between points A and B, given that mean = 0 and deviation = 1.  Radians mode is set.  The result is stored in C.

Program (34 steps):
? → A : ? → B : Rad : ∫ ( e (-X² ÷ 2 ), A, B → C : C ÷ √ (2 π → C

Note e is the exponential function (e^x).

Examples:
Input:  A = 0, B = 2.  Result:  0.47725066
Input:  A = -1, B = 1.  Result:  0.682709924


Sum:  Σ (AX + B)^C,  from X = 0 to X = Y

Program (51 steps):
? → A : ? → B : ? → C : ? → Y : 0 → X : 0 → M : Lbl 1 : (AX + B)^C M+ : 1 + X → X : Y ≥ X Goto 1: M

Examples:
Input:  A = 2. B = 6, C = 2, Y = 4.  Result:  540
Input:  A = -3, B = 1, C = 3, Y =6.  Result:  -9632

Sun Altitude and Azimuth Based on the Vernal Equinox


Input:
Y =  days after the vernal equinox, usually March 21
A = latitude on Earth (north-south, -90° to 90°)
X = the time before solar noon, local time

For example, for 10 AM (10:00), enter 2.  For 3 PM (15:00), enter -3.  Hence:  12 – time.

Output:
D = approximate declination of the sun (-23.45° to 23.45°)
B = sun’s altitude
C = sun’s azimuth (from ground wise north)

Program (69 steps):
? → Y : ? → A : ? → X : Deg : 23.45 sin(.9856Y → D   sin¯¹ (cos A cos D cos (15X) + sin A sin D → B cos¯¹ ( ( sin B sin A – sin D) ÷ (cos A cos B → C

Examples:

Input:  Y = 90 days, A = 25°, X = -3  (3 PM)
Results: 
D = 23.44400127° = 23°26’38.4”
B = 48.81756385° = 48°49’3.23”
C = 99.85903298° = 99°51’32.52”

Input:  Y = 68 days, A = 46°, X = 4 (8 AM)
Results:
D = 21.58916369° = 21°35’20.99”
B = 35.989914° = 35°59’23.69”
C = 84.40834691° = 84°24’30.05”

Source: Sun Altitude, Azimuth, Solar Pond Absorption, HP 67/97 Energy Conservation December 1978, Author: HP

Trapezoid: Midsegment, Height, and Area


Input:
A = length of top side
B = length of bottom side
C = length of left side
D = length of right side

Output:
X = Midsegment length
Y = Height
M = Area

Program (92 steps):
? → A : ? → B : ? → C : ? → D : .5(A + B → X (-A + B + C + D)(A – B + C + D)(A – B + C – D)(A – B- C- + D) → Y : √Y ÷ ( 2 √( (B – A)² ) → Y (A + B)Y ÷ 2 → M

Example:
Input:  A = 18, B = 16, C = 12, D = 11
Results:  X = 17, Y = 9.921567417, M = 168.6666461

Source:  “Trapezoid”  Wikipedia.  Edited July 7, 2014.  Retrieved July 8, 2014

Solar Irradiance



The program calculates:



1. The solar angle of incidence given the angular elevation and azimuth (from south going “counterclockwise”:  east-north-west) of both the sun and panel.
2. The irradiance given by the solar panel. 


Input:
X = elevation of the sun
A = azimuth of the sun
Y = elevation of the solar panel
Z = azimuth of the solar panel
M = the sun’s power or irradiance.  Often this is treated as a constant, which is approximately 1367 W/m^2 for extraterrestrial solar power, or approximately 1000 W/m^2 when we are dealing with the Earth’s surface (taking scattering of light into account)

Output:
C = incidence angle
D = solar irradiance

Program (46 steps):
? → X : ? → A : ? → Y : ? → B : ? → M : Deg : cos¯¹ ( cos Y sin X + sin Y cos X cos (A – B → C M cos Y → D

Example:
Input:

Sun:
X = 55°24’21”
A = 175°15’44”

Panel:
Y = 40°
B = 90°

Sun’s Irradiance:
M = 1000 W/m

Results:
C = 48.6431686°
D = 766.0444431 W/m

Sources (you might have to copy and past these links)  

Baldocchi, Dennis “Lecture 7, Solar Radiation, Part 3, Earth-Sun Geometry”  Biometeorogy, ESPM 129  University of California, Berkeley.


Retrieved February 17, 2015. 

Mortimer, David  “Lambert’s Cosine Law”  30 January 2014.  The Solar Bucket.


Retrieved March 18, 2015

University of Oregon Solar Radiation Monitoring Laboratory  “Solar Radiation Basics”  University of Oregon.  http://solardat.uoregon.edu/SolarRadiationBasics.html   Retrieved February 10, 2015

General a list of X Random Integers from 0 to Y

This program generates a list of random integers (X) from 0 to upper limit Y.  This program uses the Fix 0 mode and makes use of the Rnd (round the number in the display) command.  Note the integers as they appear.  The program finishes by setting the calculator back in Norm 1 mode.

Program (33 steps):
? → Y : ? → X : 1 → M : Fix 0 : Lbl 1 : Ran# Y : Rnd 1 M+ : X ≥ M Goto 1 : Norm 1

Example:
Generate 5 random integers from 0 to 10.  (Y = 10, X  = 5)
Result:  6, 7, 6, 6, 10 (your results will vary)

Comments

As with the other fx-3650p I and others have posted, they can easily be adapted to the fx-50fH, fx-5800p, fx-6300g, fx-CG50, and (almost) any other Casio programming calculator. 

Recently I learned that Casio updated the fx-3650P and the fx-50F(H) with the fx-3650P II and fx-50F(H) II respectively.  The only difference I was able to spot is that the fx-3650P II now has 390 programming steps instead of 360. http://www.casio-intl.com/asia/en/calc/school/programmable/

And yes, I still wish Casio sold these models in stores in the United States.  Currently, for us U.S. residents, they can only be purchased online. 

Now if Casio made a solar version of the fx-6300g, with more memory.

Eddie


This blog is property of Edward Shore, 2017.

My International Casio Collection (So Far)

 Pictured: Pic 1:  Casio fx-991CN X (China)  Pic 2:  Casio fx-570SPX II Iberia (Spain) Pic 3:  Casio fx-92 Collège (France) All original co...