Wednesday, November 29, 2017

Casio fx-5800p Special Functions

Casio fx-5800p Special Functions

Programs

An Alternate Way of Extracting the Fraction and Integer Parts of a Number

The fraction part is stored in F, and the integer part is stored in I.  This algorithm can be used when a calculator or programming language does not have a fractional part or integer part function.

This program assumes the program is in Radians mode.

Casio fx-5800P Program FPIP

Rad
0.5    → F
? → X
cos(πX) = 0 Goto 1
Abs(X) → F
tan^-1 (tan (πF)) ÷ π → F
X < 0 -F → F
Lbl 1
F /right-triangle ([Shift] [x^2])
X – F → I

Bernoulli Numbers

The program BERNOULLI approximates the Bernoulli number of nth order.

Casio fx-5800P Program BERNOULLI

? → N
If N = 0
Then
1 → B
Goto 1
IfEnd
If Frac(N ÷ 2) ≠ 0
Then
Int( Abs(N – 2) ÷ (N – 2) – 1) ÷ 4 → B
Goto 1
IfEnd
Σ ( (2*J*π)^(-N), J, 1, 250) * (-1)^(N ÷ 2 + 1) * 2 * N! → B
Lbl 1
B

Euler Numbers

The program EULERNUM calculates the Euler number of order n.

Casio fx-5800P Program EULERNUM

? → N
0 → E
Frac(N ÷ 2) ≠ 0 Goto 1
(2 ÷ π)^(N + 1) * N! ÷ 5 → E
-1 – 10 * Int(E) → E
Frac(N ÷ 4) ≠ 0 Goto 1
4 – E → E
N ≠ 0 Goto 1
1   → E
Lbl 1
E

Custom Formulas

How to create custom formulas:  [MODE], 5.  PROG, 1.  NEW, give the name, 3. Formula

To calculate the custom formula, press [CALC], enter the value for T (ignore X because X is a dummy variable).

Sine Integral:   SI:  ∫( sin(X)/X dX,0,T)

Dawson Integral:  DAWSON:  ∫(e^(T^2-X^2) dX,0,T)

Bessel Function, with order N:  BESSEL:  1/π * ∫(cos(T * sin(X)-N*X) dX,0,T)

Error Function:  ERF:  2/√π * ∫(e^(-X^2) dX,0,T)

Fresnel Sine:  FRESSIN:  ∫( sin(π*X^2/2) dX,0,T)

Fresnel Cosine: FRESCOS: ∫( cos(π*X^2/2) dX,0,T)

Source:

Jerome Spainer and Keith B. Oldham  An Atlas of Functions Hemisphere Publication Corporation: Washington  1987  ISBN 0-89116-5738-8

Eddie

This blog is property of Edward Shore, 2017

Sunday, November 26, 2017

Rounding to the Nearest Reciprocal (HP Prime, TI-84 Plus CE, Casio fx-CG 50)

Rounding to the Nearest Reciprocal   (HP Prime, TI-84 Plus CE, Casio fx-CG 50)

Introduction

The program ROUNDRCP rounds a number to the nearest 1/n. This function can come in handy in several applications, for example, when working with construction or measuring, when have to round results to the nearest eighth (1/8), inch (1/12) or sixteenth (1/16).

Presented here are versions for the HP Prime, TI-84 Plus CE, and Casio fx-CG 50.

HP Prime:  ROUNDRCP

EXPORT ROUNDRCP(a,n)
BEGIN
// Round a to the nearest 1/n
// 2017-11-21 EWS
LOCAL w;
w:=FP(ABS(a))*n;
w:=ROUND(w,0);
RETURN IP(a)+SIGN(a)*(w/n);
END;


The TI-84 Plus CE and Casio fx-CG 50 versions store the answer in X.

TI-84 Plus CE ROUNDRCP

"EWS 2017-11-21"
Input "NUMBER:",A
Input "TO 1/NTH:",N
fPart(abs(A))*N→W
round(W,0)→W
If A<0
Then
iPart(A)-(W/N)→X
Else
iPart(A)+(W/N)→X
End
Disp "X:",X


Casio fx-CG 50 ROUNDRCP

“NUMBER”?→A
“TO 1÷NTH”?→N
Frac ((Abs A))*N→N
RndFix(W,0)→W
If A<0
Then
Int (A)-(W÷N)→X
Else
Int(A)+(W÷N)→X
IfEnd
“X:”
X

Examples

Round π to the nearest 1/4:
ROUNDRCP(π, 4):  3.25 = 13/4

Round e^2 to the nearest 1/100:
ROUNDRCP(e^2, 100): 7.39 = 739/100

Round 1/4 + 2/7 + 3 1/3 to the nearest 1/16:
ROUNDRCP(1/4 + 2/7 + 3 + 1/3, 16):  3.875 = 31/8
(thank you to Joe Horn for pointing out my error, it's correct now.)

Tips 

If you do not have the sign (signum) function, you can compensate by the following code:

If X<0
Then
Return -1  (subtract operation)
Else
Return 1 (addition operation)
End

If your calculator does not have the Round to any number of decimal points function, such as the Casio fx-5800p or fx-3650p, you can manipulate the modes and use the Rnd function and a switch of modes, like this code:

Fix 0
X  (put number to round in display)
Rnd
Float/Norm (1/2)

Eddie


This blog is property of Edward Shore, 2017

Wednesday, November 15, 2017

How to Rotate Graphs

How to Rotate Graphs

Introduction

The key is to use parametric equations in our rotation.  Using the rotation angle θ, the rotation matrix is:

R = [ [ cos θ, -sin θ ] [ sin θ, cos θ ] ]

With the equations x(t), y(t) set as the matrix:

M = [ [ x(t) ] [ y(t) ] ]

The rotated graph is:

[ [ x’(t) ] [ y’(t) ] ] = R * M

Where:

x’(t) = x(t) * cos θ – y(t) * sin θ
y’(t) = x(t) * sin θ + y(t) * cos θ

Rotation the Function y = f(x)

Let x = t and set the parametric functions:

x(t) = t
y(t) = f(t)

Rotating the Polar Equation r = f(t)  (where t = θ)

1.  Solve for t.
2.  Substitute r and t in the following equations:
  x(t) = r * cos t
  y(t) = r * sin t
3.  Simplify as needed.

Some trigonometric properties:
sin^2 ϕ + cos^2 ϕ = 1
sin(2*ϕ) = 2 * cos ϕ * sin ϕ
cos(2*ϕ) = 2 * cos^2 ϕ – 1
sin(acos ϕ) = cos(asin ϕ) = √(1 – ϕ^2)

Please refer to this link for additional details:  http://edspi31415.blogspot.com/2013/01/converting-polar-equations-to.html
   
Rotation Matrices for Certain Angles

Angle 30°, π/6:  R = [ [ √3/2, -1/2 ] [ 1/2, √3/2 ] ]

Angle 45°, π/4:  R = [ [ √2/2, -√2/2 ] [ √2/2, √2/2 ] ]

Angle 60°, π/3:  R = [ [ 1/2, -√3/2 ] [ √3/2, 1/2 ] ]

Angle 90°, π/2:  R = [ [ 0, -1 ] [ 1, 0 ] ]

Angle 120°, 2π/3:  R = [ [ -1/2, -√3/2 ] [ √3/2, -1/2 ] ]

Angle 135°, 3π/4:  R = [ [ -√2/2, -√2/2 ] [ √2/2, -√2/2 ] ]

Angle 150°, 5π/6:  R = [ [ -√3/2, -1/2 ] [ 1/2, -√3/2 ] ]

Angle 180°, π:  R = [ [ -1, 0 ] [ 0, -1 ] ]

Angle 210°, 7π/6:  R = [ [ -√3/2, 1/2 ] [ -1/2, -√3/2 ] ]

Angle 225°, 5π/4:  R = [ [ -√2/2, √2/2 ] [ -√2/2, -√2/2 ] ]

Angle 240°, 4π/3:  R = [ [ -1/2, √3/2 ] [ -√3/2, -1/2 ] ]

Angle 270°, 3π/2:  R = [  [ 0, 1 ] [ -1, 0 ] ]

Angle 300°, 5π/3:  R = [ [ 1/2, √3/2 ] [ -√3/2, 1/2 ] ]

Angle 315°, 7π/4:  R = [ [ √2/2, √2/2 ] [ -√2/2, √2/2  ] ]

Angle 330°, 11π/6:  R = [ [ √3/2, 1/2 ] [ -1/2, √3/2  ] ]

Examples

Each example is followed by a graph of the original equation (blue) and the rotated equations (red).  I used a Casio fx-CG 50 for the screen shots.

Example 1:  y = 3*x^2, rotate 90°

We have a function in the form of y = f(x).  Let’s transfer the function to parametric form, first by assigning x = t and y = 3*t^2.  Angle mode is in radians.

With 90°, the rotation matrix is:  R = [ [ 0, -1 ] [ 1, 0 ] ]

The transformed equations are:

[ [ 0, -1 ] [ 1, 0 ] ] * [ [ t ] [ 3*t^2 ] ] = [ [ -3*t^2 ] [ t ] ]

Rotated Equations:  x’(t) = -3*t^2, y’(t) = t



Example 2:  x = t^3, y = 2*t – 1, rotate 270°

We have the equations in parametric form.  We’ll need the rotation matrix, where:

R = [  [ 0, 1 ] [ -1, 0 ] ]

[  [ 0, 1 ] [ -1, 0 ] ] * [ [ t^3 ] [ 2*t – 1 ] ] = [ [ 2*t – 1 ] [ -t^3 ] ]

Rotated Equations:  x’(t) = 2*t – 1, y’(t) = -t^3



Example 3:  x = sin t, y = e^t, rotate 135°

The rotation matrix is R = [ [ -√2/2, -√2/2 ] [ √2/2, -√2/2 ] ]

Rotated Equations:  x’(t) = -√2/2 * (sin t + e^t), y’(t) = √2/2 * (sin t – e^t)



Example 4:  r = 2 θ, rotate 60°

The parametric form is x(t) = 2 * t * cos t, y(t) = 2 * t * sin t

The rotation matrix is R = [ [ 1/2, -√3/2 ] [ √3/2, 1/2 ] ]

Rotated Equations: x’(t) = t * cos t - √3 * t * sin t, y’(t) = t * sin t + √3 * t * cos t



Eddie


This blog is property of Edward Shore, 2017

Saturday, November 11, 2017

Casio fx-CG 10, fx-CG 20, fx-CG 50 Update to Software Version 3.1

Casio fx-CG 10, fx-CG 20, fx-CG 50 Update to Software Version 3.1

If you want to see my original review of the fx-CG 50, please click here: 

What’s New with Software Version 3.1
  
Major Graph3D App Update!

Wow!  Casio hit it out of park with their updated 3D Graph mode.

When I first reviewed the Casio fx-CG 50 last June, one of the new features highlighted was the 3D Graph mode.  At the time, the mode was limited to lines, planes, spheres, and cylinders.  A good start, but limited mode. 

Not anymore.  First, the update added cones to the template.


The 3D Graph mode has become an official graphing mode because the mode now has functional graphing in the form of Z(X,Y).


It doesn’t stop there.  The mode also offers parametric graphing in the form of (X(S,T), Y(S,T), Z(S,T)).  This might be my favorite part of the Graph 3D app.


Finally, you can rotate Y(X) functions either by X or Y axis, to give a really neat visualization of functions.


The update adds analysis for planes and lines.  Analysis includes intersection points and relational type analysis (intersection vs. orthogonal vs. rotational vs. parallel, etc.)


QR Codes Added to the Catalog

QR (Quick Response) codes, those small square bar codes that people scan with their smartphones to connect to certain webpages, have been added to most of the commands in the Catalog.  Any QR reader should do.  A successful reading of the bar code leads to Casio’s online manual. 





Count on Casio continuing the use of QR codes, in both graphing and non-graphing models.  Recall that the fx-991 EX Classwiz has QR codes to display stat plots and screen shots through Casio’s Casio EDU+ software and app. 

Yes, QR codes generated by the catalog can be read by the Casio EDU+ app. 

For more details, click here:

Wish List

I wish in the next update, Casio increases the number of colors to display text and graphs, currently there are still seven (black, blue, red, magenta, green, cyan, and yellow).  At least put an RGB function. 

I think a differential equation graph mode or type would fit well with this series, even if it is just in the form of y’ = f(x,y,constants) and the Runge Kutta 4th order method is used. 

I suspect the next hardware of this series will have memory increased to at least 256MB or more.   This series of calculators deserves to have such increase because of all the great things this series offers!

Download Links


Please keep in mind you will need to install the Graph3D for the fx-CG 10 and fx-CG 20 Add-In separately.  The Graph3D already comes with the fx-CG 50.


The era of third-dimensional graphing is here to stay!

Eddie

This blog is property of Edward Shore, 2017.

Wednesday, November 8, 2017

HP Prime Public Beta Firmware Available (Nov. 2017)

 HP Prime Public Beta Firmware Available

There is new HP Prime software for Mac and Windows, along with firmware for the calculator (Rev. 12951, 11/6/2017; 12969, 11/8/2017; 13012, 11/11/2017).  The firmware is public beta, which means the firmware is still under testing, stomping any last few bugs the firmware may have. 

Should you download this firmware and find issues, HP asks you to contact calcbeta@hp.com.  Special thanks to Tim Wessman and the HP Calculator team. 


(By the way, please consider joining HP Museum of Calculators forum, it is awesome community of calculator and mathematics enthusiasts. Link:  http://www.hpmuseum.org/forum/  ) 

You can download the beta software here:  http://www.hpcalc.org/prime/beta/ 

(Shout out to hpcalc.org)

Here is just a preview of what’s new for the HP Prime, this is a major update so what you see here is a fraction of what’s being added.  For a complete list, please see the museum thread (#9450) posted above or the release info text file.





Eddie


This blog is property of Edward Shore, 2017.

Sunday, November 5, 2017

Animation: TI-84 Plus CE





Program listing:



Master program ANIMSTR:

prgmANI002
prgmANI003
prgmANI004
prgmANI005
prgmANI006

"EWS 2017-10-28"
FnOff :BackgroundOff
PlotsOff :AxesOn
seq(X,X,­5,5,0.5)→L1
e^(­L1²/2)→L2

dim(L1)→D
{RED,GREEN,BLUE,RED,GREEN,BLUE}→L3

"STAT PLOT"
PlotsOn 1
Plot1(xyLine,L1,L2,⁺,LTGRAY)
ZoomStat
"ANIMATION"

For(J,1,6)
For(K,1,D)
Pt-On(L1(K),L2(K),3,L3(J))
Wait 0.15
End
End

Subroutine ANI002:

"2017-11-05 EWS"
Func:ZStandard:FnOff
ClrDraw:PlotsOff

For(K,1,10)
Line(­8,8,8,8,1,GREEN)
Line(­4,4,4,4,1,ORANGE)
Pt-On(­2,2,3,ORANGE)
Pt-On(2,2,3,GREEN)
Wait 0.2

Line(­8,8,8,8,1,ORANGE)
Line(­4,4,4,4,1,GREEN)
Pt-On(­2,2,3,GREEN)
Pt-On(2,2,3,ORANGE)

Wait 0.2
End

Subroutine ANI003:

"2017-11-05 EWS"
Func:ZStandard:FnOff
ClrDraw:PlotsOff
Radian

Pt-On(­10,sin(­10),3,RED)
For(X,­9.9,10,.1)
Pt-On(X-.1,sin(X-.1),3,LTBLUE)
Pt-On(X,sin(X),3,RED)
Wait 0.1
End

Subroutine ANI004:

"2017-11-05 EWS"
Func:ZStandard:FnOff
ClrDraw:PlotsOff
Radian

"PRE-ANI"
Line(­4,4,­4,­4,BLUE)
Line(­1,4,­1,­4,BLUE)
Line(3,4,3,­4,BLUE)

"CHASING LINES"
For(K,1,10)
Line(­4,4,­4,­4,BLUE)
Line(­1,4,­1,­4,RED)
Wait .2

Line(­1,4,­1,­4,BLUE)
Line(3,4,3,­4,RED)
Wait .2

Line(3,4,3,­4,BLUE)
Line(­4,4,­4,­4,RED)
Wait .2

End

Subroutine ANI005:

"2017-11-05 EWS"
Func:ZSquare:FnOff
ClrDraw:PlotsOff
Radian
AxesOff

"CORE"
For(K,0.1,1,.1)
Circle(0,0,K,BLACK)
End

"BREATHING"
For(K,1,3)

For(J,1,5,.25)
Circle(0,0,J,RED)
End

For(J,5,1,­.25)
Circle(0,0,J,WHITE)
End

End
AxesOn

Subroutine ANI006:

"2017-11-05 EWS"
Radian:Func:PlotsOff
FnOff :AxesOff:ZSquare
ClrDraw

"SETUP"
BackgroundOn BLACK
Pt-On(0,0,3,YELLOW)

"ORBITS"
π/24→T
For(K,0,8π,T)

6.8cos(K)→A
7.2sin(K)→B
6.8cos(K-T)→C
7.2sin(K-T)→D
Pt-On(A,B,3,ORANGE)
Pt-On(C,D,3,BLACK)

5cos(1.05K)→A
5sin(1.05K)→B
5cos(1.05(K-T))→C
5sin(1.05(K-T))→D
Pt-On(A,B,3,LTBLUE)
Pt-On(C,D,3,BLACK)

3.1cos(1.1K)→A
2.9sin(1.1K)→B
3.1cos(1.1(K-T))→C
2.9sin(1.1(K-T))→D
Pt-On(A,B,3,RED)
Pt-On(C,D,3,BLACK)

Wait .15
End


BackgroundOff




Eddie



This blog is property of Edward Shore, 2017

Saturday, November 4, 2017

HP Prime: Best Regression Fit

HP Prime:  Best Regression Fit

The program BESTFIT compares a set of regressions to determine a best fit.  This simulates a feature presented on the Hewlett Packard HP 48S, HP 48G, HP 49G, and HP 50g.  BESTFIT compares the correlations of the following four regression models:

1.  Linear:  y = a * x + b
2.  Logarithmic:  y = a * ln x + b
3.  Exponential:  y = b * a^x   (y = b * e^(ln a * x))
4.  Power: y = b * x^a

The output is a two element list:  a string of the best fit equation and its corresponding correlation.

HP Prime Program:  BESTFIT

EXPORT BESTFIT(L1,L2)
BEGIN
// 2017-11-02 EWS
// Simulate Best Fit
// HP 48GX,49G,50g

// initialize
LOCAL clist,m,c,v,s,n;
clist:={0,0,0,0};

// test
// correlation is linear only
// requires approx()
// linear y=a*x+b
clist[1]:=approx(correlation(L1,L2));
// log y=a*LN(x)+b
c:=approx(correlation(LN(L1),L2));
IF IM(c)==0 THEN
clist[2]:=c;
END;
// exponential y=b*e^(a*x)
c:=approx(correlation(L1,LN(L2)));
IF IM(c)==0 THEN
clist[3]:=c;
END;

// power y=b*a^x
c:=approx(correlation(LN(L1),LN(L2)));
IF IM(c)==0 THEN
clist[4]:=c;
END;

// test
// POS(L0^2,MAX(L0^2))
m:=POS(clist^2,MAX(clist^2));
c:=clist[m];

IF m==1 THEN
v:=linear_regression(L1,L2);
s:=STRING(v[2])+"+"+STRING(v[1])+
"*X";
RETURN {s,c};
END;

IF m==2 THEN
v:=logarithmic_regression(L1,L2);
s:=STRING(v[2])+"+"+STRING(v[1])+
"*LN(X)";
RETURN {s,c};
END;

IF m==3 THEN
v:=exponential_regression(L1,L2);
s:=STRING(v[2])+"*"+STRING(v[1])+
"^X";
RETURN {s,c};
END;

IF m==4 THEN
v:=power_regression(L1,L2);
s:=STRING(v[2])+"*X^"+
STRING(v[1]);
RETURN {v,s};
END;

END;

Examples – BESTFIT:

Example 1:

X
y
1.05
10.45
2.28
11.33
4.20
16.38
6.34
28.87

Result: {“7.78250037344*1.21713132288^X”, 0.981261724397}
Example 2:

X
Y
-10
82
-5
41
5
-42
10
-79

Result:  {“0.5+ -8.1*X”, -0.999801918343}


Example 3:

X
Y
10
2.278
11
2.666
12
2.931
13
3.212

Result:  {“-5.79464870365+3.51429873838*LN(X)”, 0.998295735284}

BESTFIT2:  An Extended Version

Version 2 adds the following regressions: 

5.  Inverse:  y = b + a/x
6.  Simple Logistic:  y = 1/(b + a*e^(-x))
7.  Simple Quadratic:  y = b + a*x^2
8.  Square Root:  y = √(a*x + b)

HP Prime Program:  BESTFIT2

EXPORT BESTFIT2(L1,L2)
BEGIN
// 2017-11-02 EWS
// Simulate Best Fit
// HP 48GX,49G,50g
// additional models

// initialize
LOCAL clist,m,c,v,s;
clist:={0,0,0,0,0,0,0,0};

// test
// correlation is linear only
// requires approx()

// linear y=a*x+b
clist[1]:=approx(correlation(L1,L2));

// log y=a*LN(x)+b
c:=approx(correlation(LN(L1),L2));
IF IM(c)==0 THEN
clist[2]:=c;
END;

// exponential y=b*e^(a*x)
c:=approx(correlation(L1,LN(L2)));
IF IM(c)==0 THEN
clist[3]:=c;
END;

// power y=b*a^x
c:=approx(correlation(LN(L1),LN(L2)));
IF IM(c)==0 THEN
clist[4]:=c;
END;

// inverse y=b+a/x
IF POS(L1,0)==0 THEN
clist[5]:=approx(correlation(1/L1,
L2));
END;

// simple logistic
IF POS(L2,0)==0 THEN
clist[6]:=approx(correlation(e^(−L1),
1/L2));
END;

// simple quadratic
clist[7]:=approx(correlation(L1^2,
L2));

// square root
IF ΣLIST(L2≥0)==SIZE(L2) THEN
clist[8]:=approx(correlation(L1,
L2^2));
END;



// test
// POS(L0^2,MAX(L0^2))
m:=POS(clist^2,MAX(clist^2));
c:=clist[m];

IF m==1 THEN
v:=linear_regression(L1,L2);
s:=STRING(v[2])+"+"+STRING(v[1])+
"*X";
END;

IF m==2 THEN
v:=logarithmic_regression(L1,L2);
s:=STRING(v[2])+"+"+STRING(v[1])+
"*LN(X)";
END;

IF m==3 THEN
v:=exponential_regression(L1,L2);
s:=STRING(v[2])+"*"+STRING(v[1])+
"^X";
END;

IF m==4 THEN
v:=power_regression(L1,L2);
s:=STRING(v[2])+"*X^"+
STRING(v[1]);
END;

// inverse
IF m==5 THEN
v:=linear_regression(1/L1,L2);
s:=STRING(v[2])+"+"+STRING(v[1])+
"/X";
END;

// simple logistic
IF m==6 THEN
v:=linear_regression(e^(−L1),
1/L2);
s:="1/("+STRING(v[2])+"+"+
STRING(v[1])+"*e^(−X))";
END;

// simple quadratic
IF m==7 THEN
v:=linear_regression(L1^2,L2);
s:=STRING(v[2])+"+"+STRING(v[1])+
"*X^2";
END;

// square root
IF m==8 THEN
v:=linear_regression(L1,L2^2);
s:="√("+STRING(v[2])+"+"+
STRING(v[1])+"*X)";
END;

RETURN {s,c};
END;

Examples – BESTFIT2:

Example 4:

X
y
1.05
10.45
2.28
11.33
4.20
16.38
6.34
28.87

Result:  {“9.0573970192+0.48023219108*X^2”, 0.994491728382}

Example 5:

X
y
1
8.4853
2
8.9443
4
9.7980
7
10.9546

Result: {“√(63.9995089183+8.00048914762*X”, 0.999999999759}

Example 6:

X
y
1
1
2
-0.5
3
-1
4
-1.25

Result:  {“-2+3/X”, 1}

Eddie

This blog is property of Edward Shore, 2017

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...