Sunday, February 20, 2022

HP 48GX and HP 12C: Continued Fractions

HP 48GX and HP 12C: Continued Fractions


Continued Fractions


A continued fraction is a nested fraction in the form, shown in a linear fashion:


a_0 + 1 ÷ (a_1 + 1 ÷ (a_2 + 1 ÷ (a_3 + 1 ...    ÷ (a_n-1 + 1 ÷ a_n  ) ... )


Below are two examples of continued fractions:





HP 48GX Program: CNFRC


Instructions:


1.  Clear the stack.

2.  Enter values from a_0, a_1, a_2, to a_n.

3.  Run CNFRC


Program:

<< DEPTH 1 - 1 SWAP START INV + NEXT EVAL >>


Example 1 (refer to the above):  


Input: Clear the stack, 5, ENTER, 3, ENTER, 7, run CNFRC

Output:  5.31818181818


Example 2 (refer to the above):


Input:  Clear the stack, 6, ENTER, 4, ENTER, 2, ENTER, 5, run CNFRC

Output:  6.22448979592


HP 12C Program: Continued Fractions


1.  Enter a_n, ENTER a_n-1

2.  Press [ R/S ]

3.  Work backwards, enter a_n-2, press [ R/S ] until the end


Program:  (step, key code, key)

01   34   x<>y

02   22   1/x

03   40   +

04   43,33,00   GTO 00*


*43,33,000 GTO 000 for HP 12C Platinum


For the examples, the HP 12C set to FIX 5


Example 1 (refer to the above):  


Input:  7, ENTER, 3, R/S, 5, R/S

Output:  5.31818


Example 2 (refer to the above):


Input:  5, ENTER, 2, R/S, 4, R/S, 6, R/S

Output:  6.22449


March Madness Sweet Sixteen Calculus 


In the spirit of college basketball's March Madness, I will be posting a calculus post each day from March 16 to March 31, 2022.  


Going On a Break


I am going on a blog break.  This blog is a one-person band, me, all done on spare time between family, a full time job, relationships, and possibly some house repairs.  I am grateful for everyone who reads, subscribes, and enjoys my blog, it is an absolute joy to do.

Next blog entry is on March 12, 2022.

Thank you.  


Eddie 


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, February 19, 2022

Casio fx-9750GIII: 0-1 Knapsack Problem

Casio fx-9750GIII: 0-1 Knapsack Problem


What Do I Take?


Imagine you are given a list of objects, which each object has its profit value and it's associated weight.  You are given a knapsack, which is also known as a backpack, which can carry a limited amount of weight.  Your task is to select the objects with the most value that can fit in the knapsack.


In a 0-1 Knapsack Problem, each object can not be broken up into pieces.  There is a problem where that is allowed, known as the Fractional Knapsack Problem.  


One approach is to use what is known as the greedy algorithm.  In the greedy algorithm, you select the best choice at the moment at each step.   Once an object is selected, you go on to the next step.  There is no reverse or correction.  The greedy algorithm lives by the philosophy of "no regrets".  


Please be aware, even with attempt to select the best choice at each step, we may still not have the optimal solution.   


You can choose which criteria is used for selecting the best option.  For the program 01KNAPS, this criteria is used:


1.  The maximum ratio value of value to weight

2.  If the ratio is a tie, the maximum value 


Introduction to the Program 01KNAPS - Casio fx-9750GIII


Inputs:

List of Values of Each Object:  stored in List 10

List of Weights of Each Object:  stored in List 11

Capacity of the Knapsack:  stored in M


Outputs:

Total Value/Profit Made:   stored in P

Weight Remaining:  stored in M

A matrix showing which objects are selected, along with their weights, and value to weight ratio.   Columns are stored in List 14, List 15, and List 16, respectively.  Zeroes mean that the object is not selected.  


Notes:


The Wait Loop


The program starts with an intro screen created with several Locate statements and a For loop used as a "Wait".   This is 100% optional and serves to tell the user what program they are running.


A "Wait" Loop:

For I→1 To 750 (or a suitable number to create a short wait, 1/4 to 1/2 second)

Next


I aim to give a title screen to programs when possible.  


The SortD Function


In the MENU-LIST function in the program editor screen, we can sort lists by using the SortA (ascending) or SortD (descending).   We can sort a list by itself, or a list using up to five sub-lists.  The sorted lists are saved automatically.


It's not perfect, but it's better than nothing.


By the way, the function can be found in the CATALOG in certain times:  in the program editor or in the RUN-MAT mode (main) if the Linear Input is selected.   


Casio fx-9750GIII Program:  01KNAPS

(452 bytes)


ClrText

Locate 1,1,"0-1 KNAPSACK"

Locate 1,2,"PROBLEM BY"

Locate 1,3,"GREEDY ALG"

Locate 1,4,"EWS 2022-01-08"

For 1→I To 750

Next


ClrText

"LIST OF VALUES"?→List 10

"LIST OF WEIGHTS"?→List 11

"CAPACITY"?→M

List 10→List 12

0→P

List 10÷List 11→List 12

Dim List 12→Dim List 13

SortD(List 12, List 10, List 11)


For 1→I To Dim List 10

If List 11[ I ]≤M

Then

List 10[ I ]+P→P

M-List 11[ I ]→M

1→List 13[ I ]

IfEnd

Next


List 13×List 10→List 14

List 13×List 11→List 15

List 13×List 12→List 16


ClrText

Locate 1,3,"TOTAL VALUE:"

Locate 3,4,P

Locate 1,6,"WEIGHT LEFT:"

Locate 3,7,M◢

List→Mat(List 14,List 15,List 16)


Examples


Example 1:

Values:  {5, 3, 8, 4, 8, 4, 8}

Weights: {1, 1, 2,4, 2, 2, 4}

Capacity: 10


Total Value:  28

Weight Left: 2

[ [ 5, 1, 5 ]

[ 8, 2, 4 ]

[ 8, 2, 4 ]

[ 3, 1, 3 ]

[ 4, 2, 2 ]

[ 0, 0, 0 ] 

[ 0, 0, 0 ]]



Example 2:

Values: {20, 24, 22, 30, 25, 30}

Weights: {4, 6, 2, 6, 5, 5}

Capacity: 15


Total Value: 72

Weight Left: 4

[[22, 2, 11]

[30, 5, 6]

[20, 4, 5]

[0, 0, 0]

[0, 0, 0]

[0, 0, 0]]


Source


"Basics of Greedy Algorithms"  HackerEarth. 2022.  https://www.hackerearth.com/practice/algorithms/greedy/basics-of-greedy-algorithms/tutorial/   Retrieved January 6, 2022.


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Monday, February 14, 2022

Casio fx-5800P: Convert to Fractions by Pierre Gillet

 Casio fx-5800P: Convert to Fractions by Pierre Gillet


The program on this blog entry are created and authored by Pierre Gillet.   Gratitude for his permission to post this on my blog.  The program FRAC will show successful approximations of fractions.  Note, the program uses 30 additional registers by the DimZ command.  


Take it away, Pierre.


Casio fx-5800P FRAC and Notes


    Casio fx-5800P:

    "FRAC":

    ?X : Abs(X)->Z

    30->DimZ : 0->W

    Lbl 1    

    W+1->W

    Int(Z)->Z[W]

    Z[W]->R : 1->S

    For W-1->I TO 1 Step -1

    R->T

    Z[I]*R+S->R : T->S

    Next

    Cls : Locate 1,1,R

    Locate 1,2,"÷"

    Locate 2,2,S

    Locate 1,3,"="

    Locate 2,3,R/S

    Locate 1,4,R/S-Abs(X)◢

    1/Frac(Z)->Z

    Goto 1


Notes:


     ?X is allowed on the fx-5800P:   When executed, the last value of X is shown which can be accepted or replaced. It doesn't work for the Casio graphing calculators. 

     The program works with the absolute value of X

     The program uses 30 DimZ extra memories (from Z[1] to Z[30]) by default; If it's not enough, it will display "Dimension ERROR"

     The program pauses displays pauses after each step, displaying 4 lines per step, until it suits you:

         Numerator

         Denominator

         Result of the division of Numerator by Denominator

         Absolute error, compared to absolute value of X

For example, at the 4th step with X=Pi, the program will display:


         355

         ÷113

         =3.14159292

         2.6676418x10^-7


     The fx-5800P doesn't allow "A=";A  to display "A=8"  (if A=8) 


BUT you can bypass this using Locate <Column>, <Row>, <String or Variable>

For example, in order to display "A=8"  (if A=8)  at the beginning of the first row of the display, do:


     Locate 1,1,"A="

     Locate 3,1,A



Examples


0.675 -> 27/40 after 4 steps  


2.08080808 -> 26,010,101/12,500,000 with approximately 0 difference


1.37456356 -> 1,812,138/1,318,337  with approximately 0 difference 



Thank you to Pierre Gillet.


Eddie 


All original content copyright, © 2011-2022.  Edward Shore.  Programs provided by Pierre Gillet with permission, © 2022.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Retro Review: Casio fx-4000P

Retro Review:   Casio fx-4000P





Quick Facts:


Model:  fx-4000P

Company:  Casio

Years:  1985 - 1989

Battery:  2 x CR2032

Display:  10 digits, 2 digit exponent

Logic:  Algebraic - type in expressions the way you write them

Memory:  Up to 550 programming steps or up to 94 memory registers

Contrast Wheel

Wallet with operation guide (if included, depends on where you buy from)


The Casio fx-4000P holds up its value as it is a popular vintage programming calculator. Prices are about $30 US and above.  

 

Features


Four Basic Modes:


* COMP:  Computer Mode, general calculations


* BASE-n:  Base conversions in the standard four bases decimal, binary, octal, and hexadecimal.  Boolean functions and, or, not, and neg are included.   Binary numbers have a 32 bit capacity, in 4 blocks of 8 each.  


*  SD:  Single Variable statistics


*  LR:  Linear Regression, y = A + Bx


Statistics Variables:

U = Σx^2

V = Σx

W = n

P = Σy^2

Q = Σy

R = Σxy


A = y-intercept

B = slope

r = correlation


As with many Casio calculators, the rectangular and polar conversions store their results in two variables.   For the fx-4000P:


Pol(x,y) stores r in I, Θ in J

Rec(r,Θ) stores x in I, y in J


This is the same as the Casio current fx-5800P.  


The fx-4000P has integer part (Int), fractional part (Frac), and absolute value (Abs).  


Memory and Arrays


The Defm mode allows the user to set the number of memory registers.   The minimum amount of memory registers is 26 (A - Z).   The user can add additional registers at a cost of 8 programming steps each, up to 94 memory registers (leaving only 6 programming steps).   


The fx-4000P allows for indirect storage, which takes the form of:


letter[# of steps from that letter]


For example:

A[0] returns what is stored in A,

A[1] returns what is stored in B,

A[2] returns what is stored in C,

and so on.


By allocating additional registers, 

Z[1] returns what is stored in the 27th register,

Z[2] returns what is stored in the 28th register,

Z[3] returns what is stored in the 29th register,

and so on. 


Variables are allowed.  For example, if 2 is stored in I,  then:


15 → A[ I ] stores 15 in C (2 steps from A).

  

The tilde command is allows us to store a value in multiple registers.  The tilde acts like a Fill function.


For example:  12 → A ~ D  stores 12 in A, B, C, and D.  


Programming


The programming mode of the fx-4000P has a capacity of 550 steps, which can be allocated into 10 slots, Prog 0-9.   The maximum step capacity is reached when the minimum of memory registers is set, 26.  (Defm 0).  The language is Casio Basic:


:

colon that ends each line (except for ◢)


→   

store 


◢  

stop and display (Disp indiciator lights up)


Goto/Lbl #   

up to 10 lables 0-9


Isz var  

increment var by 1 and skip next command if var = 0


Dsz var

decrement var by 1 and skip next command if var = 0


Use Isz and Dsz to simulate For-Next loops


[test]  ⇒ [do if true, skip if false] : [ next command ]

simple If/Then jump structure (displayed on the keyboard is a solid, bold arrow)


Prompting is a little different, as the string must be followed by a colon, then a question mark is used:

"prompt" : ? → var


Example:   Prompt for the user to enter an angle and store it A.   

"ANGLE" : ? → A


We can display a string for a brief pause, simulating a Wait command by this:

"time" → var : Lbl # : "string" : Dsz var : Goto # 


For example, the string "45" is displayed for 25 counts:

25 → I : Lbl 1 : "45" : Dsz I : Goto 1


Strings can also contain the characters engineering symbols k, m, μ, n, p (but not use these in calculations), a solid square, and the angle symbols °, ^r, and ^g (which also allow the user to override the current angle). Strangely, the symbols Θ and % are not included.  


The use of Prog (key is labeled [Prg]) in programs will allow for the use of subroutines.  For subroutines, an implied Return command is added to the end of the subroutine.  


To save space, use → without closing all the parenthesis.  The Ans (last answer) can also be used in between steps.   In COMP mode, pressing equals closes all pending parenthesis.  


The programming structure of the fx-4000P, along with the fx-7000g and fx-6300g,  provide a base for future Casio programming and later graphing calculators.  


Sample Programs:

(spaces and returns provided for readability)


PO:  Σ( (A*x+B)^C from x = 0 to N )

(65 steps)


"A" : ? → A :

"B" : ? → B :

"C" : ? → C :

"N" : ? → N :

0 → S :

Lbl 1 :

S + (A N + B) x^y C → S

Dsz N : Goto 1 : 

S + B x^y C → S


Examples: 

A = 2, B = 6, C = 2, N = 4;  Result = 540

A = 5, B = -2, C = 3, N = 5;  Result = 20727


P1:  Payment of a Mortgage

(64 steps)

P = loan amount

R = periodic rate

N = number of payments

M = payment 

Cash flow convention is followed.


Fix 2 :

"PV" : ? → P :

"RATE" : ? → R :

"N" : ? → N :

.01 R → S :

"PMT" ◢

-P S ÷ (1 - (1 + S) x^y ( -N → M ◢

Norm


Example:

Monthly payment of a $320,000.00 loan at 4% annual for 30 years.

P = 320000, R = 4 ÷ 12, N = 30 × 12; Result -1527.73  (payment of $1,527.73)


If you want to a series of programs for the fx-4000P and possible what they would look like for the fx-5800P/graphing calculators, please let me know in the comments. 


Closing Thoughts


The Casio fx-4000P is a good, entry level programmable calculator which includes a good amount of programming steps.  


The fx-4000P reminds me of the current Casio fx-3650P(II) and what the latter lacks.   I wish the next incarnation of the fx-3650P had the integer, fractional, absolute value, and the ability to use strings with the full alphabet.   The only advantage the fx-3650P has is the derivative, integral, and fractions. 


The fx-4000P runs decently fast and the screen has a big display of characters and results, and it holds up as a favorite.  


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 



Sunday, February 13, 2022

TI-84 Plus CE Python (and TI Basic): Rounding vs. Truncating

TI-84 Plus CE Python (and TI Basic):  Rounding vs. Truncating 


Rounding vs Truncating:  Introduction


The program ROUNDING and the Python script rounding.py takes two numbers and estimates one of four arithmetic operations (+, - , ×, ÷).   


Rounding:  rounds a real number to the nearest integer.  The traditional 5/4 rules are applied.  In the case of the integers:  for all numbers with fractional parts of 0.5 and above (to 0.9999...), the integer is rounded up.   


Truncating:  the fractional part of the number is dropped.  


For example:


round(14.2) -> 14

round(14.5) -> 15

round(14.7) -> 15


trunc(14.2) -> 14

trunc(14.5) -> 14

trunc(14.7) -> 14


This results are shown in text form (Python program) or stored in a matrix:


[ [ x and y are rounded individually before the arithmetic operation, percent error ]

[ x and y are truncated individually before the arithmetic operation, percent error ]

[ result is rounded after the arithmetic operation, percent error ]

[ result is truncated after the arithmetic operation, percent error ] ]


The rounding percent program allows the user to compare rounding methods.


TI-84 Plus CE Python:  Python script rounding.py


from math import *

#  rounding comparison

#  2021-12-21 EWS


# rounding

def rd(x):

  return int(x+0.5)


# truncate

def tr(x):

  return int(x)


# percent change

def pc(x,y):

  return (y-x)/x*100


print("integer rounding arithmetic")

pirnt("x [+,-,*,/] y")

x=eval(input("x>0, x? "))

y=eval(input("y>0, y?  "))

print("1 + 2 - 3 * 4 / ")

op=float(input("Operation? "))


# test, force error

if op<1 or op>4:

  print("not a valid operation")

  1/0


# operations

if op==1:

  a=rd(x)+rd(y)

  b=tr(x)+tr(y)

  c=rd(x+y)

  d=tr(x+y)

  z=x+y


if op==2:

  a=rd(x)-rd(y)

  b=tr(x)-tr(y)

  c=rd(x-y)

  d=tr(x-y)

  z=x-y


if op==3:

  a=rd(x)*rd(y)

  b=tr(x)*tr(y)

  c=rd(x*y)

  d=tr(x*y)

  z=x*y


if op==4:

  a=rd(x)/rd(y)

  b=tr(x)/tr(y)

  c=rd(x/y)

  d=tr(x/y)

  z=x/y


print("results")


print("rounding individual")

print(str(a)+" ,"+str(pc(z,a))+"%")


print("truncate individual")

print(str(b)+" ,"+str(pc(z,b))+"%")


print("rounding result")

print(str(c)+" ,"+str(pc(z,c))+"%")


print("truncate result")

print(str(d)+" ,"+str(pc(z,d))+"%")


TI-84 Plus CE Python (TI-Basic):  ROUNDING


"2021-12-21 EWS"

Disp "INTEGER ROUNDING ARITHMETIC","X [+,-,*,/] Y"

Input "X>0, X? ",X

Input "Y>0, Y? ",Y

iPart(X+.5)→N

iPart(X)→S

iPart(Y+.5)→J

iPart(Y)→T

Menu("OPERATION?","X+Y",1,"X-Y",2,"X*Y",3,"X/Y",4)

Lbl 1

N+J→A

S+T→B

X+Y→Z

Goto 5

Lbl 2

N-J→A

S-T→B

X-Y→Z

Goto 5

Lbl 3

N*J→A

S*T→B

X*Y→Z

Goto 5

Lbl 4

N/J→A

S/T→B

X/Y→Z

Goto 5

Lbl 5

iPart(Z+.5)→C

iPart(Z)→D

ClrHome

Disp "ROUND IND","TRUNC INC","ROUND RESULT","TURNC RESULT"

Wait 0.5

Pause [[A,(A-Z)/Z*100][B,(B-Z)/Z*100][C,(C-Z)/Z*100][D,(D-Z)/Z*100]


Examples


17.36+56.19

Rounding Individual:  73, -0.7477906186%

Truncate Individual:  73, -0.7477906186%

Rounding Result:  74, 0.611828688%

Truncate Result: 73, -0.7477906186%


82.8 - 17.9

Rounding Individual:  65, 0.1540832049%

Truncate Individual:  65, 0.1540832049%

Rounding Result:  65, 0.1540832049%

Truncate Result: 64, -1.386748844%


9.28 * 10.26

Rounding Individual:  90, -5.474894132%

Truncate Individual:  90, -5.474894132%

Rounding Result:  95, -0.2234993614%

Truncate Result: 95, -0.2234993614%


46.5 / 1.5

Rounding Individual:  23.5, -24.19354839%

Truncate Individual:  46, 48.38709677%

Rounding Result:  31, 0%

Truncate Result: 31, 0%


It just goes to show, rounding or truncating numbers before calculation may give results that aren't as accurate as one would like.  The following paper, "Rounding versus truncation estimates in difference calculations" by Leonard Van Wyk (see source) argues that sometime truncation is more accurate than rounding in subtraction problems.   


Source


Van Wyk, Leonard   "Rounding versus truncation estimates in difference calculations"  The Mathematical Gazette, Volume 103, Issue 557, July 2019.  pp 285 -292



Eddie 


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, February 12, 2022

Even and Odd Integers in Arithmetic

Even and Odd Integers in Arithmetic


Introduction


Let n and m be integers, where:  


n = ..., -3, -2, -1, 0, 1, 2, 3, ...

and 

m = ..., -3, -2, -1, 0, 1, 2, 3, ...


An even integer is any integer that can evenly divided by 2, without remainder.  Hence, if p is an even integer, then p = 2 ∙ n


An odd integer is any integer that can not be evenly divided by 2  (remainder 1).  In this case:  p = 2 ∙ n + 1


Addition


Adding two integers will result in an integer.  


even + even = even


2 ∙ n + 2 ∙ m  

= 2 ∙ (n + m)


odd + odd = even


(2 ∙ n + 1) + (2 ∙ m + 1)

= 2 ∙ n + 2 ∙ m + 2

= 2 ∙ (n + m + 1)


even + odd = odd


(2 ∙ n) + (2 ∙ m + 1)

= 2 ∙ n + 2 ∙ m + 1

= 2 ∙ (n + m) + 1


Multiplication 


Multiplying two integers will result in an integer.  


even × even = even


(2 ∙ n) ∙ (2 ∙ m)

= 2 ∙ (n ∙ m)


odd × odd = odd


(2 ∙ n + 1) ∙ (2 ∙ m + 1)

= 4 ∙ m ∙ n + 2 ∙ n + 2 ∙ m + 1

= 2 ∙ ( 2 ∙ m ∙ n + n + m) + 1


even ×  odd = even


(2 ∙ n + 1) ∙ (2 ∙ m)

= 4 ∙ m ∙ n + 2 ∙ m

= 2 ∙ (2 ∙ m ∙ n + n)


even^2 = even


(2 ∙n)^2 

= 4 ∙ n^2

= 2 ∙ (2 ∙ n ∙ n)


odd^2 = odd


(2 ∙ n + 1)^2

= 4 ∙ n^2 + 4 ∙ n + 1

= 2 ∙ (2 ∙ n ∙ n + 2 ∙ n) + 1


 

Eddie 


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Monday, February 7, 2022

Retro Review: Casio fx-991H

Retro Review:   Casio fx-991H








Quick Facts:


Model:  fx-991H

Company:  Casio

Years:  My guess would be the late 1980s-early 1990s

Memory Register:  1 independent memory, 6 registers

Battery:  Solar with battery back up (GR927)

Display:  10 digits, 2 digit exponent

Logic:  Algebraic 


The fx-991H works best when in full or almost full light.


Features


The fx-991H is similar to the fx-115D SUPER FX except:


*  The fx-991H has 32 built in scientific constants, based on ISO Standards of 1980 and (Japan Industrial Standards) of 1985.  Trust me, most values of the scientific constants do not change much.


* The fx-991H has a hard case cover instead of the pocket cover.  Personally, I like the hard case.


I also like the feel of the keyboard, I can feel definite clicks when I press the buttons.  


Here is a quick run down what you get with the fx-991H:


*  Six additional registers through Kin/Kout.   Kin is the shifted command of the [ Kout ] key.  Storage arithmetic is permitted (yay!).  For registers 1 through 6:


Addition:   x [ SHIFT ] ( Kin ) [ + ] K#

Subtraction:  x [ SHIFT ] ( Kin ) [ - ] K#

Multiplication:  x [ SHIFT ] ( Kin ) [ × ] K#

Division:  x [ SHIFT ] ( Kin ) [ ÷ ] K#


*  Constant arithmetic.  To use it, the arithmetic key must be pressed twice.


Addition:  x [ + ] [ + ] a [ = ], b [ = ], ....   for a + x, b + x, ....

Subtraction:  x [ - ] [ - ] a [ = ], b [ = ], ....   for a - x, b - x, .... 

Multiplication:  x [ × ] [ × ] a [ = ], b [ = ], ....   for a * x, b * x, ....

Division:  x [ ÷ ] [ ÷ ] a [ = ], b [ = ], ....   for a / x, b / x, ....


*  Percent Function, [ SHIFT ] [ = ] ( % ).  This percent function operates like a lot of the Casio basic calculators.  


What is n% of y?   y [ × ] n [ SHIFT] [ = ] ( % )

What is percent portion of part n of total y?   n [ ÷ ] y [ SHIFT ] ( % )

Percent difference from n to y?  n [ - ] y [ SHIFT ] ( % )

Add n% to y:   y [ × ] n [ SHIFT ] [ = ] ( % ) [ + ]

Subtract n% from y:  y [ × ] n [ SHIFT ] [ = ] ( % ) [ - ]

Find the percent ratio of (n + y)/y:  n [ + ] y [ SHIFT ] [ = ] ( % )



*  Engineering Mode, where all answers are displayed in the form of x ee, 

(x * 10^ee, ee is a multiple of 3).   We also have use of engineering constants (M for mega, G for giga, T for tera, etc.)


*  Base Conversions with Boolean functions.  The standard set of functions are present (AND/NOT/OR/XOR/XNOR/NEG) with the standard set of bases (HEX/DEC/OCT/BIN)


*  Statistics with Linear Regression.   


A =  constant term  (y-intercept)

B =  regression coefficient (slope)

r =  correlation


y = A + Bx


*  Complex Mode.   Complex mode is limited to arithmetic, independent variable storage, argument, absolute value


*  Fractions.  Simplification is automatic.  


*  Decimal/DMS conversions.   Convert all numbers in DMS (degrees-minutes-seconds) to decimals before operating.  


*  Hyperbolic functions.


*  Scientific Constants.  There are 32 scientific constants, accessed through the [ CONST ] key or the [ SHIFT ] [ CONST ] key combination.  Constants are stored in the keys 0-9, ., EXP, +, -, ×, ÷.   


Examples:


Speed of Light, [ CONST ]  [ 1 ]:  299792458 m/s


Earth's Gravity Constant, [ CONST ] [ + ]:  9.80665 m/s^2


Universal Gravity Constant, [ CONST ] [ 3 ]:  6.672 * 10^-11 N m^2/kg^2


Fine-Structure Constant, [ SHIFT ] [ CONST ]  [ 3 ]:  7.2973506 * 10^-3  (unitless)


Stefan-Boltzmann Constant, [ SHIFT ] [ CONST ] [ × ]:  5.67032 * 10-8 W/(m^2 K^4)


For a full list of the 32 constants:  

https://drive.google.com/file/d/1r0OP-R9wddhqo0xrsQfL26eJx8FkNolD/view?usp=sharing


I checked with the manual to be sure that these are constants and it checks out.


Closing Thoughts


I really like this keyboard.  It is clean and the keys are very responsive.  The display is sharp.   I am happy to add this calculator to the collection.  Prices vary, I think I got mine for about $13 U.S., but I have seen prices on the internet go as high as $40 U.S.  


I like how Casio puts a lot of features and makes calculators more affordable.  This is a good brand to consider if you need to get the most bang for your buck.  You also get good quality of calculator.


If you want to see my review of the fx-115D SUPER FX from 2014:

http://edspi31415.blogspot.com/2014/09/retro-casio-fx-115d-super-fx.html


Until next time,


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Sunday, February 6, 2022

HP 17BII+ and TI-84 Plus CE Python: Zeta Approximation

HP 17BII+ and TI-84 Plus CE Python:  Zeta Approximation


Zeta Function


zeta(x) = Σ(1 ÷ (n^x), n =1 to ∞)


We are going to use the approximation:


zeta(x) = Σ(1 ÷ (n^x), n =1 to w) where w = intg(10^((a + 2) ÷ x)


where a is the number of decimal places desired.  The higher the accuracy, the longer the calculation takes.  Also the lower x is, the longer the calculation takes.


This is for all x > 0.


HP 17BII+ Formula ZETA


ZETA=0×L(W:10^IP((ACC+2)÷X))+Σ(N:1:G(W):1:INV(N^X))


Examples:


ACC =3, X = 2;  Result:  ZETA = 1.63


ACC =3, X = 3.5;  Result:  ZETA = 1.13


ACC =3, X = 8.7;  Result:  ZETA = 1.00


TI-84 Plus CE Python:  zeta.py


# 2021-12-07 ews

# zeta function approximation

from math import *

print("zeta function approximation")

x=eval(input("x? "))

a=eval(input("# places? "))

w=int(10**((a+2)/x)

z=0

n=1

while n<w:

  z+=(n**x)**-1

  n+=1

z=round(z,a)

print("zeta = "+str(z))


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, February 5, 2022

TI-84 Plus CE Python: Evaluation and Integration

 TI-84 Plus CE Python: Evaluation and Integration


Introduction


The two scripts presented in today's blog will make use of Python's built in commands input and eval, to allow the user to enter equations and expressions as inputs.


Using input itself defaults whatever is entered as a string.   If the string is an equation, it will allow for the eval command to evaluate the formula.


Using the eval-input combination will allow the user to enter numerical expressions as well as numbers.   This allows pi as an input, something I wasn't able to do with the float-input combination.  


To allow for math functions including the use of π, I imported the standard math module.


You can download the app variables for the TI-84 Plus CE Python here:

https://drive.google.com/file/d/1Kzly9LjxQg0WrT0XLpdgL8yArGaggaCW/view?usp=sharing


The scripts are presented below.


evaluate.py




# evaluate.py

# 2021-11-29 EWS

from math import *

ch=0

fx=input("f(x)= ")

while ch==0:

  x=eval(input("x? "))

  y=eval(fx)

  print("f(x)= "+str(y))

  print("--------")

  print("Quit? ")

  ch=float(input("0: no,1: yes  "))


Example:

f(x) = exp(.5*sin(x))

x = 0.2, f(x) = 1.104435854

x = 0.6, f(x) = 1.326204677


integral.py





# integral.py

# 2021-11-29 EWS

# Simpson's Rule

from math import *

fx=input("f(x)= ")

a=eval(input("lower? "))

b=eval(input("upper? "))

n=eval(input("n (even)? "))


x=a

t=eval(fx)

x=b

t+=eval(fx)


h=(b-a)/n

for i in range(1,n):

  x=a+i*h

  if i/2-int(i/2)==0:

    t+=2*eval(fx)

  else:

    t+=4*eval(fx)


t*=h/3

print("integral = "+str(t))


Examples:

f(x) = 1/3*sin(x/pi)

lower = 0

upper = 2*pi

n = 10,  integral = 1.482985499


f(x) = (x+1)**(-1)*(x+3)**(-1)

lower = 1

upper = 5

n = 10,  integral = 0.2027325541


The eval command has opened up more possibilities,


Eddie 


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


RPN with HP 15C & DM32: Swapping Items in the Stack

RPN with HP 15C & DM32: Swapping Items in the Stack A New Series Welcome to a new series: RPN with the HP 15C & DM32. ...