Showing posts with label summation. Show all posts
Showing posts with label summation. Show all posts

Sunday, December 9, 2018

Fun with the Infinite Series 1 + x + x^2 + x^3 + x^4 + x^5 + ...

Fun with the Infinite Series 1 + x + x^2 + x^3 + x^4 + x^5 + ...


The Series and Its Derivatives

Let F be the infinite series:

F = 1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + ... = ∑ x^k from k = 0 to ∞.

Working with derivatives:

----

First Derivative of F:  (F' = dF/dx)

F' = 1 + 2*x + 3*x^2 + 4*x^3 + 5*x^4 + 6*x^5 + 7*x^6 + ... 
= ∑ (k+1)*x^k from k = 0 to ∞

----

Second Derivative of F:  (F'' = d^2F/dx^2)

F'' = 2 + 6*x + 12*x^2 + 20*x^3 + 30*x^4 + 42*x^5 + 56*x^6 + ....

Factor out a 2:
= 2 * (1 + 3*x + 6*x^2 + 10*x^3 + 15*x^4 + 21*x^5 + 28*x^6 + .... )

Note the sequence 1, 3, 6, 10, 15, 21, 28...  These are triangle numbers, denoted as T_n.  

T_1 = 1
T_2 = 1 + 2 = 3
T_3 = 1 + 2 + 3 = 6
T_4 = 1 + 2 + 3 + 4 = 10 
and so on.

Using summation notation,  T_n = ∑ k from k = 1 to n

Going back to the series:

F'' = 2 + 6*x + 12*x^2 + 20*x^3 + 30*x^4 + 42*x^5 + 56*x^6 + ....
= 2 * (1 + 3*x + 6*x^2 + 10*x^3 + 15*x^4 + 21*x^5 + 28*x^6 + .... )
= 2 * (∑ x^k * T_k+1 from k = 0 to ∞)

In nested summation notation:

= 2 * (∑ x^k * (∑ m from m = 1 to k+1) from k = 0 to ∞)


Addition with F, F', and F"


F + F' = 2 + 3*x + 4*x^2 + 5*x^3 + 6*x^4 + 7*x^5 + 8*x^6 + ...
= ∑ ((k + 2) * x^k from k = 0 to ∞)

----

F + F' + F'' = 4 + 9*x + 16*x^2 + 25*x^3 + 36*x^4 + 49*x^5 + 64*x^6 + ...
= ∑ ((k + 2)^2 * x^k from k = 0 to ∞)

----

F' + F" = 3 + 8*x + 15*x^2 + 24*x^3 + 35*x^4 + 48*x^5 + 63*x^6 + ...

Note the sequence 3, 8, 15, 24, 35, 48, 63... where
3 = 4 - 1 = 2^2 -1
8 = 9 - 1 = 3^2 - 1
15 = 16 - 1 = 4^2 - 1
24 = 25 - 1 = 5^2 - 1
35 = 36 - 1 = 6^2 - 1
48 = 49 - 1 = 7^2 - 1
63 = 64 - 1 = 8^2 - 1
and so on...

This can be summarized as ∑( (k + 2)^2 - 1 from k = 0 to ∞)

Hence:
F' + F" = 3 + 8*x + 15*x^2 + 24*x^3 + 35*x^4 + 48*x^5 + 63*x^6 + ...
= ∑  ((k + 2)^2 - 1) * x^k from k = 0 to ∞)

Multiplying F and F' by x and x^2 

F = 1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + ... = ∑ x^k from k = 0 to ∞.
x * F = x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + ... = ∑ x^(k+1) from k = 0 to ∞.
x^2 * F =  x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + ... = ∑ x^(k+2) from k = 0 to ∞.

-----

F + x * F = 1 + 2*x + 2*x^2 + 2*x^3 + 2*x^4 + 2*x^5 + 2*x^6 + ...
= 2 - 1 + 2*x + 2*x^2 + 2*x^3 + 2*x^4 + 2*x^5 + 2*x^6 + ...
= 2 + 2*x + 2*x^2 + 2*x^3 + 2*x^4 + 2*x^5 + 2*x^6 + ... - 1
= 2 * F - 1

This is one way to dervie the formula for the Infinite Geometric Series (for |x| < 1), to solve for F:

F + x * F  = 2 * F - 1
F + x * F - 2 * F = -1
F * (1 + x - 2) = -1
F * (x - 1) = -1
F = -1 / (x - 1)
F = 1 / (1 - x)   (keep this mind, this is true only when |x| < 1)

----

F - x * F = (1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + ... ) - (x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + ... )
= F * (1 - x)

For |x| < 1,

F * (1 - x) = 1 / (1 - x) * (1 - x) = 1

In general:
F - x * F = (1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + ... ) - (x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + ... )
= 1 + (x - x) + (x^2 - x^2) + (x^3 - x^3) + (x^4 - x^4) + (x^5 - x^5) + (x^6 - x^6) + ...
= 1

F - x * F = 1

----

F' = 1 + 2*x + 3*x^2 + 4*x^3 + 5*x^4 + 6*x^5 + 7*x^6 + ... 
= ∑ ((k + 1) * x^k from k = 0 to ∞)

x * F' = x + 2*x^2 + 3*x^3 + 4*x^4 + 5*x^5 + 6*x^6 + 7*x^7 + ... 
= ∑ ((k + 1) * x^(k + 1) from k = 0 to ∞)


x^2 * F' = x^2 + 2*x^3+ 3*x^4 + 4*x^5 + 5*x^6 + 6*x^7 + 7*x^8 + ... 
= ∑ ((k + 1) * x^(k + 1) from k = 0 to ∞)

----

F' + x * F' = 1 + 3*x + 5*x^2 + 7*x^3 + 9*x^4  + 11*x^5 + 13*x^6 + ...

The sequence of 1, 3, 5, 7, 9, 11, 13, ... is the sequence of odd numbers which can be summarized as:

∑(2 * k + 1 from k = 0 to ∞)

Then:

F' + x * F'  =  F' * (1 + x) = ∑( (2*k + 1) * x^k from k = 0 to ∞)

----

F' + x * F' + x^2 * F' = 1 + 3*x + 6*x^2 + 9*x^3 + 12*x^4 + 15*x^5 + 18*x^6 + ...
= 1 + ( 3*x + 6*x^2 + 9*x^3 + 12*x^4 + 15*x^5 + 18*x^6 + ... )
= 1 + ∑(3 * k * x^k from k = 0 to ∞)

Eddie

All original content copyright, © 2011-2018.  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.  Please contact the author if you have questions.

Wednesday, July 18, 2018

Fun with the FX-603P Emulator


Fun with the FX-603P Emulator





Author for the Emulator:  Martin Krischik



Cost: $5.99 (there is an fx-602P scientific calculator emulator for $4.99, similar programming language but only 10 programming spaces instead of 20)

The app is emulates the 1990 Casio fx-603P calculator.



Decibels to Pressure

Program: (29 steps)

“DB?”  HLT  ÷ 20  = 10^x  *  2E-5  = “Pressure:” HLT

Examples:

DB = 30 dB; Result:  6.32455532 * 10^-4 N/m^2

DB = 120 dB; Result:  20 N/m^2

Turn Performance

Given a plane’s true air speed (TAS in knots), stall speed (in knots), and required bank turn (in degrees), the following are calculated:

1. G force
2.  Normal stall speed for the plane during the turn (knots)
3.  Turn diameter (nautical miles)
4.  Time it takes for the turn to be complete (in minutes)

Formulas:

G = 1/(cos(bank))

Stall speed = normal stall speed * G

Diameter = TAS^2 / (34208 * tan(bank))

Time = (0.0055 * TAS) / tan(bank)

Memory Registers:

Input:

M00 = TAS, M01 = Stall speed, M02 = Bank

Output:

M03 = G force, M04 = resulting stall speed, M05 = diameter, M06 = time

Program: (110 steps)

DEG “TAS?” HLT Min00
 “Norm. Stall?” HLT  Min01
 “Bank?” HLT Min02
MR02 cos 1/x Min03 “G:” HLT
MR03 √ * MR01 = “Stall Speed:” HLT
MR00 x^2 ÷ ( MR02 tan * 34208 ) = Min05 “Diameter:” HLT
0.0055 * MR00 ÷ MR02 tan “Time:” HLT Min06

Notes: 
DEG:  [ MODE ] [ 4 ]


Example:

Inputs:
TAS: 123 knots
Norm. Stall:  60 knots
Bank:  44.8°

Results:
G:  1.409302674
Stall Speed: 71.22843498 knots
Diameter:  0.445363387 n.m.
Time: 0.681239424 minutes (about 40.87 seconds)

Source:  “Turn Performance” HP 65 Aviation Pac-1 Hewlett Packard.  1974
.

Sum of a Function

This program uses the subroutine (under P9 with the variable MinF, or any register M04 or after) to calculate the summation:

Σ f(x) for x = a to b

The sum is stored in M03.

Note: when entering a new f(x), clear P9 (MODE, 3, P9, AC) first before entering the new function.  It’s a lot cleaner.

Main Program:  (34 bytes)

0 Min03
“a?” HLT Min01
“b?” HLT Min02
MR02 – MR01 + 1 = Min00
Lbl0
MR01 GSBP9 M+03
1 M+01
DSZ Goto0
MR03 “Σ=”

Note: 
Lbl0:  [ LBL] [ 0 ]
GSBP9: [GSB] [ P9 ]
Goto0:  [ GOTO ] [ 0 ]
The character Σ:  (in ALPHA) [SHIFT] [ 7 ]
Memory F:  [ Min ], [ MR ], etc.  [EXE] for F.

Examples:

Σ n^2 + 3*n – 6 for n = 1 to 8 
Subroutine:
Min0F x^2 + 3 * MR0F – 6 =

Result:  264

Σ (n^3 – 1)/(n^2 + 1) for n = 0 to 11
Subroutine:
( Min0F x^y 3 – 1 ) /div (MR0F x^2 + 1 ) =

Result: 61.6582396282

Combinations: where Repetition is allowed

The program calculates the number of combinations where repeats are allowed.

nHr = (n + r – 1)! / (r! * (n -1)!)

Program:  (39 steps)

“n?” HLT Min01
“r?” HLT Min02
( MR01 + MR02 – 1) x!
÷ ( MR02 x! * ( MR01 – 1 ) x! )
= “nHr=”

Examples:

Input: n = 5, r = 3.  Result:  35

Input: n = 12, r = 6.  Result:  12376

Aviation:  Rate of Climb

This program calculates the rate-of-climb (ft/min) when plane increases the elevation (in feet) given the distance to the mountain (in nautical miles, n.m.) and the true air speed (TAS, in knots). 

Formula:

ROC = ( TAS * ΔALT  ) / (60 * (dist^2 + (ΔALT/6077.1155)^2) )

Program: (88 steps)

6077.1155 Min0F
“TAS (knots)?” HLT Min01
“CHG ALT (ft)?” HLT Min02
“DIST (n.m.)?” HLT Min03
( MR01 * MR02 ) ÷
( 60 * ( MR03 x^2 + (
MR02 ÷ MR0F ) x^2
)   √ = “ROC:”

Example:

Input:
TAS = 87 knots
CHG ALT = 4800 ft
DIST = 13.3 n.m.

Result:
522.3878955 ft/min

Source:  “Rate of Climb and Descent” HP 65 Aviation Pac-1 Hewlett Packard.  1974

Eddie


All original content copyright, © 2011-2018.  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.  Please contact the author if you have questions.

Thursday, November 24, 2016

Casio fx-7400g Plus: Program Library

Casio fx-7400g Plus: Program Library


Contents:
* Polar Graphing (POLAR)
* Summation and Integration (FX, SUMFX, INTFX)
* Binomial Expansion (BINOMEXP)
* Forward Triangle Intersection (FORDINT)
* Coordinates of a Traverse (TRAVEZ)
* Quadratic Equation (QUAD)


The classic fx-7400g (we’re talking about the early 2000s) lacked numerical integration, summation, and polar graphing.  Let’s remedy that through programming.

Fortunately any of the programs created on the fx-7400g Plus can be translated literally to later Casio graphing calculators. 


Casio fx-7400g Plus Program POLAR
  
Program POLAR
ClrGraph
Rad
“THETA MIN”? → A
“THETA MAX”? → B
“THETA STEP”? → S
For A → I To B Step S
sin (2I) →  R       (see note below)
PlotOn R cos I, R sin I
Next
DrawGraph

Notes:
*  This is best used when the function list is clear.
*  Set up graph screen parameters (Xmin, Xmax, Ymin, Ymax) before hand.
*  Insert polar functions by editing the 7th line (in italics), using I for θ.  The result must be stored to R  (by → R).

Casio fx-7400g Plus Programs FX, SUMFX, INTFX

The programs SUMFX and INTFX will require the subroutine program FX.  FX is where you insert the function f(x).   The result is stored to Y. 

Program FX
X^2+1 → Y
Return

Program SUMFX
“LOWER”? → L
“UPPER”? → U
0 → T
For L → X To U
Prog “FX”
T + Y → T
Next
“SUM=”
T

Example:  FX contains X^2 +1, with L = 1, U = 15.  Result:  1255
Program INTFX
“LOWER”? → L
“UPPER”? → U
“NO. PARTS”? → N
Rad
L → X
Prog “FX”
Y → T
U → X
Prog “FX”
T + Y → T
(U – L) ÷ N → H
For 1 → I To N-1
L + I * H → X
Prog “FX”
If I Rmdr 2 = 0
Then T + 2*Y → T
Else T + 4*Y → T
IfEnd
Next
T * H ÷ 3 → T
“INTEGRAL=”
T

Example:  FX contains X^2 +1, with L = 1, U = 15, N = 24.  Result:  1138.666667

Casio fx-7400g Plus Program BINOMEXP

The program BINOMEXP shows the coefficients of the binomial expansion (Ax + B)^N.

Program BINOMEXP
“(AX+B)^N”
“A”? → A
“B”? → B
“N”? → N
For 0 → I To N
N nCr I * A^(N-I) * B^I → T
“{COEF, POWER}”
{T, N-I}
Next

Example:  (2x – 3)^2
Results:  {4, 2}, {-12, 1}, {9, 0}   (4x^2 – 12x + 9)


 Casio fx-7400g Plus Program FORDINT

The program FORDINT calculates the third point on a triangle where the coordinates of points A  (xa, xb) and B (xb, yb) are known.  Also, a line towards P point is aimed from point A at angle α° and from point B at angle β°. 

Variable
Casio fx-7400g Plus
Variable
Casio fx-7400g Plus
Variable
Casio fx-7400g Plus
xa
N
ya
S
α
A
xb
O
yb
T
β
B
xp
P
yc
U
γ
C


Source: Casio.   Casio fx-FD10 Pro User’s Guide Tokyo. 2014

Program FORDINT
Deg
“XA”? → N
“YA”? → S
“ANGLE A”? → A
“XB”? → O
“YB”? → T
“ANGLE B”? → B
1 ÷ tan A + 1 ÷ tan B → C
(N ÷ tan B + O ÷ tan A + (T – S)) → P
(S ÷ tan B + T ÷ tan A + (N – O)) → U
180 – A – B → C
“{XP, YP, C}”
P
U
C

Example:
Point A:  (1000, 950), angle towards point P:  30°
Point B:  (1012, 997), angle towards point P:  44°

Result:
Point P:  (approximately) (1024.49237, 975.078358)
Angle γ: 106°

Casio fx-7400g Plus Program TRAVEZ

TRAVEZ calculates the new point knowing the original coordinates, direction, and angle of travel.  The angle 0° comes from due east and rotates counterclockwise.

Program TRAVEZ
Deg
“1ST EAST”? → E
“1ST NORTH”? → N
0 → D
Lbl 1
“DISTANCE”? → I
“ANGLE”? → A
I * cos A + E → E
I * sin A + N → N
D + I → D
“POINT”
{E, N}
“DONE? Y=1”
? → Y
Y ≠ 1 Goto 1
“DISTANCE =”
D

Example:  Initial point (1000,1000)
Distance: 750, Angle:  276; Point {1078.396347, 254.1085785}
Distance: 600, Angle:  35; Point {1569.887574, 598.2544403}
Distance: 700, Angle:  118; Point {1241.25748, 1216.317755}
Total Distance:  2050

Casio fx-7400g Plus Program QUAD

The program QUAD is the quadratic equation which finds the roots of

Ax^2 + Bx + C = 0

Yes, I just can’t resist.

Program QUAD
“A”? → A
“B”? → B
“C”? → C
B^2 – 4AC → D
If D≥0
Then “REAL ROOTS”
(-B + √D) ÷ (2A) → S
(-B - √D) ÷ (2A) → T
Else “ROOTS S+TI”
-B ÷ (2A) → S
√(Abs D) ÷ (2A) → T
IfEnd
{S, T}


Example:
A = 2.5, B = -3, C = -1.1
Roots:  “REAL ROOTS”, 1.494427191, -0.294427191


A = 2.5, B = -3, C = -1.1
Roots:  “ROOTS S+TI”,  -0.375 ± .3665719575i   (T:  -3.665719575)

Happy Thanksgiving!  Eddie


This blog is property of Edward Shore, 2016.





Sunday, March 20, 2016

PrgCalcPro: Summation

PrgCalcPro: Summation

Summation

This program uses a loop to determine Σ f(X) from a to b.   The function f(X) starts on Line 22.  Use Memory Register a as X and finish the function with RET.   The sum is stored in Memory 0. 

The listing here uses f(X) = X^2 + 1.  

To run: enter a, press [ E up-arrow ], b, [RET], [RUN]

0: 4B  ;  MB
   1: 14  ;  XY // X<>Y
   2: 4A  ;  MA
   3: 00  ;  0 // clear memory 0
   4: 40  ;  M0
   5: 53  ;  SUB // determine f(X), loop starts here
   6: 22
   7: 60  ;  R0
   8: 10  ;  +
   9: 40  ;  M0
  10: 6A  ;  RA // add 1 to a, prepare for next loop
  11: 01  ;  1
  12: 10  ;  +
  13: 4A  ;  MA
  14: 6B  ;  RB
  15: 11  ;  -
  16: 01  ;  1
  17: 11  ;  -
  18: 59  ;  X>=0 // is a - (b+1) ≥ 0?
  19: 05 // if not repeat the loop
  20: 60  ;  R0
  21: 50  ;  STOP // terminate
  22: 6A  ;  RA // this is where f(X) starts
  23: 22  ;  X^2
  24: 01  ;  1
  25: 10  ;  +
  26: 52  ;  RET // don't forget to include RET at the end

Example:

Σ x^2 + 1 from x=0 to x=5.   Result: 61. 

This blog is property of Edward Shore,   2016.  

Saturday, August 9, 2014

HP RPN Advance Functions Video Up and Running

This is part two of the RPN Mode for HP Prime tutorial.  This time I am taking about advanced functions, such as numeric integrals, numeric derivatives, summation, and solving equations.

Link to the video:

http://youtu.be/YAJwjpldiak

DETAILS:


Syntax - RPN Mode:
-----
MAX and MIN
Path:  Toolbox, Math, 2, 1 for MAX (2 for MIN)

Syntax:
1:  list or vector
MAX(1) or MIN(1)
 - or -
Numbers on the stack
MAX(n) or MIN(n)   (n is 9 or less)
-----
Factorizing Integers – CAS.ifactor

1.  Enter the integer to be factorized, press the Enter key.
2.  Press Toolbox, CAS, 5, 2, 1 to execute CAS.ifactor(1)
-----
Generating a Sequence - MAKELIST
Path:  Toolbox, Math, 6, 1

Stack:
5:  ‘function in single quotes’
4:  ‘variable in single quotes’
3:  beginning point
2:  ending point
1:  increment/decrement
MAKELIST(5)
-----
Finding the Roots of a Polynomial - CAS. proot
Path:  Toolbox, CAS, 6, 1

Stack:
1:  vector or list of coefficients (decreasing power of x)
CAS.proot(1)
-----
Summation – CAS.sum
Path: Toolbox, Math, 2, 5

Stack:
4:  ‘function in single quotes’
3:  ‘variable’
2:  starting point
1:  finishing point
CAS.sum(4)
-----
Numerical Integration
1.  Press the Template Key, choose ∫ (2nd row, 4th column)
2.  Fill in the template – use capital letters for the variable
3.  Press the Enter Key
4.  Finally, press Toolbox, CAS, 1, 1 to execute CAS.simplify(1)
-----
Numerical Derivative
1.  Store value in the variable: Number, Enter Key, Variable in single Quotes, Shift Key, EEX Key
2.  Press the Template Key, choose ∂ (1st row, 4th column).  Fill in the template – use capital letters
for the variable, and press the Enter Key
3.  Finally, press Toolbox, CAS, 1, 1 to execute CAS.simplify(1)
-----
Matrix Operations
Put the matrix on the stack.  Use the Template Key, choose matrix (1st row, 6th column).

Determinant:  Press Toolbox, Math, 7, 2.  Determinant is calculated automatically. 
Inverse:  Press Shift, then the division key. (x^-1).  This works for square matrices only.
Eigenvalues:  Press Toolbox, Math, 7, 6, 1.  CAS.EIGENVAL is called.  Execute CAS.EIGENVAL(1).
-----
Finding Numerical Roots using FNROOT
Path:  Toolbox, Math, 2, 4
Stack:
3:  ‘function in single quotes’
2:  ‘variable’
1:  guess
Execute FNROOT(3)

Format:   function = 0
-----


Eddie


This blog is property of Edward Shore.  2014
 

Spotlight: Akron Brass FireCalc Pocket Computer

Spotlight: Akron Brass FireCalc Pocket Computer Welcome to a special Monday Edition of Eddie’s Math and Calculator blog. Thi...