Showing posts with label Casio fx-CG50. Show all posts
Showing posts with label Casio fx-CG50. Show all posts

Saturday, December 20, 2025

Basic vs. Python: Helix Curve (with Casio fx-CG 50)

Basic vs. Python: Helix Curve (with Casio fx-CG 50)



Calculators Used: Casio fx-CG100, Casio fx-CG50



The Helix Curve



The helix space curve can be defined with the following set of parametric equations:



x(t) = r × cos(t)

y(t) = r × sin(t)

z(t) = c × t

where r = radius, c = spacing between the coils of the helix



We can use any measurement of length we want, such as meters, feet, or inches, as long as our measurements are consistent.



Graphing the Helix Equation



Regarding calculators, 3D parametric equations can be graphed with the Casio fx-CG 50, fx-CG 100 (independent variables s and t), and the TI-Nspire (independent variables t and u). The screenshots below is a graph of a helix with the use of the fx-CG 100 emulator (classpad.workspace.com):






Curvature, Torsion, and Arc Length of a Helix



For the formulas, let

x = r × cos(t), x’ = -r × sin(t), x’’ = -r × cos(t), x’’’ = r × sin(t)

y = r × sin(t), y’ = r × cos(t), y’’ = -r × sin(t), y’’’ = -r × cos(t)

z = c × t, z’ = c, z’’ = 0, z’’’ = 0



The variable t is the independent variable of x(t), y(t), and z(t).



Curvature



The general formula for curvature:

k² = ((x’² + y’² + z’²) × (x’’² + y’’² + z’’²) – (x’ × x’’ + y’ × y’’ + z’ × z’’)) ÷ (x’² + y’² + z’²)³



Applying to the helix:

k² = ((r² sin² t + r² cos² t + c²) × (r² cos² t + r² sin² t + 0) – (r² sin t cos t – r² sin t cos t + 0)) ÷ (r² sin² t + r² cos² t + c²)³

Note: r² sin² t + r² cos² t = r² × (sin² t + cos² t) = r²

k² = ((r² + c²) × r²) ÷ (r² + c²)³

k² = r² ÷ (r² + c²)²

k = r ÷ (r² + c²)

Note: curvature is assumed to be a positive value





Torsion



The general formula for torsion:

τ =

(x’’’ × (y’ × z’’ – y’’ × z’) + y’’’ × (x’’’ × z’ – x’ × z’’’) + z’’’ × (x’ × y’’ – x’’ × y’))

÷ ((y’ × z’’ – y’’ × z’)² + (x’’ × z’ – x’ × z’’)² + (x’ × y’’ – x’’ × y’)²)



Breaking it down into parts:



x’’’ × (y’ × z’’ – y’’ × z’) = r × sin t × (0 - -r × sin t × c) = r² × c × sin² t

y’’’ × (x’’’ × z’ – x’ × z’’’) = -r × cos t × (-r × cos t × c – 0) = r² × c × cos² t

z’’’ × (x’ × y’’ – x’’ × y’) = 0

x’’’ × (y’ × z’’ – y’’ × z’) + y’’’ × (x’’’ × z’ – x’ × z’’’) + z’’’ × (x’ × y’’ – x’’ × y’)

= r² × c × sin² t + r² × c × cos² t + 0 = r² × c



(y’ × z’’ – y’’ × z’)² = (0 - -r × sin t × c)² = r² × c² × sin² t

(x’’ × z’ – x’ × z’’)² = (-r × cos t × c – 0)² = r² × c² × cos² t

(x’ × y’’ – x’’ × y’)² = (r² sin² t + r² cos² t)² = r^4

(y’ × z’’ – y’’ × z’)² + (x’’ × z’ – x’ × z’’)² + (x’ × y’’ – x’’ × y’)²

= r² × c² × sin² t + r² × c² × cos² t + r^4 = r² × c² + r^4 = r² × (c² + r²)



Then:

τ = (r² × c) ÷ (r² × (c² + r²)) = c ÷ (r² + c²)





Arc Tangent from t = 0 to t = x



s = ∫ √(x’² + y’² + z’²) dt from t = 0 to t = x



Since:

x’² + y’² + z’² = r² sin² t + r² cos² t + c² = r² + c²



Then:

s = ∫ √(x’² + y’² + z’²) dt from t = 0 to t = x

= ∫ √(r² + c²) dt from t = 0 to t = x

= x × √(r² + c²)



To summarize, for the helix curve:

Curvature: k = r ÷ (r² + c²)

Torsion: τ = c ÷ (r² + c²)

Arc Length to x: s = x × √(r² + c²)



The code below calculates the following:

* curvature

* torsion

* arc length to 2π



Casio fx-CG50 Program HELIXFX



"HELIX: CASIO BASIC"

"RADIUS"?→R

"SPACING"?→c

"CURVATURE="

R÷(R²+C²)→K ◢

"TORISON="

C÷(R²+C²)→T ◢

"ARC LENGTH TO 2π="

2×π×√(R²+C²)→S



Python Script: helixp.py



from math import *

print("Helix: Parameters")

print("math module imported\n")

r=eval(input("radius? "))

c=eval(input("spacing? "))

k=r/(r**2+c**2)

t=c/(r**2+c**2)

print("curvature=\n",str(k))

print("torsion=\n",str(t))

print("arc length to 2pi=\n",str(s))



Example



Radius: r = 2.75

Spacing: c = 0.89



Outputs:

Curvature: 0.3291599837

Torsion: 0.1065281402

Arc length to 2π: 18.16112298



Sources



Harris, John W. and Horst Stocker. Handbook of Mathematics and Computational Science Springer: New York, NY. 2006. ISBN 978-0-387-94746-4

Lee, Sarah. “Curvature and Torsion of 3D Parametric Curves.” Number Analytics // Super Easy Data Analysis Tool for Research, May 17, 2015, www.numberanalytics.com/blog/curvature-torsion-3d-parametric-curves . Accessed 02 July 2025.

Weisstein, Eric W. "Helix." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/Helix.html Accessed July 2, 2025.

Wikimedia Foundation. “Torsion of a curve.” Wikipedia. Lasted Edited January 2, 2023, https://en.wikipedia.org/wiki/Torsion_of_a_curve Accessed July 2, 2025.


Eddie

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

The author does not use AI engines and never will.


Saturday, December 7, 2024

Casio fx-CG50 and TI-84 Plus CE: Multiple Linear Regression

Casio fx-CG50 and TI-84 Plus CE: Multiple Linear Regression


We have arrived at the last month of 2024. What a crazy year. I hope for smoother and peaceful times ahead.



Introduction


The program MLREG fits bi-variate data to the linear regression equation:


y = b0 + b1 * t + b2 * x


where t and x are the independent variables, and y is the dependent variable. The program uses a numerical method known as normal equations, to solve the system:


n * b0 + Σ(t) * b1 + Σ(x) * b2 = Σ(y)

Σ(t) * b0 + Σ(t^2) * b1 + Σ(t*x) * b2 = Σ(t*y)

Σ(x) * b0 + Σ(t*x) * b1 + Σ(x^2) * b2 = Σ(x*y)


or in matrix form:


[ [ n ,Σ(t), Σ(x) ] [ Σ(t), Σ(t^2), Σ(t*x) ] [ Σ(x), Σ(t*x), Σ(x^2) ] ] * [ [ b0 ] [ b1 ] [ b2 ] ]

= [ [ Σ(y) ] [ Σ(t*y) ] [ Σ(x*y) ] ]


where:

n is the number of data points,

Σ(t) is the sum of all t data,

Σ(x) is the sum of all x data,

Σ(y) is the sum of all y data,

x * t, t * y, x * y, t^2, x^2 are all represent of the variable element-by-element multiplication of each set


The calculator programs assign the following variables:

n * b0 + Σ(t) * b1 + Σ(x) * b2 = Σ(y)

Σ(t) * b0 + Σ(t^2) * b1 + Σ(t*x) * b2 = Σ(t*y)

Σ(x) * b0 + Σ(t*x) * b1 + Σ(x^2) * b2 = Σ(x*y)


A = n

B = Σ(t)

C = Σ(x)

D = Σ(t^2)

E = Σ(t*x)

F = Σ(x^2)

X = Σ(y)

Y = Σ(t*y)

Z = Σ(x*y)




Casio fx-CG 50 Program: MLREG


This is programmed in Casio Basic.


“Y=B0+B1×T+B2×X”

“T LIST”? → List 4

“X LIST”? → List 5

“Z LIST”? → List 6

If Dim List 4 ≠ Dim List 5 Or Dim List 5 ≠ Dim List 6 Or Dim List 4 ≠ Dim List 6

Then

“LISTS NOT SAME LENGTH” ◢

Stop

IfEnd

Dim List 4 → A

Sum List 4 → B

Sum List 5 → C

Sum (List 4²) → D

Sum (List 4 × List 5) → E

Sum (List 5²) → F

Sum List 6 → X

Sum (List 6 × List 4) → Y

Sum (List 6 × List 5) → Z

“B0,B1,B2=” ◢

[ [A, B, C ][B, D, E][C, E, F] ] ⁻¹ × [ [ X ][ Y ][ Z ] ] → Mat Z



TI-84 Plus CE Program: MLREG


ClrHome

Disp “Y=B0+B1*T+B2*X”

Input “T LIST: “, L₄

Input “X LIST: “, L₅

Input “Y LIST: “, L₆

If dim(L₄) ≠ dim(L₅) or dim(L₅) ≠ dim(L₆) or dim(L₄) ≠ dim(L₆)

Then

Disp “LISTS NOT EQUAL SIZE”

Stop

End

dim(L₄) → A

sum(L₄) → B

sum(L₅) → C

sum(L₄ ²) → D

sum(L₄ * L₅) → E

sum(L₅ ²) → F

sum(L₆) → X

sum(L₆ * L₄) → Y

sum(L₆ * L₅) → Z

[ [ A, B, C ] [ B, D, E ] [ C, E, F ] ] ⁻¹ * [ [ X ] [ Y ] [ Z ] ] → [ J ]

Disp “B0,B1,B2= “, [ J ]


Note: [ J ] is matrix J is called form the Matrix menu.



An Online Multiple Linear Regression Calculator


A multiple linear regression calculator which determine coefficients, quadrants, and other statistics can be found on the stats.blue web page: https://stats.blue/Stats_Suite/multiple_linear_regression_calculator.html


Examples


Example 1


t

x

y

1.12

22.3

100

1.16

22.1

104

1.19

21.8

107

1.23

21.4

110

1.28

21.1

114


Result:

B0 = -48.8333333

B1 = 99.99999999 (TI-84 Plus CE rounds this to 100)

B2 = 1.666666666


Equation:

y = -48.8333333 + 99.99999999 * t + 1.666666666 * x



Example 2


t

x

y

10.2

1.95

1000

10.5

3.00

1002

10.8

4.00

1005

11.1

4.95

1007

11.6

5.80

1009

11.8

6.75

1012

12.1

7.80

1015


Result:

B0 = 1008.157502

B1 = -1.429759754

B2 = 3.052897088


y = 1008.157502 – 1.429759754 * t + 3.052897088 * x


Until next time, when a new series will be introduced. Stay tuned,



Eddie


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

Casio fx-CG50: Logistic Equation - Solving For Parameters From Two Data Points

Casio fx-CG50:  Logistic Equation - Solving For Parameters From Two Data Points



The Challenge



It can be a challenge, especially without a statistics software package or method like the maximum likelihood estimate, to fit data (x, p), to the curve:


p(x) = 1 / ( 1 + α * x^β ) = ( 1 + α * x^β )^-1



What happens if we just have two data points (x1, p1) and (x2, p2).  Then finding α and β turns into simpler task.   Either we find a quick estimate to extend to other data points or if we just have two data points, exact solutions.




Finding α and β



With the points (x1, p1) and (x2, p2), the system to solve is:


1 / ( 1 + α * x1^β ) = p1

1 / ( 1 + α * x2^β ) = p2


1 + α * x1^β = 1/p1

1 + α * x2^β = 1/p2


α * x1^β = 1/p1 - 1

α * x2^β = 1/p2 - 1 


Assuming that α ≠ 0, divide both equations to get:


x1^β / x2^β = (1/p1 - 1) / (1/p2 - 1)


Solve for β:


(x1/x2)^β = (1/p1 - 1) / (1/p2 - 1)


ln [ (x1/x2)^β  ] = ln [ (1/p1 - 1) / (1/p2 - 1) ]


β * ln [ (x1/x2) ] = ln [ (1/p1 - 1) / (1/p2 - 1) ]


β = ln [ (1/p1 - 1) / (1/p2 - 1) ] / ln [ (x1/x2) ] 


Then we can get α:  


α = (1/p1 - 1) / (x1^β) = (1/p2 - 1) / (x2^β) 




Casio fx-CG50 Program:  BETPARAM

(276 bytes)


The characters α and β are found in the CHAR sub menu (outside of the PRGM menu).  If you have a monochrome calculator or just don't want color, ignore the color commands.


The program then graphs the resulting equation.   The variables Y1 and Y2 (with the bold Y) represent functions of X.  

 


Red "P(X)=1÷(1+αX^β)"

"SOLVE FOR α, β"◢

Rad

"POINT 1"

"X1"?→Y

"P1"?→Q

"POINT 2"

"X2"?→Z

"Y2"?→R

ln ((Q^-1 -1)÷(R^1 - 1))

Ans÷ln (Y÷Z)→B

(Q^-1 - 1)÷(Y^B)→A

ClrText

Blue Locate 1,3,"EST. PARAMETERS"

Locate 1,4,"α="

Locate 5,4,A

Locate 1,5,"β="

Locate 5,5,B

"1÷(1+A×X^B)"→Y1

""→Y2

SetG-Color Green,1

DrawGraph

ZoomAuto



Examples


Example 1:

(x1, p1) = (0.5, 0.76)

(x2, p2) = (1.5, 0.70)





Example 2:

(x1, p1) = (3/2, 5/8)

(x2, p2) = (2/3, 3/8)






Source:


Sumpter, David.  The Ten Equations That Rule the World: And How You Can use Them Too.  Flatiron Books: New York.  2021.  ISBN 978-1-250-24696-7



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, March 11, 2023

Casio fx-CG50: Plotting the Betting Equation

Casio fx-CG50:  Plotting the Betting Equation



Introduction


The program BETPLOT plots two equations:


The betting equation, based on logistic equation:


y1(x) = p(x) = 1 / (1 + α*x^β)


α, β:  parameters

x:  data point, odds given by the booker

p(x):  probability, probability that a favorite event happens/wins



The expected profit equation:


y2(x) = p(x) * x - (1 - p(x))



Casio fx-CG 50 Program:  BETPLOT


The characters α, β, and # are found in the CHAR sub menu (outside of the PRGM menu).  If you have a monochrome calculator or just don't want color, ignore the color commands.


The program then graphs the resulting equation.   The variables Y1 and Y2 (with the bold Y) represent functions of X.  

 

"BETTING EQN."

"DAVID SUMPTER"

Red "1÷(1+αX^β)"◢

"INCREMENT"?→1

"# STEPS"?→S

"α"?→A

"β"?→B

"(1+A×X^B)^-1"→Y1

"X×Y1-(1-Y1)"→Y2

Y=type

SetG-Color Black, 1

SetG-Color Green, 2

Seq(K,K,0,S×I+I,I)→List 1

(1+A×List 1^B)^-1→List 2

List 2×List1-(1-List 2)→List 3

ClrText

"COL. 1: X"

"COL. 2: P(X)"

"COL. 3: EXP. WIN"◢

List→Mat(List 1,List 2,List 3)◢ 

ViewWindow 0,S×I,I,Min(List 2)-1,Max(List 2),0.25

AxesOn

GridOn

DrawGraph



Examples


Example 1:

α = 1.3, β = 1.01





Example 2:

α = 1.16, β = 1.25






Source:


Sumpter, David.  The Ten Equations That Rule the World: And How You Can use Them Too.  Flatiron Books: New York.  2021.  ISBN 978-1-250-24696-7



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, October 1, 2022

Casio fx-CG 50: Random Walk Histogram

Casio fx-CG 50:  Random Walk Histogram


Mosquitos an Inspiration, What? 


Inspiration:  

Ellenberg, Jordan.   Shape:  The Hidden Geometry of Information, Biology, Strategy, Democracy, and Everything Else  Penguin Books:  New York, NY. 2021


The beginning of Chapter 4, Sir Ronald Ross proposes the problem:  In a simple case, a mosquito can only travel in one of two directions, which is northeast or southwest.   The goal was to find the average distance a mosquito is from its home after a given life span.


The program TWALK would address a similar problem.  


N = number of trials


S = number of steps the mosquito (or whatever you want to imagine) walks in a single direction


Each trial calculates the final position.  The program draws a histogram of all the trails.   


TWALK gives two choices:


(-1, 1):  Each turn, the mosquito must move forward 1 step or backward 1 step


(-1, 0, 1):  Each turn, the mosquito must either move forward 1 step, move backward 1 step, or stay still for one turn. 



Drawing an Histogram Program in Casio Programming


Syntax:


S-Grph#  DrawOn, Hist, List x, 1, [ColorLinkOff], [Color] ColorLighter


# = Graph 1, 2, 3

List x = List 1 to List 26

Color Commands:  ColorLinkOff, 

Colors: One of 8 eight colors

ColorLighter: the fill of the color is lighter than the bar


The color commands are optional.  If you are using a Casio fx-9750GIII, leave of the color commands.



Casio fx-CG50 Program TWALK


Text:

'ProgramMode:RUN

"EWS 2022-08-04"

"RANDOM WALK 2.0"

"NO. TRIALS"?->N

N->Dim List 26

"NO. STEPS"?->S

Menu "STEPS","_(-)_1,1",2,"-1,0,1",3

Lbl 2:2->F:Goto 1

Lbl 3:3->F:Goto 1

Lbl 1

For 1->I To N

F=2=>Sum (2*RanInt#(0,1,S)-1)->List 26[I]

F=3=>Sum (RanInt#((-)1,1,S))->List 26[I]

Next

"POSITIONS LIST:"Disps

List 26Disps

(-)S->H Start

1->H pitch

S-Gph1 DrawOn,Hist,List 26,1,ColorLinkOff,Blue ColorLighter 

DrawStat



On the Screen:

"EWS 2022-08-04"

"RANDOM WALK 2.0"

"NO. TRIALS"?→N

N→Dim List 26

"NO. STEPS"?→S

Menu "STEPS","-1,1",2,"-1,0,1",3

Lbl 2:2→F:Goto 1

Lbl 3:3→F:Goto 1

Lbl 1

For 1->I To N

F=2⇒Sum (2×RanInt#(0,1,S)-1)→List 26[I]

F=3⇒Sum (RanInt#(-1,1,S))→List 26[I]

Next

"POSITIONS LIST:"◢

List 26◢

-S->H Start

1->H pitch

S-Gph1 DrawOn,Hist,List 26,1,ColorLinkOff,Blue ColorLighter 

DrawStat


Examples


N = 50, S = 5


(-1, 1):  Mosquito cannot rest





(-1, 0, 1): Mosquito can rest






Wishing you an excellent day,


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, April 10, 2022

Casio fx-CG 50 and fx-9750GIII: Regression Builder

Casio fx-CG 50 and fx-9750GIII:  Regression Builder


Introduction


The program LRBUILD lets the user fit bi-variate data (x,y) to a customized regression equation in the form:


y = C + Σ Cₙ * fₙ(x) 


where:


C = constant term.  This term is automatically calculated for by the program.


Cₙ = coefficient of each subsequent term of fₙ(x)


fₙ(x) = function, where the user can choose any of the following forms:


1.  x^A

2.  ln(A * x)

3.  e^(A * x)

4.  sin(A * x)


where A is a real number.  Angles are assumed to be in radian measure.  


For example, we can fit data by least squares method to this equation:


y = C + C_1 * x^2 + C_2 * e^(0.5 * x) + C_3 * sin(x)


You can add as many fₙ(x) terms as you like.


The program will give you the coefficients in a vertical matrix, starting from C and so forth, and the R^2 goodness of fit:


R^2 = 1 - SS_res / SS_tot


SS_res = Σ( y_observed - y_predicted)^2


SS_tot = Σ(y_observed - mean(y_oberserved))^2



Notes:


The characters _n (lower subscript n) and Σ (sigma symbol) are found on the CHAR (Character Select) on the programming editor menu (almost exit until the soft menu TOP, BOTTOM, SEARCH, ... displays).


The lines:


For 1 → I To 750

Next


are used to create a short pause.


There are two versions:  


Program files with the g3m extension is for the color Casio graphing calculators, such as the fx-CG50.   You can download this file here:

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



Program files with the g1m extension is for the monochrome Casio graphing calculators, such as the fx-9750GIII (United States) and the fx-9860GIII (International).  You can download this file here:

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



To transfer between Casio calculators, it is recommended to save them as text files.  Then transfer to the SAVE-F folder and load it on the home calculator.  Some editing may be necessary, such as <-1> with x^-1.


Casio fx-9750gIII and fx-CG50 (and probably most other Casio modern graphing calculators) Program: LRBUILD

(Extra spaces included for readability - this meant to be typed on the calculator)


Rad

ClrText

Locate 1,1,"LIN REG BUILDER"

Locate 1,2,"EWS 2022-01-17"

Locate 1,3,"Y=C+Σ(C_n×F_n(X))"   (n is the lower script n from the CHAR screen)

For 1 → I To 750

Next

"X DATA"? → List 1

"Y DATA"? → List 2

Dim List 1 → N

Dim List 1 → Dim List 3

{0} → List 4

{0} → List 5

Seq(1,X,1,N,1) → List 6

List→Mat(List 6) → Mat A

List→Mat(List 2) → Mat B

"CONSTANT TERM ADDED"

For 1 → I To 750

Next

Lbl 0

Menu "TERM?", "X^A", 1, "ln (AX)", 2, "e^(AX)", 3, "sin (AX)", 4, "CALCULATE", 5

Lbl 1

"A"? → A

Augment(List 4, {1}) → List 4

Got A

Lbl 2

"A"? → A

Augment(List 4, {2}) → List 4

ln(A×List 1) → List 6

Goto A

Lbl 3

"A"? → A

Augment(List 4, {3}) → List 4

e^(A×List 1) → List 6

Goto A

Lbl 4

"A"? → A

Augment(List 4, {4}) → List 4

sin(A×List 1) → List 6

Goto A

Lbl A

Augment(List 5, {A}) → List 5

List→Mat(List 6) → Mat D

Augment(Mat A, Mat D) → Mat A

Goto 0

Lbl 5

Dim List 4 → M

(Trn Mat A × Mat A)^-1 × Trn Mat A × Mat B → Mat C

"COEFFS:" ◢

Mat C ◢  

For 1 → I to N

0 → Y

For 1 → J To M

List 4[ J ] → L

List 5[ J ] → A

Mat C[ J, 1 ] → C

List 1[ I ] → X

L = 0 ⇒  Y + C → Y

L = 1 ⇒ Y + C × X^A → Y

L = 2 ⇒ Y + C × ln(AX) → Y

L = 3 ⇒ Y + C × e^(AX) → Y

L = 4 ⇒ Y + C × sin(AX) → Y

Next

Y = 0 ⇒ 1E-7    (lower case 10 on the fx-CG 50)

Y → List 3[ I ]

Next

1 - (Sum (List 2 - List 3)^2)÷(Sum (List 2 - Mean(List 2))^2) → R

"R^2="

R ◢

List→Mat(List 1, List 2, List 3) → Mat D



Variables:


List 1:  X Data

List 2:  Y Data

List 3:  Expected Y Data (Calculated)

List 4:  Operation Types:  0 - constant, 1 - x^a, 2 - ln(a*x), 3 - e^(a*x), 4 - sin(a*x)

List 5:  A


Mat A:  X data matrix 

Mat B:  Y data matrix

Mat C:  matrix of calculated coefficients



Examples


Example 1:

Fit the following data:


x data = {10, 25, 34, 46, 65}

y data = {39.7, 100, 135.9, 183.9, 260}


to the curve y = C + C1 * x + C2 / x


Remember the constant term is automatic.   

On the TERM? menu, select 

1.  X^A with A = 1

1.  X^A (again), this time with A = -1

5.  CALCULATE


Calculated coefficients:

[[ 0.1012904425 ]

[ 3.99874051 ]

[ -3.775351133 ]]


y = 0.012904425 + 3.99874051x - 3.775351133/x


R^2 = 0.9999994909


y' predicted data: 

{39.71116043, 99.91878916, 135.947281, 183.9612811, 259.9613413}


Example 2:

Fit the following data:


x data = {-0.35, -0.16, 0.27, 0.84}

y data = {-0.64, -0.31, 0.58, 2.06}


to the curve y = C + C1 * sin x  + C2 * e^x


Remember the constant term is automatic.   

On the TERM? menu, select 

4.  sin(A*X) with A = 1

3.  e^(A*X) with A = 1

5.  CALCULATE


Calculated coefficients:

[[ -0.9847711767 ]

[ 1.023495272 ]

[  0.9854914931 ]]


y = -0.9847711767 + 1.023495272 * sin x + 0.9854914931 * e^x


R^2 = 0.9999986129


y' predicted data:

{-0.6412613439, -0.3080521531, 0.5791860102, 2.060127487}


Example 3:

Fit the following data:


x data = {2, 3, 4, 5, 6}

y data = {22.5, 34, 45.5, 57.5, 69.75}


to the curve y = C + C1 * x^1.2 + C2 * ln(3*x)


Remember the constant term is automatic.   

On the TERM? menu, select 

1.  X^A with A = 1.2

2.  ln(A*X) with A = 3

5.  CALCULATE


Calculated coefficients:

[[ -0.08646217016 ] 

[ 6.83429695 ]

[ 3.855357541 ]]


y = -0.08646217016 + 6.83429695 * x^1.2 + 3.855357541 * ln(3* x)


R^2 = 0.9999924407


y' predicted data:

{22.52250254, 33.92570965, 45.56537698, 57.50145068, 69.73496014}


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. 


Earth's Radius by Latitude

Earth's Radius by Latitude Introduction: Calculating the Earth’s Radius In quick, general calculations, we assume that the...