Showing posts with label vectors. Show all posts
Showing posts with label vectors. Show all posts

Saturday, June 13, 2026

Numworks (Python): Parallelograms Described by Vectors

Numworks (Python): Parallelograms Described by Vectors



Introduction



The script drawpgram.py draws a parallelogram constructed by a pair of two-dimensional vectors. Both vectors original from the origin of the Cartesian plane ([0, 0]). Let the two vectors be labeled as [x1, y1] and [x2, y2].



This script also calculates the area and perimeter of the constructed parallelogram consisting of the end points (0,0), (x1, y1), (x2, y2), and (x1+x2, y1+y2).







Then the perimeter of the parallelogram is calculated as:

perimeter = 2 * (norm([x1, y1] + norm[x2, y2]) = 2 * (√(x1 + y1) * √(x2, y2))



And the area is calculated as:

area = abs(det([[x1, y1] [x2, y2]])) = abs(x1 * y2 – x2 * y1)





Numworks Script: drawpgram.py

Modules used: Math, PyPlot



Script page: https://my.numworks.com/python/ews31415/drawpgram



# Draw a parallelogram with two vectors

# Edward Shore, 2/15/2026

# Numworks

# drawpgram.py



from math import *

from matplotlib.pyplot import *



print("Draw a parallelogram with 2 vectors")

x1=eval(input("x1? "))

y1=eval(input("y1? "))

x2=eval(input("x2? "))

y2=eval(input("y2? "))



# Area

area=abs(x1*y2-x2*y1)



# Perimeter

perim=2*((x1**2+y1**2)**(1/2)+(x2**2+y2**2)**(1/2))





minx=min([x1,x2,x1+x2,0])

maxx=max([x1,x2,x1+x2,0])

miny=min([y1,y2,y1+y2,0])

maxy=max([y1,y2,y1+y2,0])



axis((minx-1,maxx+1,miny-1,maxy+5))



plot([0,x1],[0,y1],'blue')

plot([0,x2],[0,y2],'purple')

plot([x1,x1+x2],[y1,y1+y2],'purple')

plot([x2,x1+x2],[y2,y1+y2],'blue')



str1="area = {0:.6f}".format(area)

text(minx-1,maxy+4.5,str1)



str2="perim = {0:.6f}".format(perim)

text((minx+maxx)/2,maxy+4.5,str2)



show()



Notes:

1. I use eval(input( “prompt” )) and importing the Math module to allow for expressions to be entered, such as expressions involving pi (π). If I use float(input( “prompt” )) instead, only numbers would be allowed.

2. For the purposes of display, the results are rounded off to six decimal places ({0:.6f}) and displayed in a line. The full precision results of area and perimeter are stored in the variables area and perim, respectively.



Examples



Example 1: [2, 4], [5, 2]



Example 2: [-3, 1], [5, 3]



Example 3: [-6, 0], [0, -4]



Source

Margalit, Dan and Joseph Rabinoff. 2025. “Determinants and Volumes” Interactive Linear Algebra LibreTexts. Accessed February 8, 2026. https://math.libretexts.org/Bookshelves/Linear_Algebra/Interactive_Linear_Algebra_(Margalit_and_Rabinoff)/04%3A_Determinants/4.03%3A_Determinants_and_Volumes



Eddie


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

TI-55 (1977) Programs: Illumination, Wind Turbine, Mile/Kilometer Conversion, 2D Vectors

TI-55 (1977) Programs: Wind Turbine, Mile/Kilometer Conversion, 2D Vectors


Time for the classic TI-55 calculator from the 1970s. My spotlight on this calculator from November 2024: https://edspi31415.blogspot.com/2024/11/spotlight-ti-55-from-1977.html


TI-55: Power Generated by a Wind Turbine


The power generated by a wind turbine can be calculated by:


P = (π * r²) / 2 * ρ * v³ = area / 2 * ρ * v³


P = power generated by the wind turbine (W, Watts)

r = length of an arm of the turbine (radius) (m)

ρ = density of air (kg/m³). Typically, ρ = 1.225 kg/m³

v = velocity of the air (m/s)


Inputs before running the program:

r STO 1, R1 = r

v STO 2, R2 = v

ρ STO 3, R3 = ρ


Note: This formula and program does not take efficiency factors into account. The theoretical maximum power is calculated.


Code:


Step

Key Code

Key


Step

Key Code

Key

00

49

π


10

02

2

01

55

×


11

35

y^x

02

61

RCL


12

03

3

03

01

1


13

45

÷

04

32


14

02

2

05

55

×


15

85

=

06

61

RCL


16

86

R/S

07

03

3


17

87

Rst

08

55

×





09

61

RCL






Examples:


r → R1

v → R2

ρ → R3

Result (P):

5

7

1.225

16500.234

6.1

13.3

1.225

168449.82

4

10

1

25132.741


Sources:


Sharp Electronics Corporation Conquering The Sciences: Applications for the SHARP Scientific Calculator EL-506A Sharp Corporation. Osaka, Japan. 1986. pp.75-77


Wind Turbine Calculator – Calculating Wind Turbine Power Output” CTRLCalculator.com 2024. Retrieved December 5, 2024. https://ctrlcalculator.com/ecology/wind-turbine-calculator/





TI-55: Miles/Kilometers Conversions


This program uses the in⋅mm conversion function. The results are stored as follows:


R1: x mi to km (first result)

R2: x km to mi (second result)


1 km ≈ 0.6213712 mi

1 mi ≈ 1.609344 km


Code:


Step

Key Code

Key


Step

Key Code

Key

00

51

STO


14

76

Prod

01

01

1


15

01

1

02

51

STO


16

21

INV

03

02

2


17

76

Prod

04

06

6


18

02

2

05

03

3


19

61

RCL

06

03

3


20

01

1

07

06

6


21

86

R/S

08

00

0


22

61

RCL

09

67

in⋅cm


23

02

2

10

45

÷


24

86

R/S

11

06

6


25

87

Rst

12

29

10^x





13

85

=






Examples:


X

R1: X mi → km

R2: X km → in

55

88.51392

34.17542

103

165.7624

64.00123

24.75

39.831264

15.378937



TI-55: 2D Vectors: Norm and Dot Product


Let there be two vectors defined as: [R1, R2] and [R3, R4].


Norms:

| [ R1, R2] | = √(R1² + R2²): stored in R5

| [ R3, R4] | = √(R3² + R4²): stored in R6


Dot Product:

[ R1, R2 ] ⋅ [ R3, R4 ] = R1 * R3 + R2 * R4


This program takes all 32 steps available on the TI-55. When this program terminates, the number in the display flashes. In order to use the number, press [ CE ].


For example, to calculate the angle between vectors, use the following keystrokes:

[CE] (to make the number stop flashing) [ ÷ ] [ ( ] [ RCL ] 5 [ × ] [ RCL ] 6 [ ) ] [ = ] [ INV ] [ cos ]


Code:


Step

Key Code

Key


Step

Key Code

Key

00

61

RCL


16

36

P→ R

01

01

1


17

31

x<>y

02

31

x<>y


18

51

STO

03

61

RCL


19

06

6

04

02

2


20

61

RCL

05

21

INV


21

01

1

06

36

P→ R


22

55

×

07

31

x<>y


23

61

RCL

08

51

STO


24

03

3

09

05

5


25

75

+

10

61

RCL


26

61

RCL

11

03

3


27

02

2

12

31

x<>y


28

55

×

13

61

RCL


29

61

RCL

14

04

4


30

04

4

15

21

INV


31

85

=



Example:


[ R1, R2 ] = [ 19, -38 ]

[ R3, R4 ] = [ 32, 64 ]


19 STO 1

38 +/- STO 2

32 STO 3

64 STO 4

R/S


Results:


Norms:

| [ R1, R2] | = R5 = 42.485292

| [ R3, R4] | = R6 = 71.554175


Dot Product: -1284


Find out the angle between the vectors: [19, -38] and [ 32, 64]

After the program is ran:

[CE] (to make the number stop flashing) [ ÷ ] [ ( ] [ RCL ] 5 [ × ] [ RCL ] 6 [ ) ] [ = ] [ INV ] [ cos ]

Angle: 126.8699°


Enjoy!


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.

First Look: HP 16C Collector's Edition

 First Look: HP 16C Collector's Edition I just got the HP 16C Collector's Edition.   This is the famous HP 16C that specializes in c...