Sunday, May 11, 2014

Casio fx-3650p: Programming

HAPPY MOTHER'S DAY! Love you Mom! Thanks for all you do - Eddie

Casio fx- 3650p Programs

To celebrate the recent procurement of a Casio fx-5800p, let's dedicate the next several posts to Casio programming calculators. This one is for the fx-3650p, a programming calculator sold world wide (not so much the United States :( ).

Some pointers about the fx-3650p:

* The fx-3650P has only 7 variables (A, B, C, D, X, Y, and M). To save space, variables are recycled.

* You can apply storage arithmetic to memory M, mainly M+ and M-. On the fx-3650P, M+ and M- can be programmable steps. I am not sure if this is possible on programming models (fx-50f, fx-4500p, etc), but this option is not present in Casio's fx-5800p and current graphing calculators (fx-9860, Prizm, etc).

* With Goto and Label, loops can be constructed. The fx-3650p has four comparative tests (=, ≠, >, and ≥).

* Take advantage of not having to close the final parenthesis and begin able to use implicit multiplication to save space.

With that, here are some programs.

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

Circular Sector

Input:
A = radius
B = angle in degrees

Formulas:
arc length = 2 * r * sin(θ*π/360)
chord length = (r * θ * π)/180

Program: (28 steps)
? → A : ? → B : Deg :
2 A sin ( B π ÷ 360 ◢ A B π ÷ 180


Example:
A = 3.6
B = 44°

Input: Prog # 3.6 EXE 44 EXE

#: 1, 2, 3, or 4, depending on where your program is stored.

Results (to four decimal points);
0.04825 (chord length) EXE
2.7646 (arc length)

Stoping Sight Distance (U.S. Units)

Input:
A = design vehicle speed in miles/hour
B = grade, as a percentage

Standard constants (acceleration of the car of 11.2 ft/s^2 and 2.5 seconds of reaction time) are used.

Source: Goswami, Indramil Ph.D. P.E. "All In One Civil Engineering PE Breadth and Depth Exam Guide" 2nd Edition. McGraw Hill: 2012

Formula:
SSD = 11/3 * v + (1.075*v^2)/(11.2 + .32G)

Program: (32 steps)
? → A : ? → B :
11 A ⌟ 3 + 1.075 A ² ⌟ ( 11.2 + .32 B


Example 1: 50 mph, grade of 0%
Input: Prog # 50 EXE 0 EXE
Result: 423.4 mph

Example 2: 65 mph, grade of -2%
Input: Prog # 65 EXE -2 EXE
Result: 668.8 mph

The next two programs make use of loops.

Total Resistance: Resistors in Parallel

Formula: (1/R1 + 1/R2 + 1/R3 + ... )⁻¹

Note: The fx-3650P allows us to take the M+ to our advantage. Enter each resistor in Ohms. When completed, enter 0 to exit the loop.

Program: (30 steps)
0 → M :
Lbl 0 : ? → A : A = 0 ⇒ Goto 1 :
A ⁻¹ M+ : Goto 0 :
Lbl 1 : M ⁻¹


Example: A circuit has three resistors in parallel of 4 Ω, 3. Ω, and 6 Ω.
Input: Prog # 4 EXE 3 EXE 6 EXE 0 EXE
Result: 1.33333333

Net Present Value

Formulas: Σ (A_M / (1 + B%)^M) for M = 0 to C

Variables:
A = cash flows
B = periodic interest rate
C = number of cash flow (entered in advance)

Calculated Variables:
M = counter
D = total

Program: (51 steps)
? → C : ? → B : 0 → M : 0 → D :
Lbl 0 : ? → A :
D + A ÷ ( 1 + .01 B ) ^ M → D : 1 M+ :
C ≥ M ⇒ Goto 0 : D


Example:
Cash Flow:
CF0 = -$1,000.00
CF1 = $0.00
CF2 = $500.00
CF3 = $750.00
CF4 = $1,000.00
Periodic Interest Rate = 10%
Number of Flows = 4 (don't count the initial flow)

Input:
Prog #
4 EXE (number of flows)
10 EXE (periodic Interest rate)
-1000 EXE (cash flows)
0 EXE
500 EXE
750 EXE
1000 EXE

Results: $659.72 (NPV)

Pendulum of the Rod (U.S. units)

(See the above diagram).
A = length of rod
D = length of the board holding the rod

Formulas:
T = 2 π √( I / (m*g*A))
I = inertia of the pendulum
m = mass of the object
g = gravity constant (9.80665 m/s^2, 32.174 ft/s^2)

Using the rod, where I = 1/3 * m * r^2,
T = 2 * π * √(A/96.522) (US units) or
T = 2 * π * √(A/29.41995) (SI units)

Average velocity: V = D/T

Source: Michael Browne, Ph.D. "Schaum's Outlines: Physics for Engineering and Science" 2nd Edition. McGraw Hill, 2010

Program: (24 bytes for US Units)
? → A : ? → D :
2 π √ ( A ÷ 96.522 ◢ D ÷ Ans


Example:
A = 6 ft., D = 1.4 ft
Input: Prog # 6 EXE 1.4 EXE
Results:
1.566543062 sec (T) EXE
0.89368753 ft/sec (V)

Vectors: Dot and Cross Products

Formulas:
Dot Product:
[A, B, C] • [D, X, Y] = A*D + B*X + C*Y
[A, B, C] × [D, X, Y] = [ B*Y-C*X, C*D-A*Y, A*X-B*D ]

Program: (50 bytes)
? → A : ? → B : ? → C :
? → D : ? → X : ? → Y :
A D + B X + C Y ◢
B Y - C X ◢
C D - A Y ◢
A X - B D


Example:
[ 3, 4, 6 ] • [ -1, 2, 3 ] = 23
[ 3, 4, 6 ] × [ -1, 2, 3 ] = [ 0, -15, 10 ]

Input:
Prog # EXE 3 EXE 4 EXE 6 EXE -1 EXE 2 EXE 3 EXE

Results:
23 (dot product) EXE
0 (cross product, x) EXE
-15 (cross product, y) EXE
10 (cross product, z)

Hope that you enjoy these programs, maybe got a few pointers. Have a great day. I will be working with the Casio fx-5800p for my next blog, which I target to put out next week.

Peace!

Eddie


This blog is property of Edward Shore. 2014

Tuesday, May 6, 2014

Video: Unboxing the Casio fx-5800p (Updated 5/11/2014)

Unboxing the Casio fx-5800p. My cat Spike makes an appearance. Enjoy! Eddie


https://www.youtube.com/watch?v=zRdIk48dUPQ
Update 5/11/2014:  My apologizes - I had to edit a video and reload it.  The above link is correct.
Eddie

Monday, May 5, 2014

Complex Analysis Rap

Complex Analysis Rap

If you have a chance, check out this awesome complex analysis rap by Katherine Bellafiore Sanden:

http://youtu.be/PyYLzjYOHz0

You can download the song here: https://soundcloud.com/dragonflykbs/complex-analysis

Thank you Katherine for putting it on Soundcloud! The song is now proudly played on my iPod.

Thread where the rap, and other math sings are posted:

http://www.hpmuseum.org/forum/thread-1227.html

Thank you HP Forums (MoHPC)!

Just thought this is worth sharing - Eddie


Review: Canon F-792SGA Scientific Calculator

Here it is, a full in-depth review of the Canon Eco-Friendly F-792SGA calculator. For a hilarious intro video to the calculator, just click here:

http://youtu.be/F4QJZSLYLyk

Thanks Gina and Dad!

Quick Stats
Company: Canon
Price: The price ranges from $13 to $20.
Power: Solar, with battery backup (one CR2032 battery)
Where to Buy: Online. I am not aware of any stores in the United States (maybe Fry's?) that have them on sale. I got mine from amazon.com.
Package: Blister package. The calculator comes with two foldable manual sheets: one in English, the other in Spanish.
Special Note: The calculator's shell is made of recycled plastic.
Year Manufactured: first manufactured in 2013

Official web page from Canon: http://www.usa.canon.com/cusa/consumer/products/calculators/compact_calculators/f_792sga

At the time of this blog post, Canon does not offer an electronic version of the manual. Hopefully it will be uploaded soon.

Calculator Modes Offered
(First page)
1: COMP - Regular Calculator Mode
2: CMLX - Complex Number Mode
3: STAT - Statistics Mode
4: BASE - Base Calculations
5: EQN - Simultaneous Equations up to 4 x 4 systems, Quadratic, Cubic, and Quartic polynomial solver
6: TABLE - Function table of one variable
7: MATX - Matrices with operations for up to 4 x 4 matrices
8: VCTR - Vectors with operations for up to 3-element vectors
(Second Page)
1: INEQ - Inequality Solver
2: RATIO - Ratio Solver

General Math Mode

The F-792SGA allows for linear or textbook input and output. In textbook input, exact roots and multiples of π are displayed. Pressing the F-D key converts answers between exact and approximate.

Keyboard and the Apps Key

The keys are nice and responsive. Also, the keys stay in place when pressed and don't make slight shifts, giving the keyboard stability.

The keyboard is also nicely organized. The dedicated Apps button gives the user access to functions depending on the mode.

COMP: Π (product), Σ (sums), Max (of at least 2 numbers), Min (of at least 2 numbers), Q...r (quotient and remainder), Mod, LCM (of at least 2 integers), GCD (of at least 2 integers)

CMPLX: Polar and rectangular conversions, real part, imaginary part, conjugate, argument

STAT: ability to change regression type, edit data, regression variables, normal distribution area calculations

BASE: AND, OR, XOR, XNOR, NOT, NEG, base markers

EQN: change equation type

MATX: edit matrices, determinant, transpose, generate identity matrices, inverse of matrices (Inv), adjoint to matrices

VCTR: edit vectors, dot product. (Use × for cross product)

RATIO and INEQ: change type

Advanced Functions on the Keyboard

In COMP mode, you can calculate numerical derivatives of f(X), definite integrals of f(X), random numbers, and random integers (Press [Alpha], [ . ]).

Solving Equations in COMP Mode

To solve an equation, type in the equation, follow it with a comma (Press [Shift], [ ) ]). Then press [Shift], [CALC]. You can use the variables A through F, X, Y, and M.

38 Built In Formulas

Canon has a nice feature that is exclusive to the Canon scientific calculator line: that is the 38 built in formulas. On the F-792SGA, just press [Alpha], [ ( ]. Then scroll to get the formula desired, press the equals key. You are prompted for the variables and the result is returned.

For reference, I will have the 38 formulas listed at the end of this review after the Verdict section.

Complex Mode

The complex mode is a separate mode. The nice thing is that there are real and imag functions. Unfortunately, transcendental functions (powers, logs, trig) are not available with complex numbers.

Statistics Mode

You can turn the frequency column on and off. The F-792SGA can store up to 80 single points or 40 pairs. With the frequency column turned on, the number of slots are halved.

Regressions available are: Linear, Exponential (y = a*e^(b*x) and y = a*x^b), Power, Logarithmic, Inverse, and Quadratic (nice!)



F-792SGA vs. Other Scientific Calculators

The display and operating system of the Canon F-792SGA is practically the same of Casio's current Natural-V.P.A.M calculators (such as the fx-115ES PLUS). However, this is not a straight-knock off of the Casio counterpart.

Here are some differences:

* The F-792SGA has 79 scientific constants and 170 conversion pairs compared to the fx-115ES PLUS's 40 and 40, respectively. For further comparison purposes, the Sharp EL-W516X has 52 and 44, respectively. The nice thing about the F-792SGA is that you don't need to type a code to access the constants and conversions.

* The F-792SGA has a ratio solving mode, which I think is unique to this calculator (or to the Canon line?). This mode solves for X in two ratio statements: a:b=X:d and a:b=c:X. This is in place of the fx-115ES PLUS' verify mode.

* Up to 4 x 4 matrices can be used with the F-792SGA. This is on par with the Sharp EL-W516X. However, I like the matrix handling and operation on the F-792SGA better.

* The F-792SGA is one of the few solar scientific calculators to solve quartic equations, if not the only one.

* The F-792SGA has 19 memory registers: A-F, X, Y, M, and 0-9. The numeric storage registers are good for longer-term storage of constants. This is first calculator of this time to allow the use of numeric registers.

* The F-792SGA has 38 built in formulas, exclusive to Canon scientific calculators. This is referring to all non-graphing calculators.

Verdict

The Canon F-792SGA is a solid calculator and can rival the solar scientific calculators that are available. Again, you may not be able to find Canon calculators in most stores (that is unfortunate), so the most realistic way to get one is to order online (assuming it is available in your country).

I hope you enjoyed this review.

Eddie


List of Formulas included with the F-792SGA

1. Area of a Triangle: S = 1/2 * b * c * sin A

2. Area of a Circle: S = π * r^2

3. Fan-Shaped Area (Sector): S = 1/2 * r^2 * θ

4. Area of a Parallelogram: S = a * b * sin θ

5. Area of an Ellipse: S = π * a * b

6. Area of a Trapezoid: S = 1/2 * (a + b) * h

7. Surface Area-Sphere: S = 4 * π * r^2

8. Surface Area-Cylinder: S = 2 * π * r * (h + r)

9. Volume-Sphere: S = 4/3 * π * r^3

10. Volume-Cylinder: V = π * r^2 * h

11. Volume-Cone: V = 1/3 * π * r^2 * h

12. Sum-Arithmetic Progression: S = 1/2 * n * (2*a_0 + (n-1)*d))

13. Sum-Geometric Progression: S = a_0 * (r^n - 1)/(r - 1)

14. Σ(n^2) = 1/6 * n * (n + 1) * (2*n + 1)

15. Σ(n^3) = (1/2 * n * (n + 1))^2

16. Distance between two points: √((x_2 - x_1)^2 + (y_2 - y_1)^2)

17. Included angle between two lines: θ = atan((k_2 - k_1)/(1 + k_1 * k_2))

18. Law of Cosines-find side: a = √(b^2 + c^2 - 2*b*c*sin A)

19. Law of Sines-find side: a = 2 * r * sin A

20. Distance: d = v_0 * t + 1/2 * a * t^2

21. Velocity: v = v_0 + a * t

22. Circular Motion-Finding Period with velocity: T = 2 * π * r/v

23. Circular Motion-Finding Period with angular velocity: T = 2 * π/omega

24. Period of Simple Pendulum: T = 2 * π * √(l/g)

25. Electric Oscillation Frequency: f = 1/(2 * π * √(L * C))

26. Resistance: R = ρ * l/s

27. Joule's Theorem: P = V^2/R

28. Joule's Theorem: P = I^2 * R

29. Shunt Resistance: R = (R_1 * R_2)/(R_1 + R_2)

30. Kinetic Energy: E = 1/2 * m * v^2

31. Gravitational Potential Energy: E = m * g * h

32. Centrifugal Force: F = m * v^2/r

33. Centrifugal Force: F = m * omega^2 * r

34. Law of Gravity: F = G * M * m/r^2 (G = 6.6728*10^-11)

35. Electric Field Intensity: E = Q/(4 * π * epsilon * r^2)

36. Heron's Formula: S = √(Φ*(Φ-a)*(Φ-b)*(Φ-c)) where Φ=(a+b+c)/2. Only a,b, and c are asked for.

37. Optics-Reflective Index: E = sin I/sin r

38. Optics-Critical Angle-Total Reflection: θ = asin(n_2/n_1)

** g is assumed to be g = 9.80665 m/s^2. Use SI units.

Note: These formulas are included with most Canon scientific calculators, like the F-710. The notable exception is the F-604, where the formulas are not present.
Source: Canon F-792SGA Manual



This blog is property of Edward Shore. 2014

Sunday, May 4, 2014

Scientific Calculator Keyboard Challenge

Design the keyboard of a scientific calculator and post links to your designs as responses to this blog entry. Rules:

You have only 25 keys to work with. That's it.

Whatever features, applications, special functions, number of modification keys you can fit is up to you. It can be simple, graphing, financial and/or complex. This blog entry is just a call to be creative and to have some fun. Here is one I did:

It is a relatively simple scientific calculator design that would be either a solar-powered calculator or an app. Features include linear regression, algebraic and RPN entry modes, and basic scientific functions.

If you partake in this, have fun and please provide links as responses.

Coming soon I will review two calculators I recently purchased: the Canon F-792SGA and the Casio fx-5800P N.

PCalc: Programming Examples

For introduction to programming the PCalc iOS app, please click on this link:

http://edspi31415.blogspot.com/2014/05/pcalc-programming-introduction.html

PCalc:

Degrees Minutes Seconds to Decimal Degrees (DMS > D)

Converts DD.MMSSsssss to DD.dddddddddddd
D: Degrees
M: Minutes
S: Seconds

Example:
Input: 45.1535 (45° 15' 35")
Output: 45.2597222222 (≈ 45.25972°)

Program:
Decimal Mode
Set R0 To X
Truncate X
Set R1 To R0
Subtract X From R1
Multiply R1 By 100
Set R2 To R1
Truncate R1
Subtract R1 From R2
Divide R2 By 60
Multiply R2 By 100
Add R1 To R2
Divide R2 By 60
Add R2 To X


Decimal Degrees to Degrees Minutes Seconds (D > DMS)

Converts DD.ddddddd to DD.MMSSsssss where
D: Degrees
M: Minutes
S: Seconds

Example:
Input: 6.375 (6.375°)
Output: 6.2230 (6°22'30")

Decimal Mode
Set R0 To X
Truncate X
Set R1 To R0
Subtract X From R1
Multiply R1 By 60
Set R2 To R1
Truncate R1
Multiply R1 By 0.01
Add R1 To X
Set R3 To R2
Truncate R3
Subtract R3 From R2
Multiply R2 By 0.006
Add R2 To X


Stopping Sight Distance (in feet)

Input:
Y: design vehicle speed (miles per hour)
X: grade (in percentage)

Output:
X: Stopping sight distance in feet

Standard constants are used: deceleration of the car is assumed to be 11.2 ft/s^2.

Example:
Input:
Y: 45 mph
X: 2 (2% grade)

Output:
X: 249.8576858108 (feet)

Decimal Mode
Set R0 To 22/15
Multiply R0 By Y
Multiply X By 0.32
Add 11.2 To X
Invert X
Multiply X By 1.075
Y To Power of 2
Multiply X By Y
Add R0 To X


Perfect Trajectory (Projectile Motion without Air Resistance starting from point (0,0))

Input:
Y: Velocity in meters/second
X: Angle in Degrees

Output:
Y: Maximum Height in meters
X: Range of Projectile in meters

Example:
Input: Y: 30, X: 30
Output (to 4 decimal places): Y: 11.4718, X: 79.4790

Program:
Decimal Mode
Degrees Mode
Set R1 To 19.6133
Invert R1
Set R0 To X
Sine R0
R0 To The Power of 2
Multiply R1 By R0
Set R0 To Y
R0 To The Power of 2
Multiply R1 By R0
Set R2 To 9.80665
Invert R2
Set R0 To X
Multiply R0 By 2
Sine R0
Multiply R2 By R0
Set R0 To Y
R0 To The Power of 2
Multiply R2 By R0
Set X To R2
Set Y To R1


Eddie


This blog is property of Edward Shore. 2014

PCALC Programming: An Introduction

This blog entry is an introduction to programming the PCalc iOS App by James Thomson. My review of this app can be found here:

http://edspi31415.blogspot.com/2014/04/greetings-from-seattle-and-short-review.html

** Note, PCalc Lite app will not have this functionality. To get it, you have to purchase either the full PCalc iOS app (usually sold for $9.99), or make an in-app purchase of the appropriate add-on.

Creating or Edit Programs

Starting New Program or Edit a Program:

1. Press the f(x) button.
2. Select Edit (lower left corner of the dialogue box). This will cause a red circle to appear next to "User" and any other customized categories.
3. Select a category (User will work). To edit an existing program, just select it. To create a new program, select the Plus (+) symbol on the upper right hand corner of the screen. You can delete programs by pressing the red circle with a minus sign next to the program name. A red Delete box will appear as an indicator of confirmation.

Programs in PCalc work with registers. The X register is the primary display register. The Y register is the second display register. PCalc also has 10 permanent memory registers (labeled Memory 0 through Memory 9), 16 temporary registers (labeled Register 0 through Register 9, then Register A through Register F), and a tax register.

Everything is done in a sequential manner.

Types of Commands

There are several types of commands.

Mode Commands: they change the mode of PCalc. This includes angle setting (Degrees Mode, Radians Mode) and base setting (Decimal Mode, Octal Mode, Binary Mode, Hexadecimal Mode).

One Argument Commands: A command operates on a register and stores the result in that register. This includes trigonometric and logarithmic commands. This also includes several number operations:

Negate: Multiply the register by -1. This is like the change sign key. (+/-)

Invert: Takes the reciprocal of the value of the designated register. (1/x)

Truncate: Takes the integer part of the value of the register. (INTG/IP)

Exponent: The exponential function (e^x)

Factorial: The factorial function (x!). x must be positive, but does not have to be an integer.

Two Argument Commands: This is the arithmetic operations, power commands, and the Set command. The format is like this:

Command (operation)
Register (result is stored here)
Value (value of a designed register or specified value)

Let A and B be registers, B can also be a value.

Add B To A: A + B is stored in A

Subtract B From A: A - B is stored in A

Multiply A By B: A × B is stored in A

Divide A By B: A ÷ B is stored in A

A To Power of B: A^B is stored in A

(Inverse Power):
A To Power Of 1/B: Bth root of A stored in A (principal root)

Skipping Functions: PCalc allows for Boolean comparisons of values.

Command: Skip (what has to happen for the next commands to be skipped)
Register (register to be compared)
Value (register or value that is compared)
Skip (number of steps if the comparison is true)

For example:
Command: Skip If Greater Than
Register: X
Value: 42
Skip: 1

Skip 1 step if X>42.

There is a plain Skip command to arbitrarily skip a number of commands. This can turn out to be useful. It may take practice to get the Skip commands correct.

There are no loop commands in PCalc (as of this blog post).

You can stop, even invoke the error condition at any time by inserting a Stop or Error command, respectively.

Let's go over a couple of examples.

Volume of a Sphere

The volume of a sphere is V = 4/3 * π * r^3, where r is the radius.

This program takes the radius in the X register and calculate the volume of the radius. Please pay careful attention to the order of the program steps.

Volume of a Sphere
Decimal Mode
X To The Power of 3
Multiply X By 4/3
Multiply X By Pi (scroll down the possible list of values to select π).


Test example: The radius of Earth is approximately 3,963 miles. If we treat Earth as a sphere, it's volume would approximately be 260,711,882,973.332 cubic miles.

In more complex programs, I start by making copies of X, Y, and any other required registers into temporary registers. I use temporary registers to store and execute immediate calculations. When all the calculations are finished, I store the results into X, Y, and permanent memory registers (if necessary). The next program, Rect > Polar, will be an example of this.

Convert Rectangular Coordinates to Polar Coordinates

Enter the y coordinate then the x coordinate. The result will have r in the X register and the angle in the Y register. The angle is shown in degrees and ranges from -180° to 180°, similar to most scientific calculators with this function.

Comments are followed by a double backwards slash characters ( \\ ). These are for notes only and are not entered.

Rect > Polar
Decimal Mode
Degrees Mode \\ set PCALC to degrees
Set R0 to X \\ start calculating r = √(x^2 + y^2)
R0 To The Power of 2
Set R1 To Y
R1 To The Power of 2
Add R1 To R0
R0 To The Power of 1/2 \\ Inverse Power command, R0 = r
Set R1 To Y \\ start calculation for angle
Skip 5 If X!=0 \\ skip the next 5 steps if x≠0 - Goto (I)
Skip 2 If Y<0
Set R1 To 90
Skip 10 \\ skip the next 10 steps - Goto (II)
Set R1 To -90
Skip 8 \\ Goto (II)
Divide R1 By X \\ Label (I)
Inverse Tangent R1 \\ atan(R1)
Skip 2 If X>=0 \\ block if x<0 and y≥0
Skip 1 If Y<0
Add 180 To R1
Skip 2 If X>=0 \\ block if x<0 and y<0
Skip 1 If Y>=0
Subtract 180 From R1 \\ R1 = angle
Set X To R0 \\ Label (II) - r is now in register X
Set Y To R1 \\ angle is now in register Y, end of program


How to enter (x,y):
RPN Mode On: y, enter key, x, f(x) key, select Rect > Polar
RPN Mode Off: y, x~y key, x, f(x) key, select Rect > Polar

How to View Results:
RPN Mode On: r is displayed on the X stack, angle on the Y stack
RPN Mode Off: r is displayed, press the x~y key to get the angle

Example data (x,y):
y = 3, x = 3: r = 4.242640687, angle = 45
y = -4, x = 3: r = 5, angle = -53.13010235
y = 2, x = -2: r = 2.82842715, angle = 135
y = -3, x = -2: r = 3.60551275, angle = -123.6900675


My next blog entry will have several more example programs using PCalc.

Eddie


This blog is property of Edward Shore. 2014


Sunday, April 27, 2014

Combinations: Arranging Permutations with Three Ascending Consecutive Numbers

Question:  How many ways can a digits of a number be arranged so that at least three digits are in (i) ascending order and (ii) consecutive positions?

The Number 1234 (4 digit numbers)

Question:  How many ways can I arrange the digits of the number 1234 so that each permutation has at least three digits are in (i) ascending order and (ii) consecutive positions?

For example, desired permutations are 1234, 2134, and 4123.

Calculation:

The requirements that three digits are in ascending and consecutive order are be satisfied if the permutation contains any of the following:  123, 124, 134, and 234.

Treat the mentioned permutations as one object and the remaining number as one. Three slots has the group 123, 124, 134, and 234.  The corresponding last digit for each of the group is 4, 3, 2, and 1, respectively.  The number of arrangements so far is 4 * 2 = 8.   We are not done though.  Here are the eight arrangements calculated:

1234
1243
1342
2341
4123
3124
2134
1234

Note that 1234 appears twice.  Let's remove the duplicate.   We are left with 4 * 2 - 1 = 7. A table of all possible arrangements of 1234 (with the desired permutations highlighted). 







 
The Number 12345 (5 Digits)

Let's address the same question, this time with the arranging the digits of 12345.

Calculation:
 
The requirements that three digits are in ascending and consecutive order are be satisfied if the permutation contains any of the following:  123, 124, 125, 134, 135, 145, 234, 235, 245, and 345.  There are 10 three-digit combinations. 

Like before, treat the three digit combinations as "one object" and the two remaining digits separately.  For example, the combo 124 will fill three digits, 3 and 5 will complete the other two digits.  The gross number of permutations are (10 * 3) * 2 * 1 = 60.  Like the last problem, we have to account for duplicates.  In those 60 permutations counted, 12345, 12354, 12453, 13452, 23451, 21345, 51234, 41235, 31245 are counted twice, and 12345 counted thrice.  Removing 10 duplicate permutations, we arrive at our final answer: 60 - 10 = 50.

The complete calculation is:  (10 * 3) * 2 * 1 - 10 = 50.


A table of all possible arrangements of 12345 (with the desired permutations highlighted) is shown below:


I am not 100% sure if there was a formula for answering this question - but here is a way to find such arrangements using brute force.  What inspired me to do pursue this question was this video published by Numberphile:

https://www.youtube.com/watch?v=CwIAfkuXc5A 

In this video, Simon Pampena arranges nine numbered cards and addressed how often those cards are arranged with at least four cards are in ascending or descending order.  However, Pampena does not the requirement that the ordered cards are arranged in consecutive slots.  


BTW, I am back from Seattle in Southern California.  

Have a great weekend - the rest of it - and I'll talk to you next time!

Eddie


 

Thursday, April 24, 2014

Greetings from Seattle - and a short review of the PCalc App. (Updated 4/28/2014)


I am in at the 1st Ave and Pike St Starbucks: the original Starbucks. Actually, the first one opened that first opened in 1971 moved to this location in 1976. The original Pike Place Brew is strong! Thankfully the coffee mellows after a while.

It is a dream of mine to blog from here. Thank you Starbucks! (Twitter: @starbucks)


Short Review of PCalc

This was recommend to me by bb010g. Thanks for the recommendation!

Prices:
PCalc Lite: Free (basic scientific calculator - Algebraic and RPN modes)
PCalc Full: $9.99 on iOS. (Includes Engineering functions, additional themes, conversions, programmer pack - base conversions and Boolean logic - each can be purchased separately)

Also available on Mac, but not available on Android devices.

Developer: James Thomson (Twitter: @jamesthomson)

I have the full version on both my iPad and iPod Touch. I like the intelligent layout of the keyboard, especially on the iPod Touch. The keys are big but you can still access all the major functions without much trouble. The choice of settings are plenty: everything from calculator settings to whether sound the keys make, if at all.

The features such as conversions, constants, and custom functions are accessed through the A>B, 42, and f(x) keys respectively. Each of the menus offers its options in a style consistent to standard iOS devices.

The calculator app has 10 memory registers and 16 other temporary registers that are used for programming. You can program custom functions. While the language does not contain loops, it does include relational testing (if true then skip n steps). Instead of working with the stack, you work with the memory and temporary registers, which takes a little getting used to. I hope to publish future posts explaining PCalc programming language in detail in the near future.

Here is a little sample of snippets I learned with the PCalc Programming:

The commands are constructed using proper English. (e.g. "Multiply M3 by M1", "Set R0 to 22/15")

Arithmetic Operators: Execute (add, subtract, multiply, divide) on a designated register with a certain value. The result is stored in the designated register.

Register X is the "display". Use this register to display your final answer. (Assuming your function has only one output).

To take the absolute value (on register X for example), execute the following steps:
Power X by 2
Power X by 0.5

PCalc is a great calculator app worth looking into. Website: http://www.pcalc.com

Update 4/28/2014:

Thanks to Terry for alerting me to this:  In Radians mode, cos(1.57079632) returned an answer of 6.7948967066 x 10^-9, which is not accurate.  Checking with Wolfram Alpha and with several calculators (HP 32Sii for example), cos(1.57079632) returns the correct answer of 6.7948966... x 10^-9.   Hopefully, this gets corrected in the next update.  

I checked cos(pi/2) and PCalc was accurate with answer of 0.

This ends my blog entry for now - off to see Seattle! Talk to you all soon! Thanks for the comments, recommendations, corrections, and compliments. As always, they are much appreciated.

Eddie


This blog is property of Edward Shore. 2014

Sunday, April 20, 2014

HP Prime: EC and BLOTCH - two programs using MOUSE and DRAWMENU


Happy Easter!
Happy 4/20 Day!
Happy Sunday!

These two programs for the HP Prime illustrate the use of DRAWMENU and MOUSE.

EC

Using DRAWMENU to draw a customized menu.

Functions featured:
head: 1st element of a list
tail: all elements of a list except the 1st
l2norm: L-2 norm of a vector
ker: kernel of a matrix
SPECRAD: spectral radius of a matrix
even: is the number even?


Input: EC(argument)

The argument needs to be appropriate type of what you want to do.

For head and tail: the argument needs to be a list.
For l2norm: the argument needs to be a vector.
For ker and SPECRAD: the argument needs to be matrix
For even: we need an integer

Examples:
EC({7,8,9}), choosing head will return {7} while tail returns {8,9}.
EC([7,2,6,9]) while choosing l2norm returns √170.
EC([[1,4],[-3,-12]]) while choosing ker returns [[4, -1]].
EC([[1, 4],[-3, -12]]) while choosing SPECRAD returns 13.0384048104 (approximately)
For even, a result of 1 indicates that the number is even and 0 if the number is odd.

Program:

EXPORT EC(x)
BEGIN
// CAS Custom Menu
// EWS 2014-04-20

LOCAL m,m1,mx,my;
WHILE MOUSE(1)≥0 DO END;
RECT;
TEXTOUT_P("Choose the function.",1,1,4);
TEXTOUT_P("head: 1st element of a list",1,18,4);
TEXTOUT_P("tail: all elements of a list except the 1st",1,35,4);
TEXTOUT_P("l2norm: L-2 norm of a vector",1,52,4);
TEXTOUT_P("ker: kernel of a matrix",1,69,4);
TEXTOUT_P("SPECRAD: spectral radius of a matrix",1,86,4);
TEXTOUT_P("even: is the number even?",1,103,4);

DRAWMENU("head","tail","l2norm","ker","SPECRAD","even");

REPEAT
m:=MOUSE;
m1:=m(1);
UNTIL SIZE(m1)>0;
mx:=m1(1);
my:=m1(2);

IF my≥220 AND my≤239 THEN

IF mx≥0 AND mx≤51 THEN
RETURN SUB(x,1,1);
END;

IF mx≥53 AND mx≤104 THEN
RETURN SUB(x,2,SIZE(x));
END;

IF mx≥106 AND mx≤157 THEN
RETURN exact(ABS(x));
END;

IF mx≥159 AND mx≤210 THEN
RETURN ker(x);
END;

IF mx≥212 AND mx≤263 THEN
RETURN CAS.SPECNORM(x);
END;

IF mx≥265 AND mx≤319 THEN
RETURN even(x);
END;

END;

END;

BLOTCH

Blotch Drawing Program

S = size of the square blotch
D = size of each box in the blotch. Each box is a randomized color.

To draw a square blotch, just touch the screen outside the menu.

Input: BLOTCH( )

Program:

EXPORT BLOTCH( )
BEGIN
// EWS 04-20-2014

// Initialize
LOCAL m,m1,mx,my,j,k,r;
WHILE MOUSE(1)≥0 DO END;

// Clear Canvas
RECT;
LOCAL s:=50, d:=4;

// Menu - to be redrawn
DRAWMENU("Clear","S+5","S-5","D+2","D-2","Exit");

// Start main loop
REPEAT

// Get mouse data
REPEAT
m:=MOUSE; m1:=m(1);
UNTIL SIZE(m1)>0;
mx:=m1(1); my:=m1(2);

DRAWMENU("Clear","S+5","S-5","D+2","D-2","Exit");

// Clear Screen
IF (my≥220 AND my≤319) AND (mx≥0 AND mx≤51) THEN
RECT;
END;

// Change Size
IF (my≥220 AND my≤319) AND (mx≥53 AND mx≤104) THEN
IF s<80 THEN s:=s+5; END;
END;

IF (my≥220 AND my≤319) AND (mx≥106 AND mx≤157) THEN
IF s>5 THEN s:=s-5; END;
END;

// Change Depth
IF (my≥220 AND my≤319) AND (mx≥159 AND mx≤210) THEN
IF d<8 THEN d:=d+2; END;
END;

IF (my≥220 AND my≤319) AND (mx≥212 AND mx≤263) THEN
IF d>2 THEN d:=d-2; END;
END;

// Exit Key
IF (my≥220 AND my≤319) AND (mx≥256 AND mx≤319) THEN
BREAK;
END;

// Draw Blotch
FOR j FROM mx-s/2 TO mx+s/2 STEP d DO
FOR k FROM my-s/2 TO my+s/2 STEP d DO
r:=RANDINT(1677215);
RECT_P(j,k,j+d-1,k+d-1,r);
END; END;

// Close main loop
UNTIL (my≥220 AND my≤319) AND (mx≥256 AND mx≤319);

RECT_P(0,220,319,239);
TEXTOUT_P("DONE!",146,220,4,#FF0000h);
WAIT(-1);
END;


As always, thank you for your comments, compliments, and questions. Happy Sunday everyone!

I will be heading to Seattle later this week - hope to blog from the Original Starbucks when I am there.


This blog is property of Edward Shore. 2014

Thursday, April 17, 2014

MAA Southern California-Nevada Section Spring Meeting: Highlights

Introduction

On April 12, 2014, I went to the Southern California-Nevada Section of the MAA Spring Meeting, held at Concordia University in Irvine, CA. It has been more than ten years since I last went to a meeting. It feels good to go back.

Link on to their website: http://sections.maa.org/socalnv/

Highlights

Hal Stern, University of Redlands talked about how statistics play a significant role in sports, and how it can be useful in measuring and predicting performance.

A student poster session, which lasted an hour. Given how excellent and engaging the student's posters were, I was only able to look at four in the hour given for the poster sessions, and I only wished that I looked at more.

After the poster session, Rachel Levy of Harvey Mudd College, spoke about her journey as a mathematician deals with the media. She states that good incidental communication is important because it form an impression on anyone who is listening.

Levy starts by emphasizing the need for mathematicians to communicate and be aware of how they communicate. Harvey Mudd requires all math majors take a public speaking class. The class has shown to have positive affects on her students. Levy also emphasize the use affirmations, such as saying to students "You are thinking like a math major," leading students to believe that they can join the mathematics community.

Levy stresses the need for positive communication. She challenges the often used saying "So easy even your grandmother can do it," implying the referred groups are seen as novices. This inspired her to start her blog, Grandma got STEM, which highlights grandmothers and their mathematical and scientific accomplishments. After communication with a librarian, her blog gained a significant increase in readers, leading to radio interviews world-wide.

Link to Grandma got STEM: ggstem.wordpress.com

Levy talked about how Twitter can be used to advertise positive messages regarding mathematics, advertising math blogs and events, and send thank you notes.

In the final part of the presentation, Levy describes her dealings with the general press, stating it is a risky proposition, as the press can easily distort the intended message (either intentionally or unintentionally). She gives tips include having your talking points prepared, thinking about the audience, having photographs and videos ready, and making sure the one takeaway point is said during the interview.

This is my favorite part of the spring meeting.

The next talk was given by Perla Myers, University of San Diego. Myers describe her mission to change the prevailing feelings of fear and distraught when people think of mathematics. She specializes in training future teachers to enhance mathematical understanding and introduce activities designed to make learning math enjoyable, such as the use of origami.

Jamie Pommersheim, Reed College, gave he final talk of the day. The topic: dissecting squares into triangles of equal areas.

It is possible to accomplish this task by using an even number of triangles, but what about odd number of triangles? This question was first addressed by Fred Richman, who at first posed this questions to his students. After finding out the difficulty of this task, he turned the question to American Mathematical Monthly publication.

It was later proved by Paul Monsky that splitting the square into an odd number of triangles of equal area was impossible. Pommersheim devoted the rest of his talk to describe why, using two approaches.

The first approach describes Monsky's proof. Pommersheim starts by describing the 2-adic norm which is described by:

|| n || = || 2^t * r/s || = 2^(-t)

Where n is a rational number, and r and s are odd integers. The 2-adic norm of 0 is defined to be 0.

Examples of calculating the 2-adic norms:
|| 6 || = || 2^1 * 3 || = 1/2 (t = 1)
|| 16 || = || 2^4 || = 1/16 (t = 4)
|| 5/8 || = || 1/8 * 5/1 || = || 2^(-3) * 5 || = 8 (t = -3)

Consider a square with corner points (0,0), (1,0), (1,1), and (0,1). Each corner point and any point that helps form triangles within that square is assigned a "color". For each point (x,y), the color is assigned as follows:

The color A is assigned if:
* x has the largest 2-adic norm or
* x at least as big of 2-adic norm of either y or 1.

The color B is assigned if:
* y has the biggest 2-adic norm or
* the 2-adic norm of y is 1 and x has a 2-adic norm is less than 1.

The color C is assigned if both x and y have 2-adic norms less than 1.

For the corner points, the following colors are assigned:
(0,0) has the color C
(1,0) has the color A
(1,1) has the color A
(0,1) has the color B

It is next shown that three collinear points cannot have all three colors A, B, and C. Consider the three points (0,0), (x1, y1), and (x2, y2). Point (0,0) is assigned the color C.

The area of a general triangle can be calculated by:

Area = 1/2 * det([[x1, y1, 1],[x2, y2, 1],[x3, y3, 1]])

Using this formula above, the "area" is x1*y2 - x2*y1. We know the area of any line is 0. Hence, x1*y2 - x2*y1 = 0. And:

Show that a straight line can contain points of only two colours.

x1*y2 = x2*y1

Taking the two 2-adic norms of both sides to get:

|| x1*y2 || = || x2*y1 ||
|| x1 || * || y2 || = || x2 || * || y1||

This implies that both points must be assigned the same color which contradicts the assumption that a line made of three collinear points can have three different colors.

The proof goes on to use Sperner's Lemma, which states (briefly) given any dissection of square there exists of a tricolored triangle. Also, the 2-adic norm of an area of tricolored triangle is greater than 1. However, if the square is divided into an odd number of triangles, the 2-adic norm of each triangle is 1.

Pommersheim shows a second way to demonstrate that squares cannot be cut into an odd number of equal area triangles. He uses finds a polynomial of areas that is associated with each dissection.

For a square dissected into four triangles, the associated polynomial is
D + B - (A + C), which A, B, C, and D represent the areas for each triangle. In this case each area of the triangle is n/4 where n is the area of the square. Clearly, n/4 + n/4 - (n/4 + n/4) = 0, which is the desired result.

For a square dissected into six triangles the polynomial becomes:
(A + C + E)^2 - 4*A*B - (B + D + F)^2 + 4*D*F.

Substituting n/6, the area of each triangle in this case, and the value of the polynomial is 0.

Pommersheim eliminates triangle B. Now we have five triangles, each with area n/5. The polynomial becomes:
(A + C + E)^2 - 4*A*C - (D + F)^2 + 4*D*F

The trouble comes when we evaluate the polynomial with each area n/5, which leaves the value n^2/5. This shows that it is impossible to divide a square into an odd number of triangles of equal area.


There it is. I hope you find this enjoying, informational, and inspiring. I look forward to going to the next one. Until next time,

Eddie



This blog is property of Edward Shore. 2014

HP Prime Video: Scatterplots


A simple video on how to plot scatter plots on the HP Prime:


http://youtu.be/Q9E0ovCRMQc


This blog is property of Edward Shore. 2014

Monday, April 14, 2014

Program - HP 32SII: Stopping Sight Distance

Background: The stoping sight distance is the distance traveled when a person operating perceives the need to the stop and stops the vehicle. The velocity used in calculating stopping sight distance is the referred to as the design speed. The stopping sight distance is the sum of two parts:

1. Reaction Distance, which is the distance while the operator perceives the need to stop, and

2. Breaking Distance, which is the distance traveled while the operator puts the breaks on the vehicle, slowing the vehicle to a stop.

The general formula is:

SSD = v * t_r + v^2/(2*(a + g*G))

where:
v = the design speed of the vehicle
t_r = perception-reaction time
a = deceleration rate of the vehicle
g = gravity constant (32.174 ft/s^2 or 9.80665 m/s^2)
G = grade of the road. Grade is positive for uphill roads. If a road has a grade of 1%, it means for every 100 ft travelled horizontally, the road has risen 1 ft. In this formula, grade is given as a percentage (i.e. 1%, G = 1)

The AASHTO (American Association of State Highway and Transportation Officials) recommends t_r = 2.5 seconds and a = 11.2 ft/s^2.

The formula for SSD using U.S. units and recommended constants is given as:

SSD = 55/15 * v + (1.075*v^2)/(11.2 + 0.32*G)

Where velocity is given in mph. The HP 32sII program given below has the U.S. Formula.

Source: Goswami, Indramil Ph.D. P.E. "All In One Civil Engineering PE Breadth and Depth Exam Guide" 2nd Edition. McGraw Hill: 2012


PROGRAM

Input:

Y: speed of vehicle or design speed (mi/hr)
X: grade of the road (i.e. for 1% grade enter as 1)

Output:

X: Stopping Sight Distance (in feet)

Formula used:
SSD = 55/15 * V + 1.075*V^2/(11+.32*G)

Assumptions:
* Total reaction time is 2.5 seconds. The deceleration rate of the vehicle is 11 ft/s^2. Both values are recommended by the AASHTO (American Association of State Highway and Transportation Officials).

Program:

S01 LBL S
S02 0.32
S03 *
S04 11.2
S05 +
S06 1/x
S07 1.075
S08 *
S09 x<>y
S10 ENTER
S11 R-down
S12 x^2
S13 *
S14 R-up
S15 55
S16 *
S17 15
S18 ÷
S19 +
S20 RTN


Examples:

Input:
Y: 65 (V)
X: 2 (G)
Result (Fix 4): 621.9376 ft

Input:
Y: 35 (V)
X: -4 (G)
Result: 261.0828



This blog is property of Edward Shore. 2014


Thursday, April 10, 2014

BASIC Programming Language Turns 50 on May 1

Thanks to Don Shepherd sharing this at the MoHPC website, here is the information regarding BASIC's 50th birthday! The programming language was born at Dartmouth College in Hanover, NH. John Kemeny and Thomas Kurtz were the original developers.

https://www.dartmouth.edu/basicfifty/


#programming #math



This blog is property of Edward Shore. 2014

HP 71B Basic and Casio fx-CG 100: Weighted Random Sample

HP 71B Basic and Casio fx-CG 100: Weighted Random Sample Introduction In calculators, it is fairly easy to generate a rand...