Sunday, May 28, 2023

HP Prime: Integer Ratios and Integer Density

HP Prime:  Integer Ratios and Integer Density




How Many Integers Fit the Criteria?


The program INTDENS calculates the ratio of integers to a range of integer that fit a criteria.   The seven ratios that the program offers are:


1.  The number of odd integers over the range of integers


2.  The number of even integers over the range of integers


3.  The number of integers equally divisible by N over the range of integers.   The user sets the value of N.


4.  The number of perfect squares over the range of integers.  An integer is a perfect square when the fractional part of integer is zero.  Examples are perfect squares are 1, 4, 9, 16, and 25.


5.  The number of integers that begin with digit N over the range of integers.  N is the digit 0-9.   


6.   The number of integers that are triangular numbers over the range of integers.   a triangular number is an integer of the form (n * (n + 1)) / 2.


7.  The number of integers that are relativity prime to N over the range of integers.   An integer is relatively prime to N when the greatest common divisor between N and that integer is 1.   



The program can be used for testing whether density exists with the criteria.  The density, if it exists, is defined as:


limit

n → ∞    (number of integers from 0 to n-1 that fit a criteria) / (n - 1)


For example:  the integer density of odd integers is 1/2, while the integer density of integers divisible by 6 is 1/6.  Beware if the limit tends towards 0 as n gets large, such as the number of perfect squares or triangular numbers.  



HP Prime Program:  INTDENS


Code:


EXPORT INTDENS()

BEGIN

// integer density

// 2023-03-20 EWS


LOCAL A,B,C,H,I,N,lst,E;

I:=0;


// list of choices

lst:={"Odd Integers",

"Even Integers",

"Divisible by N",

"Perfect Squares",

"Begins With Digit N",

"Triangular Numbers",

"Rel. Prime to N"}; 

  

INPUT({A,B,{H,lst}},

"Integer Density",

{"LOW: ","HIGH: ","TYPE: "});  


// odd

IF H==1 THEN

FOR I FROM A TO B DO

C:=when(I MOD 2==1,1,0)+C;

END;

END;


// even

IF H==2 THEN

FOR I FROM A TO B DO

C:=when(I MOD 2==0,1,0)+C;

END;

END;


// divisible by N

IF H==3 THEN

INPUT(N,"Divisible by N","N: ");

FOR I FROM A TO B DO

C:=when(I MOD N==1,1,0)+C;

END;

END;


// perfect squares

IF H==4 THEN

FOR I FROM A TO B DO

C:=when(FP(√I)==0,1,0)+C;

END;

END;


// begins with digit N

IF H==5 THEN

INPUT(N,"Begins with digit N","N: ");

FOR I FROM A TO B DO

E:=ALOG(IP(LOG(I)));

E:=IP(I/E);

C:=when(E==N,1,0)+C;

END;

END;


// triangular numbers

IF H==6 THEN

FOR I FROM A TO B DO

E:=(−1+√(1+8*I))/2;

C:=when(FP(E)==0,1,0)+C;

END;

END;


// relatively prime to N

IF H==7 THEN

INPUT(N,"Relatively Prime to N","N: ");

FOR I FROM A TO B DO

C:=when(gcd(I,N)==1,1,0)+C;

END;

END;

 

// results

N:=B-A+1;

MSGBOX("Count: "+STRING(C)+"\n

Range: "+STRING(N)+"\n

Ratio: "+STRING(C/N)); 

RETURN QPI(C/N);  

   

END;



Examples



For this set of examples:  A = 1 (low), B = 3000 (high)


Ratio of odd integers:  1/2


Ratio of even integers:  1/2


Ratio of integers divisible by 5 (N = 5):  1/5


Ratio of perfect squares:  9/500


Ratio of integers beginning with 2:  1111/3000


Ratio of triangular numbers:  19/750


Ratio of integers relatively prime to 250 (N = 250):  2/5



Source


Diaconis, Persi and Brian Skyrms  Ten Great Ideas About Chance  Princeton University Press:  Princeton, NJ.  2018.  ISBN 978-0-691-19639-8



Note:   On June and July 2023, regular posts will be on Saturdays only.  The Carnival of Math will be on June 3, 2023.  



All original content copyright, © 2011-2023.  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, May 27, 2023

TI-Nspire CX II (CAS): How Many Terms Are Needed to Calculate π?

TI-Nspire CX II (CAS): How Many Terms Are Needed to Calculate π?



Every One Wants a Slice of π


There are many ways of calculating the π, usually apply a formula or a sequence many, many, many times to get as many digits as possible.  The file pitests.tns tests (see below) five algorithms:



Test 1:  Zeta Formula


π^2 / 6 = Σ( 1 / n^2, n=1 to ∞ )


Test 2:  Pi Squared Over Eight Sum


π^2 / 8 = Σ( (2 * n + 1)^(-2), n = 0 to ∞)


Test 3:  Half of Pi Product


π / 2 = Π( (2 * k)^2 / ((2 * k - 1) * (2 * k + 1)), k = 1 to ∞)


Test 4:  Fibonacci Number Sum


π / 2 = Σ( arctan((F_[2*k+1])^(-1)), k = 0 to ∞ )


The angle is radians.  F_[2*k+1] is the [2*k+1]th Fibonacci number.


Test 5:  Limit Sequence


π = lim (n → ∞) [ a^2 / n ]


where 

a0 = 1

a_[n+1] = a_[n] * (1 + (2 * n + 1)^(-1))


The goal is to determine how many terms are needed to obtain a certain amount of digits.  






Certain algorithms take longer than others.     Here are some results:


2 places:  3.14

3 places:  3.141



Test 1:  

2 decimal places:  600 terms

3 decimal places:  1611 terms 


The zeta function converges super slowly for small arguments.


Test 2:

2 decimal places:  199 terms

3 decimal places:  537 terms


Test 3:

2 decimal places:  493 terms

3 decimal places:  1325 terms


Test 4:

2 decimal places:  9 terms

3 decimal places: 10 terms


The Fibonacci method is the fastest and probably is the quickest way to build the expansion of π.


Test 5:

2 decimal places:  94 places

3 decimal places:  1929 places



Download the file pitests.tns here:  https://drive.google.com/file/d/1XqHtPnoKvqfmFLNWHQ-IayFz_lM5zZyT/view?usp=share_link



Source


"List of formulae involving π"  Wikipedia.   Edited on February 11, 2023.   Accessed on March 12, 2023.  https://en.wikipedia.org/wiki/List_of_formulae_involving_%CF%80



Note:   On June and July 2023, regular posts will be on Saturdays only, which will include the next Carnival of Math.


Eddie



All original content copyright, © 2011-2023.  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, May 21, 2023

Python: Square Root Simplification

 Python: Square Root Simplification



Introduction


The script SQFACTOR.py attempts to factor and simplify square root expressions in the form of either:


1.  √n

2.  √m + √n


The script was created using the TI-83 Plus Premium CE Python Edition, which is my first Python script using the French calculator.  




Python script:  sqfactor.py


from math import *

# basic code


def sqfactor(n):

  c=1

  k=2

  while k**2<n:

    while (n/k**2)-int(n/k**2)==0:

      n/=k**2

      c*=k

    k+=1

  return [c,n]


# 2 forms

print("Select: ")

print("1. sqrt(n)")

print("2. sqrt(m)+sqrt(n)")

ch=int(input())


if ch==1:

  n=float(input("n? "))

  l=sqfactor(n)

  print("sqrt("+str(n)+")=")

  print(str(l[0])+"*sqrt("+str(l[1])+")")


if ch==2:

  m=float(input("m? "))

  n=float(input("n? "))

  l0=sqfactor(m)

  l1=sqfactor(n)

  c=l0[0]

  d=l0[1]

  r=l1[0]

  s=l1[1]

  print("sqrt("+str(m)+") + sqrt("+str(n)+")")

  if d==s:

    print(str(c+r)+"*sqrt("+str(d)+")")

  else:

    print(str(c)+"*sqrt("+str(d)+")+")

    print(str(r)+"*sqrt("+str(s)+")")



Examples



Example 1:


√1640

Result:  2 * sqrt(410.0)


Example 2:


√56 + √78

Result:  2 * sqrt(14.0) + 1 * sqrt(78.0)


Example 3:


√75 + √27

Result:  8 * sqrt(3.0)



Eddie 


All original content copyright, © 2011-2023.  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, May 20, 2023

Casio Classpad fx-CP400: Solving a System of Linear Differential Equations Using Laplace Transforms

Casio Classpad fx-CP400: Solving a System of Linear Differential Equations Using Laplace Transforms



Introduction


The following procedure should work with the Casio Classpad family of calculators (300, 330, fx-CP400, fx-CP500). 


An attempt to use the Casio Classpad to solve the system of differential equations:


dxf/dt = A * xf(t) + B * yf(t) + g1(t)

dyf/dt = C * xf(t) + D * yf(t) + g2(t)


Initial conditions:  xf(0) = xf0,   yf(0) = yf0



The independent variable in all the functions is t.  The Casio Classpad's CAS functions laplace and invLaplace are used to accomplish this task.



Syntax


Laplace Transform of f(t):


laplace(f(t), t, s)


Laplace Transform of a Differential Equation:


laplace(diff eq, independent variable, dependent variable, s)


Inverse Laplace Transformation:


invLaplace(ℒ(s), s, t)


t:  parameter of the original function f(t)

s:  parameter of the transformed function ℒ(s)


The definition of a Laplace Transformation:


ℒ(f(t))(s) = ∫( f(t) * e^(-s*t) dt, t = 0 to ∞)


Now, even though we are working a system of differential equations, the laplace and invLapace commands can only work on function at a time.  Any other variable will be treated as a constant, even it was meant to represent another functions.  The substitution steps will account for this.  


The variables used to respect the Classpad's system variables.  


Here are the steps I used to solve:


dxf/dt = A * xf(t) + B * yf(t) + g1(t)

dyf/dt = C * xf(t) + D * yf(t) + g2(t)


Initial conditions:  xf(0) = xf0,   yf(0) = yf0


Spaces are added to readability.  



1.  Store dxf/dt in the variable f1.   Use xf' to represent dxf/dt.  


2.  Store dyf/dt in the variable f2.   Use yf' to represent dyf/dt.


3.  Execute the following and substitutions:


laplace( f1, t, xf, s ) ⇒ g1

g1 | xf(0) = xf0 and  yf / s = Mp ⇒ g1


4.  Execute the following and substitutions:


laplace( f2, t, yf, s ) ⇒ g2

g2 | yf(0) = yf0 and Lp = Mp ⇒ g2

g2 | xf /s = Lp ⇒ g2


Note Lp = ℒ( xf(t) ) and Mp = ℒ( yf(t) )


5.  Now solve the system of transformed equations: 


solve( {g1, g2}, {Lp, Mp} ) ⇒ lists


6.  Take the inverse laplace transforms:


invLaplace( getRight( lists[1], s, t ) ) ⇒ h1

invLaplace( getRight( lists[2], s, t ) ) ⇒ h2


The solutions are:


xf(t) = h1

yf(t) = h2


The getRight command extracts the right side of an equation.



Examples


Example 1:


xf ' = -0.08 * xf + 0.02 * yf + 6

yf ' = 0.08 * xf - 0.08 * yf


Initial conditions:  xf(0) = 0, yf(0) = 150






Example 2:


xf ' = 2 * xf + yf + t^2

yf ' = -2 * xf + 5


Initial conditions:  xf(0) = 2, yf(0) = 5




Casio Classpad Program:  laplaced


Download here:  https://drive.google.com/file/d/1zxTEynCjXmBrPU9pYqmXo3kF_so7fiI-/view?usp=share_link


Code:


' setup

SetRadian


' local variables

Local str1, str2, f1, f2

Local g1, g2, lists, h1, h2

Local Mp, Lp, t, s, xval, yval


' main

ClrText

InputStr str1, "xf'(xf,yf,g1(t))="

InputStr str2, "yf'(xf,yf,g2(t))="

Input xval, "xf(0)? "

Input yval, "yf(0)? "


StrJoin "xf'=", str1, str1

StrJoin "yf'=", str2, str2

strToExp(str1) ⇒ f1

strToExp(str2) ⇒ f2


' transform and solve

laplace(f1, t, xf, s) ⇒ g1

g1 | xf(0) = xval and yf/s = Mp ⇒ g1


laplace(f2, t, yf, s) ⇒ g2

g2 | yf(0) = yval and Lp = Mp ⇒ g2

g2 | xf/s = Lp ⇒ g2


Print "Laplace Transforms:"

PrintNatural g1

Print g1

PrintNatural g2

Print g2


solve({g1, g2},{Lp, Mp})⇒lists

invLaplace(getRight(lists[1]),s,t) ⇒ h1

invLaplace(getRight(lists[2],s,t) ⇒ h2


Print "Solutions: "

Print "xf = "

PrintNatural h1

Print h1

Print "yf = "

PrintNatural h2

Print h2


Note:  PrintNatural displays the expression in textbook form in a popup box, but it does not add anything to the text output terminal.  This is why I included both PrintNatural and Print commands.  



Source


Kreyszig, Erwin.  Advanced Engineering Mathematics  8th Edition  John Wiley & Sons, Inc:  New York, NY.  1999.  ISBN 0-471-15496-2



All original content copyright, © 2011-2023.  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, May 15, 2023

TI-84 Plus CE and TI-83 Premium CE: Vectors Program

TI-84 Plus CE and TI-83 Premium CE:  Vectors Program










The program VECTORS is made for the TI-84 Plus CE and TI-83 Premium CE.  


Introduction


The program VECTORS calculates the following of the three dimensional vectors [A] and [B]:


* Dot product of [A] and [B]

* Euclidean norm of vectors [A] and [B]

* Angle between vectors [A] and [B] in degrees

* Cross product of [A] × [B]

* Tensor product of [A] ⊗ [B]


The program uses the system matrices [A] and [B] and formats them as 3 rows, 1 column matrices.   The program changes the angle mode to Degrees.


After entering each vector, the program gives you an option to normalize the vectors.  Since the cross and tensor products do not follow the commutative property, there is an option to switch the elements of both vectors.  


Depending on the calculator used, results will be shown in either exact format (TI-83 Premium CE) or approximate format (TI-84 CE).  



Calculations Used 


In this section, each of the vectors will be followed by the program code used.  


Let [A] and [B] be the column vectors:

[A] = [[a1][a2][a3]]

[B] = [[b1][b2][b3]]


Dot Product: 

[A] • [B] = a1 * b1 + a2 * b2 + a3 * b3 = [A]ᵀ [B]




Euclidean Norm:

||[A]||₂ = √(a1² + a2² + a3²) = √([A]ᵀ [A])

||[B]||₂ = √(b1² + b2² + b3²) = √([B]ᵀ [B])





Angle Between Two Vectors:

θ = arccos(([A] • [B]) ÷ (||[A]||₂ * ||[B]||₂))




Cross Product:

[A] × [B] = [C] where:

c1 = a2 * b3 – a3 * b2

c2 = -a1 * b3 + a3 * b1

c3 = a1 * b2 – a2 * b1

The result is a 3 x 1 matrix. 




Tensor Product:

[A] ⊗ [B] = [A] [B]ᵀ

The result is a 3 x 3 matrix. 





Download 



You can download the program and the user guide here:

https://drive.google.com/file/d/1R1sHGfr8dKQDkH87QDE0HgMDWxeLNHPN/view?usp=share_link



Eddie 



All original content copyright, © 2011-2023.  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, May 14, 2023

HP Prime: Drawing a Balance Scale and an Updated High Low Game

HP Prime:   Drawing a Balance Scale and an Updated High Low Game



Introduction


The program DSCALE draws a balance scale given two weights:  one placed on the left side (A) and one on the right side.  The length of the bar, which is measured from the center to one of the weights can be set by the user.   Assume that the length is equal on both sides.


The scale in this program is not meant to bend more than 45°.   The program will not draw the scale if the bend is greater than 45°.  


The program is made to simulate balancing the scales.   


Note that the HP Prime PPL  (Prime Programming Language) does not have goto and label commands.  To allow for the user to draw more than one scale, a while loop and a seeding value are used.



HP Prime Program:  dscale


EXPORT dscale()

BEGIN

STARTAPP("Function");

HAngle:=1;  // degrees

W:=4;

K:=1;

INPUT(L,"Balance Scale","L:",

"Length-Center");

 

  

WHILE K==1 DO

INPUT({A,B},"Balance-Scale",

{"<-","->"},{"Left Weight","Right

Weight"});

D:=(B-A)/2;

θ:=ABS(ATAN((B-A)/L));

S:=W*(B-A)/L;

IF θ>45 THEN

MSGBOX("CANNOT DRAW");

CONTINUE;

END;

Function.Xmin:=−W-1;

Function.Xmax:=W+1;

Function.Xtick:=1;

Function.Ymin:=−W-1;

Function.Ymax:=W+1;

Function.Ytick:=1;

RECT(#FFFFFFh);

LINE(0,W,0,−W,#DAA520h);

LINE(−.5,W,.5,W,#FF8000h);

LINE(−1,−W,1,−W,#FF8000h);

LINE(−.5,W,−W,S,#AAAAAAh);

LINE(.5,W,W,−S,#AAAAAAh);

LINE(−W,S,W,−S,0);

WAIT(0);


CHOOSE(K,"Again?","Yes","No"); 

END;

STARTVIEW(−1);

 

END;






The Hi-Low Game Comes to the HP Prime



The program HILODS is the classic high-low guessing game, but instead of text, it draws a balance scale to indicate whether you are higher and lower from the target number.  You work with the left weight (A), with the goal of balancing with the right weight (B).  The right weight is set with a random integer from 10 to 99.  


The game has three difficulty levels:  easy (25 guesses), medium (15 guesses), and hard (10 guesses).






HP Prime Program:  hilods


lose()

BEGIN

STARTVIEW(−1);

MSGBOX("The number is "+STRING(B)+".\n

"+STRING(ABS(A-B))+" away.\n

Better luck next time.");

// backslash n: new line

END;


win() 

BEGIN

STARTVIEW(−1);

MSGBOX("You win! \n

# Guesses: "+STRING(N-C));

END;

 

EXPORT hilods()

BEGIN

// in progress

 

  

STARTAPP("Function");

HAngle:=1;  // degrees

W:=4;

L:=100;

B:=RANDINT(10,99);

Function.Xmin:=−W-1;

Function.Xmax:=W+1;

Function.Xtick:=1;

Function.Ymin:=−W-1;

Function.Ymax:=W+1;

Function.Ytick:=1;

CHOOSE(I,"Different Levels",

"Easy","Medium","Hard");

C:=2.5*I^2-17.5*I+40;

N:=C;

A:=0; // starting seed


WHILE A≠B DO

INPUT(A,

"Guesses left: "+STRING(C),

"Guess? ",

"From 10 to 99");

D:=(B-A)/2;

S:=W*(B-A)/L;

RECT(#FFFFFFh);

LINE(0,W,0,−W,#DAA520h);

LINE(−.5,W,.5,W,#FF8000h);

LINE(−1,−W,1,−W,#FF8000h);

LINE(−.5,W,−W,S,#AAAAAAh);

LINE(.5,W,W,−S,#AAAAAAh);

LINE(−W,S,W,−S,0);

WAIT(0);

C:=C-1;

IF A==B THEN

win();

END;

IF C==0 THEN

lose(); B:=A; // to exit loop

END;

// while end

END;

// main end

END;





This a slightly different approach to the same program than I gave last week.  


Eddie 



All original content copyright, © 2011-2023.  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, May 13, 2023

HP 12C Using TVM variables as Registers

 HP 12C Using TVM variables as Registers



Special Thanks

Regarding the HP 12C Tips talk I gave on HHC 2017, I received this tip from an email from   SergioSamy.   Appreciation and gratitude.  


To watch my HP 12C tip presentation, click here:

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




Why Use TVM Variables?


Normally, we use the variables n, i, PV, PMT, and FV for time value of money, cash flow, and depreciation calculations.  They can be used for variables for non-finance or other business calculations as well.


When we program on the Classic HP 12C, we have 99 steps.  If the program memory is clear, we have 20 registers from R.9  (register dot-nine) to R0 (register zero).   For every eight steps, a memory register is lost.   


At full capacity of the Classic HP 12C, we only have seven registers left (R0 through R6).  


The moment that we use press the [ Σ+ ] button and use statistics, the registers R1 and R6 get occupied, possibly leaving R0 to use for other purposes:


R1 = n

R2 = Σx

R3 = Σx^2

R4 = Σy

R5 = Σy^2

R6 = Σxy


However, the TVM registers: n, i, PV, PMT, and FV, are permanent memory registers for use.   Today's programs will illustrate this use.   


Note:  Pressing the TVM keys once after a number (key word: after) stores the number in a variable.   If you don't key a number first, then the program solves for the a variable.  Let's look at a couple of examples.



Economic Ordering Quantity


Formula:


EOQ = √(2 * CPO * SLS ÷ (CPU * HOLD%))


CPO = fixed order cost

SLS = number of project sales units

CPU = variable cost per unit

HOLD% = projected cost of holding inventory

EOQ = economic ordering quantity, in units


TVM variables used:


[ n ]:  EOQ, computed

[ i ]: HOLD%,  entered

[ PV ]:  CPU, entered

[ PMT ]:  CPO, entered

[ FV ]:  SLS, entered



Program Code:


Line Number:  Key Code;  Key


01:  45, 14;  RCL PMT

02:  45, 15;  RCL FV

03:  20;  ×

04:  2;  2

05:  20;  ×

06:  45, 13;  RCL PV

07:  45, 12;  RCL i

08:  25;  %

09:  34;  x<>y

10:  33;  R↓

11:  10;  ÷

12:  43, 21;  √

13:  44, 11;  STO n

14:  43,33,00;  GTO 00



Example


CPO = 40.95

SLS = 8,000

CPU = 5.50

HOLD% = 10%


10 [ i ]

5.50 [ PV ]

40.95  [ PMT ]

8000 [ FV ]

[ R/S ].  Result:  1091.45


Source


HP-17B, HP-19B, HP-27S  Step-by-Step Solutions For Your HP Calculator.  Marketing and Sales.   Hewlett Packard.  Edition 1.  January 1988



Quadratic Equation


Instructions:


Find the roots of a*x^2 + b*x + c = 0


The program ends with the discriminant stored in R0. 


D = b^2 - 4*a*c


If D<0, the roots are complex in the form of s ± ti:

s:  real part, stored in PMT

t:  imaginary part, stored in FV


If D≥0, the roots are real and:

Root 1 is stored in PMT

Root 2 is stored in FV


Store a in [ n ], b in [ i ], and c [ PV ].  Then run the program. 


Note:  to get the absolute value, square then take the square root of the number.  This is why I have two square root commands in a row: one is to make the absolute value; the second to take the square root of D. 


Program Code:


Line Number:  Key Code;  Key


01:  45,12;  RCL I

02:  2;  2

03:  21;  y^x

04:  45, 13;  RCL PV

05:  45, 11;  RCL n

06:  20;  ×

07:  4;  4

08:  20;  ×

09:  30;  -

10:  44, 0;  STO 0

11:  45, 12;  RCL i

12:  16;  CHS

13:  2;  2

14:  10;  ÷

15:  45, 11;  RCL n

16:  10;  ÷

17:  44, 14;  STO PMT

18:  45, 0;  RCL 0

19:  2;  2

20:  21;  y^x

21:  43, 21;  √

22:  43, 21;  √

23:  2;  2

24:  10;  ÷

25:  45, 11;  RCL n

26:  10;  ÷

27:  44, 15;  STO FV

28:  0;  0

29:  45, 0;  RCL 0

30:  43, 34;  x≤y

31:  43,33,00;  GTO 00

32:  45,14;  RCL PMT

33:  36;  ENTER

34:  36;  ENTER

35:  45, 15;  RCL FV

36:  30;  -

37:  44, 15; RCL FV

38:  33; R↓

39:  43, 36;  LSTx

40:  40;  +

41:  44,14; STO PMT

42:  45, 0;  RCL 0

43:  43,33,00;  GTO 00


Examples


2*x^2 - 3*x + 6 = 0


2 [ n ]

-3 [ i ] 

6 [ PV ]

[ R/S ]


Results:

D = -39.00   (complex roots)

[ RCL ] [ PMT ]:  Real part:  0.75

[ RCL ] [ FV ]:  Imaginary part:  1.56

0.75 ± 1.56i


x^2 + 8*x - 4 = 0


1 [ n ]

8 [ i ] 

-4 [ PV ]

[ R/S ]


Results:

D = 80

[ RCL ] [ PMT ]:  Root 1:  0.47

[ RCL ] [ FV ]:  Root 2:  -8.47

0.47, -8.47



Hope you find this tip helpful,


Eddie 



All original content copyright, © 2011-2023.  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, May 8, 2023

Retro Review: Casio fx-3900Pv

Retro Review:  Casio fx-3900Pv





Quick Facts


Model:  fx-3900Pv

Company:  Casio

Years:  late 1980s - early 1990s

Type:  Finance

Batteries: 1 x CR-2025

Display:  2 lines

Memory Registers:  1 independent with 6 constant registers

Operating System:  Algebraic 



Programming With Editing!


The fx-3900Pv has a programming module similar to the Casio fx-3600P, its many variations and Radio Shack EC-4004.   What separates the fx-3900Pv from the rest is the inclusion of an editing mode.   


The display has two lines.   The top line has all the mode indicators and program steps. The bottom line is the numeric display.  


We are not programming in the blind.  Yay!


Run Mode:   We execute programs in this mode. [ MODE ] [ . ]


Learn (LRN) Mode:  We enter programs from scratch.   [ MODE ] [ EXP ]


Edit Mode:  We edit programs stored in memory.  New entries are automatically inserted.   Program steps can be deleted by the [ SHIFT ] [ ↑ ] (CLR) key sequence.  [ MODE ] [ 0 ]


There are four program slots.  P3 is the shifted program of P1 and P4 the shift of P2.  


The programming commands available on the fx-3900Pv are:


ENT:  prompts the user for a number.  When entering a program, include a valid number after the ENT command.  The number entered after ENT is not counted as a program step.   


HLT:  Halts program execution.  In run mode, continue exection with the [ RUN ] key.


RTN:  Halts the program execution and returns to the first step.  The RTN instruction allows for repeated calculations.


x>0:  If the number in the display at the time is positive, the program returns the first step.   Otherwise, go to the next step.


x≤M:  If the number in the display is less than or greater than the value stored in memory M, go to the first step.  Otherwise, go to the next step.


A sample program:  


f(x) = x^3 - x^2 ÷ 4 + 1


We will use the first program slot.


P1:

SHIFT:  Min    (store in Memory M)

x^y

-

MR   

SHIFT:  x^2

÷

4

+

1

=


f(2.2):  2.2 [ P1 ].   Result:  10.438

f(-1.9):  1. 9 [ +/- ] [ P1 ].  Result:  -6.7615



Integration  ∫dx


In the integration mode ( [ MODE ] [ 1 ]), we can designate one of the four program slots to approximate a definite integral using Simpson's Rule.  Memory M is used for x in f(x).   The program must start with a Min command and end in equals.  


To calculate the integral:


1.  Enter integral mode.

2.  Pick which program has f(x):  P1, P2, P3, or P4.

3.  Optional:  enter n to specify 2^n divisions, then press [ SHIFT ] [ RUN ].

4.  Enter the lower limit, press [ RUN ], enter upper limit, press [ RUN ].



Example:   ∫ x^3 - x^2 ÷ 4 + 1 dx for x = 1 to x = 5.  Use 16 divisions (n = 4)


[ MODE ] 1 [ P1 ]  (see the section above)

4 [ SHIFT ] [ RUN ]  (display: 16)

1 [ RUN ] 5 [ RUN ]


Result:  1.496666667 * 10^2


(2^8: 256 divisions returns 1.496666665 * 10^2 , after short while)


The integration updates the memory registers as such:


K1 = a

K2 = b

K3 = 2^n

K4 = f(a)

K5 = f(b)

K6 = integral



Other Features


The other modes of the fx-3900Pv are:


Mode 2:  LR.  Linear Regression.  Fits data to the line y = A x + B.


A:  slope

B:  intercept

r:  correlation


K1 = Σx^2

K2 = Σx

K3 = n

K4 = Σy^2

K5 = Σy

K6 = Σxy


Mode 4:  Degrees angle mode


Mode 5:  Radians angle mode


Mode 6:  Gradians angle mode


Mode 7:  Fix point display mode.  To round numbers to the fix point internally, execute the RND (round) command.  

 

Mode 8:  Scientific notation display mode


Mode 9:  Norm mode (floating point)



Registers


[ Kin ]:   Stores the number into any register K1 through K6.


[ Kout ]:  Recalls the value of K1 and K6.


The M register:  < Min >, [ M+ ],  < M- > , [ MR ].


Storage arithmetic:  [ Kin ] followed by [ + ], [ - ], [ × ], [ ÷ ]



Final Thoughts


The fx-3900Pv improves on the fx-3600P programming module by adding an editing mode. 


Missing from is the fractions and fraction-decimal conversions.   I would have loved to see other programming commands such as integer part, functional parts, and absolute value.   Other than that, the fx-3900Pv is a big improvement of the fx-3600P.


Casio Ledudu page of fx-3900Pv: 

https://casio.ledudu.com/pockets.asp?lg=eng&type=417



Eddie 


All original content copyright, © 2011-2023.  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. 


  Casio fx-7000G vs Casio fx-CG 50: A Comparison of Generating Statistical Graphs Today’s blog entry is a comparison of how a hist...