Location of the center of mass of a region
Description
Published by Marcel Pelletier, June 2023, in the MoHPC - General Software Library
This document shows how to use the integral function ∫yx, in a program, to calculate the location of the center of mass of a region.
Center of Mass
Program C uses registers .0 , .1 and .2 . The user-defined functions, label A and label B, can be add at the end of the program memory.
The center of mass of a region (the centroid) is located at point (x, y), where
b b b
x = 1/A ∫ x f(x) dx y = 1/A ∫ 1/2 (f(x))² dx A = ∫ f(x) dx
a a a
If the region lies between two curves y=f(x)
and y=g(x)
, where f(x)≥g(x)
then,
b b b
x = 1/A ∫ x [f(x) - g(x)] dx y = 1/A ∫ 1/2 [(f(x))² - (g(x))²] dx A = ∫ [f(x) - g(x)] dx
a a a
Examples
Example 1
Find the centroid of the region bounced by the curves y=cos x, y=0, x=0∧x=π/2
.
In PRGM mode:
Delete any existing program at label A.
f LBL A
COS
g RTN
In RUN mode:
g RAD
0 ENTER → 0.000
g π 2 ÷ → 1.5708
f C → 0.5708
x↔y → 0.3927
The centroid is located at the point (π/2-1, π/8).
Example 2
Find the centroid of the region bounded by the line y=x
and the parabola y=x²
. The curves intersect at the point (0, 0) and (1, 1) → a=0 and b=1.
In PRGM mode:
Delete any existing program at label A.
f LBL A
g x²
g RTN
f LBL B
g x²
g RTN
In RUN mode:
g SF 1 (This the second case!)
0 ENTER
1 f C → 0.5000
x↔y → 0.4000
The centroid is located at the point (1/2, ²/5) or (0.5, 0.4).
Program Resources
Labels
Name |
Description |
|
Name |
Description |
|
A |
User-defined function A |
|
.3 |
|
|
B |
User-defined function B |
|
.4 |
|
|
C |
Center of Mass |
|
.5 |
|
|
.1 |
|
|
.6 |
|
|
.2 |
|
|
|
|
|
Storage Registers
Name |
Description |
|
.0 |
|
|
.1 |
|
|
.2 |
|
|
Flags
Program
Line |
Display |
Key Sequence |
|
Line |
Display |
Key Sequence |
|
Line |
Display |
Key Sequence |
|
000 |
|
|
|
019 |
32 .2 |
GSB . 2 |
|
038 |
32 12 |
GSB B |
|
001 |
42,21,13 |
f LBL C |
|
020 |
45,20, .0 |
RCL × . 0 |
|
039 |
43 11 |
g x² |
|
002 |
42,20, .5 |
f ∫xy . 5 |
|
021 |
43 32 |
g RTN |
|
040 |
30 |
− |
|
003 |
44 .1 |
STO . 1 |
|
022 |
42,21, .2 |
f LBL . 2 |
|
041 |
43 32 |
g RTN |
|
004 |
33 |
R⬇ |
|
023 |
45 .0 |
RCL . 0 |
|
042 |
42,21, .5 |
f LBL . 5 |
|
005 |
33 |
R⬇ |
|
024 |
32 12 |
GSB B |
|
043 |
44 .0 |
STO . 0 |
|
006 |
42,20, .1 |
f ∫xy . 1 |
|
025 |
30 |
− |
|
044 |
32 11 |
GSB A |
|
007 |
44 .2 |
STO . 2 |
|
026 |
43 32 |
g RTN |
|
045 |
43, 6, 1 |
g F? 1 |
|
008 |
33 |
R⬇ |
|
027 |
42,21, .3 |
f LBL . 3 |
|
046 |
32 .6 |
GSB . 6 |
|
009 |
33 |
R⬇ |
|
028 |
44 .0 |
STO . 0 |
|
047 |
43 32 |
g RTN |
|
010 |
42,20, .3 |
f ∫xy . 3 |
|
029 |
32 11 |
GSB A |
|
048 |
42,21, .6 |
f LBL . 6 |
|
011 |
45,10, .1 |
RCL ÷ . 1 |
|
030 |
43 11 |
g x² |
|
049 |
43 32 |
g RTN |
|
012 |
45 .2 |
RCL . 2 |
|
031 |
43, 6, 1 |
g F? 1 |
|
050 |
32 12 |
GSB B |
|
013 |
45,10, .1 |
RCL ÷ . 1 |
|
032 |
32 .4 |
GSB . 4 |
|
051 |
30 |
− |
|
014 |
43 32 |
g RTN |
|
033 |
2 |
2 |
|
052 |
43 32 |
g RTN |
|
015 |
42,21, .1 |
f LBL . 1 |
|
034 |
10 |
÷ |
|
053 |
42,21,11 |
f LBL A |
|
016 |
44 .0 |
STO . 0 |
|
035 |
43 32 |
g RTN |
|
054 |
24 |
COS |
|
017 |
32 11 |
GSB A |
|
036 |
42,21, .4 |
f LBL . 4 |
|
055 |
43 32 |
g RTN |
|
018 |
43, 6, 1 |
g F? 1 |
|
037 |
45 .0 |
RCL . 0 |
|
|
|
|
|