Showing posts with label cross product. Show all posts
Showing posts with label cross product. Show all posts

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. 


Saturday, April 23, 2022

Applications: Sharp EL-5150

Applications:  Sharp EL-5150 


Note:  spaces included for readability

Fan Laws

AER Equation:
1; f(BCDI) = B * ( C ÷ D ) Y^x ( 1 ÷ I  )

Variables:
Calculate CPM_new
B = CPM_old

1st Fan Law:
I = 1
C = RPM_new
D = RPM_old

2nd Fan Law:
I = 2
C = SP_new
D = SP_old

3rd Fan Law:
I = 3
C = BHP_new
D = BHP_old

Example 1:

Fan Law 2:
CPM_old = B = 4000 CPM
SP_new = C = 48 
SP_old = D = 36
I = 2

Result:  4618.802153

Example 2:

Fan Law 3:
CPM_old = B = 3500 CPM
BHP_new = C = 59
BHP_old = D = 52
I = 3

Result:  3650.488072


Ideal Shockley Diode Equation


I = I0 * e^((VD/(n* VT) - 1)
where VT = K * T/q

I = diode current (amps)
I0 = saturation current (amps)
VT = thermal voltage (V) - see notes below
VD = voltage across the diode (V)
n = ideality factor, in ideal situations, n = 1

Notes:  

*  The equation below assumes the ideal diode, n = 1
*  The equation uses a ratio of scientific constants:  k/q 
*  k = Boltzmann's Constant = 1.380649 * 10^-23 J/K
*  q = Charge of an Electron = 1.602176634 * 10^-19 C  (on some calculators, like the Casio fx-991EX, this constant is labeled e)
*  k/q = 8.617332385 * 10^-5 J/(K*C) = 8.617332385 * 10^-5 V/K  (volts/degrees Kelvin)

AER Equation:
1; f(IDE) = 8.617332385E-5 × E STO A, I ×(e(D ÷ A) - 1)

Calculate VT (stored in A), the I 
I = I0
D = VD
E = temperature in Kelvin

Example 1:

I = 4E-6 A 
D = 0.08 V
E = 280 K

Results:
A = 0.024128531, (I) 0.00001061
 
Example 2:

I = 4E-6 A 
D = 0.06 V
E = 300 K

Results:
A = 0.025852000, (I) 0.00003674

Dot and Cross Product of Two 3D Vectors

For the two vectors [A, B ,C] and [D, E, F]:

AER Equations:
1; f(ABCDEF) = A × D + B × E + C × F ◣
2; B × F - C × E, C × D - A × F, A × E - B × D

Example 1:
[ A, B, C ] and [ D, E, F]

[ 4.5, -2.5, -8 ] and [ 1.6, 3.9, 6 ]

Dot Product:  -50.55
Cross Product:  [ 16.2, -39.8, 21.55 ]

Example 2:
[ A, B, C ] and [ D, E, F]

[ 4, 3, 2 ] and [ 2, 7, 0 ]

Dot Product:  29
Cross Product:  [ -14, 4, 22 ]

Law of Cosines

Sides with lengths A, B, C with D as the angle opposite of A.  Equation 1 finds the length of side A, while Equation 2 finds the angle D.

AER Equations:
1; f(BCD) = √(B^2 + C^2 - 2 × B × C × COS D) STO A ◣
2; f(ABC) = cos^-1 ((B^2 + C^2 - A^2) ÷ (2 × B × C)) STO D

Example 1 - find A:
Degree Mode Set
Input:  B = 4.5, C = 3.7, D = 30°
Run 1:

Result:  2.258617731


Example 2 - find D:
Degree Mode Set
Input:  A = 40, B = 56, C = 38
Run 2:

Result:  45.5579132°


Note:  Due to the incredible amount of spam comments that get sent on this blog, which I moderate so the readers don't see them, I have decided to turn comments off.  I will review whether to turn comments back on at a later time.  My apologizes to those who leave legitimate comments.  

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. 

Saturday, September 18, 2021

Sharp EL-5500III & PC-1403: Complex Number Arithmetic and Vectors

 Sharp EL-5500III & PC-1403:  Complex Number Arithmetic and Vectors


Complex Number Arithmetic

This program calculates the four arithmetic functions for complex numbers in the form of x + i*y, where i = √-1.

Sharp EL-5500III/PC-1403 Program:  Complex Number Arithmetic
RUN 600 (or whatever line you designate)

600 PRINT "COMPLEX ARITHMETIC"
603 INPUT "A? "; A, "Bi? "; B, "C? "; C, "Di? "; D
606 INPUT "1:+ 2:- 3:* 4:/ :"; H
609 IF H=1 THEN 630
612 IF H=2 THEN 640
615 IF H=3 THEN 650
618 IF H=4 THEN 660
621 GOTO 606
630 PRINT A+C; "+ "; B+D; "i": END
640 PRINT A-C; "+ "; B-D; "i": END
650 PRINT A*C-B*D; "+ "; B*C+A*D; "i": END
660 W=(C^2+D^2)
663 PRINT (A*C+B*D)/W; "+ "; (B*C-A*D)/W; "i": END

Example

a + bi = 8 + 3i;  c + di = -4 + 2i
Add: 4 + 5i
Subtract: 12 + 1i
Multiply: -38 + 4i
Divide:  -1.3 + -1.4i

Vectors

This program calculates the dot product, cross product, and the angle between of two vectors.   

Sharp EL-5500III/PC-1403 Program:  Vectors
RUN 800 (or whatever line you designate)

800 PRINT "TWO VECTORS"
803 DIM A(2): DIM B(2)
806 INPUT "A0? "; A(0), "A1? "; A(1), "A2? "; A(2)
809 INPUT "B0? "; B(0), "B1? "; B(1), "B2? "; B(2)
812 INPUT "1.DOT 2.CROSS 3.ANGLE :"; H
815 IF H=1 THEN 830
818 IF H=2 THEN 840
821 IF H=3 THEN 850
824 GOTO 812
830 D=A(0)*B(0)+A(1)*B(1)+A(2)*B(2)
832 PRINT "DOT = ";D : END
840 DIM R(2): R(0)=A(1)*B(2)-A(2)*B(1)
842 R(1)=A(2)*B(0)-A(0)*B(2)
844 R(2)=A(0)*B(1)-A(1)*B(0)
846 PRINT "R0:";R(0) :PRINT "R1:";R(1) :PRINT "R2:";R(2)
848 END
850 X=√(A(0)^2+A(1)^2+A(2)^2)
852 Y=√(B(0)^2+B(1)^2+B(2)^2)
854 D=A(0)*B(0)+A(1)*B(1)+A(2)*B(2)
856 N= ACS (D/(X*Y))
858 PRINT "ANG = "; N: END

Example (Degrees mode set)

A:  A(0) = 4, A(1) = -3, A(2) = 2
B:  B(0) = 6, B(1) = 7, B(2) = -1
Dot:  1
Cross: R(0) = -11, R(1) = 16, R(2) = 46
Angle:  88.85263015°

Eddie

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

Friday, May 11, 2018

Fun with the Sharp EL-5500 III (May 2018 Edition)


Fun with the Sharp EL-5500 III   (May 2018 Edition)

The EL-5500 III is one of my favorite pocket programming device, small, portable, and has my favorite programming language: BASIC. 

Let’s get started.

Note:  Substitute line numbers with labels that you find fit.  Add defined labels to the first line if you would like.  Labels can come from the bottom two rows of the QWERTY keyboard (A row and Z row).

Comments are followed by double slashes (//), they are not typed.

Sharp EL-5500 III Program:  Net Present Value

2  PAUSE “NET PRESEN VALUE”
4  CLEAR    // clears all the variables
6  INPUT “CF0:”; N, “RATE:”; I
8  J = 1
10 INPUT “FLOW:”; F, “FREQ:”; K
12 FOR L=1 TO K: N = N + F/(1 + I/100)^J: J = J+1
14 NEXT L
16 INPUT “MORE=1: “; L   // enter 1 to enter more cash flows, anything else to end entry
18 PRINT USING “#############.##”; “NPV: “; N
20 END

Example:

CF0:  -7,000,  Interest Rate:  8%
Flow 1:  2,000, Freq 1: 1  (enter 1 for MORE)
Flow 2:  1,500, Freq 2: 2  (enter 1 for MORE)
Flow 3:  2,500, Freq 3: 2  (we are at the end, enter anything other than 1 at MORE)

Result:
NPV:  2443.06

Sharp EL-5500 III Program: Synthetic Division

2 PAUSE “Synthetic Division”: CLEAR
4 PRINT “P(X)/(X – R)”: WAIT 59   // WAIT 59 is about 1 second
6 INPUT “DEGREE:”; N
8 DIM P(N): DIM Q(N)
10 FOR I=1 TO N
12 PRINT “COEF OF X^”; N-I
14 INPUT P(I): Q(I) = P(I)
16 NEXT I   // there is no line 18
20 INPUT “R:”; R
22 FOR I=0 TO N-1
24 Q(I+1) = R*Q(I) + P(I+1)
26 NEXT I
28 E = Q(N)
30 PRINT “Q(X) = “
32 FOR I=0 TO N-1
34 PRINT Q(I); “X^”; N-I-1
36 WAIT 150  // about 2.5 seconds
38 NEXT I
40 PRINT “+”; E; “/(X-“; R; “)”: END

Example:  (x^4 – 2*x^3 + 1) / (x – 1)
Degree: 4
Coefficients:  1, -2, 0, 0, 1
R: 1

Result: 1, -1, -1, -1, no remainder
x^3 – x^2 – x – x

Sharp EL-5500 III Program: Vector Basics

Cross product, dot product, norm of two vectors, angle between two vectors

2 PAUSE “Vector Basics”
4 INPUT “X1:”; X1, “Y1:”; Y1, “Z1:”; Z1  \\ vector 1
6 INPUT “X2:’; X2, “Y2:”; Y2, “Z2:”, Z2  \\ vector 2
8 C1 = Y1*Z2 – Y2*Z1: C2 = -X1*Z2 + X2*Z1: C3 = X1*Y2 – X2*Y1  // cross product
10 D = X1*X2 + Y1*Y2 + Z1*Z2  \\ dot product
12 N1 = √(SQU X1 + SQU Y1 + SQU Z1): N2 = √(SQU X2 + SQU Y2 + SQU Z2)  // norm, SQU is the x^2 key
14 DEGREE
16 A = ACS( D/(N1*N2))  // angle between vectors, ACS is ACOS
18 PRINT “CROSS X: ”; C1
20 PRINT “CROSS Y: ”; C2
22 PRINT “CROSS Z: ”; C3
24 PRINT “DOT: ”; D
26 PRINT “NORM V1: “; N1
28 PRINT “NORM V2: “; N2
30 PRINT “ANGLE: “; A
32 END


Example:  V1 = [-2, 3, 0] and V2 = [ 4, 2, -11]
Cross: [-33, -22, -16]
Dot: -2
Norm V1: 3.605551275
Norm V2: 11.87434209
Angle: 92.67749998°

Sharp EL-5500 III: Atwood Machine

M1:  mass hanging on the left side of the machine
M2:  mass hanging on the right side of the machine

The program asks to choose a unit system.  Enter 1 for US units (feet, pounds, seconds, g = 32.174 ft/s^2), anything else for SI units (meters, kilograms, seconds, g = 9.80665 m/s^2).

2 PAUSE “Atwood Machine”
4 INPUT “1: US, ELSE: SI “; I
6 IF I=1 THEN LET G=32.174
8 IF I<>1 THEN LET G=9.80665
10 INPUT “M1: “; M1, “M2: “; M2
12 A = (M1 – M2)*G / (M1 + M2)
14 T = M1 * (G-A)
16 PRINT “Accel.: “; A
18 PRINT “Tension: “: T
20 END

Example:  M1 = 11.82 kg, M2 = 9.38 kg, use SI units (enter anything other than 1 at the 1:US, ELSE:SI prompt)

Results:
Accel.: 1.128689906 m/s^2
Tension: 102.5734883 N


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.

RPN HP 12C: Fibonacci and Lucas Sequences

  RPN HP 12C: Fibonacci and Lucas Sequences Golden Ratio, Formulas, and Sequences Let φ be the Golden Ratio: φ = (1 + √5) ÷ 2...