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

Friday, November 3, 2017

HP Prime: User Key: Building a list of Templates

HP Prime:  User Key:  Building a list of Templates

Introduction

You can assign a custom menu to a user key.  The program TEMPLATES assigns a list of functions to the templates key (the key to the right of the Toolbox key, key 18 I believe). 

When this program is completed, you call the custom menu by pressing [Shift], [Help] (User), [template key]. 

Choose a function or command.  Whatever you choose will be inserted into the entry line.  This user key works in program editing as well.



HP Prime Program:  TEMPLATES

Note:  I do not have a main “TEMPLATES” program block.  In terms of making a custom menu like this, it is not necessary.


// a custom menu
// 2017 EWS

KEY K_Templ()
BEGIN
LOCAL str,lst,cst,ch;
// templates
lst:={"Function.ROOT()",
"Function.AREA()",
"Function.SLOPE()",
"Finance.TvmNbPmt()",
"Finance.TvmIPYR()",
"Finance.TvmPV()",
"Finance.TvmPMT()",
"Finance.TvmFV()"};


// choose list
cst:={"ROOT",
"AREA",
"SLOPE",
"N",
"I%YR",
"PV",
"PMT",
"FV"};

CHOOSE(ch,"Template",cst);

RETURN lst(ch);

END;

This is one of my favorite programs because now I will be able to quickly access functions that would take additional keystrokes and with the App specific functions, dealing with dynamic menus.  I encourage this type of custom menu for other functions and commands you frequently use from the catalog.  Try it.  Please let me know how it goes.

Eddie


This blog is property of Edward Shore, 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 rotatio...