Showing posts with label position. Show all posts
Showing posts with label position. Show all posts

Saturday, October 26, 2024

TI 30Xa Algorithm: Acceleration, Velocity, Speed

TI 30Xa Algorithm: Acceleration, Velocity, Speed


Introduction and Algorithm


Given the acceleration (α), initial velocity (v0), and initial position (p0) of an object on a 2D plane, calculate velocity and position at time T.


Assuming that acceleration is constant, the equations are:


Acceleration: A = α

Velocity: V = α * t + v0

Position: P = α / 2 * t^2 + v0 * t + p0



With some simplification, we can simplify the work flow:


( I )

A = α


( II )

V = α * t + v0

V = A * t + v0 (II)


( III )

P = α / 2 * t^2 + v0 * t + p0

P = t * ( α / 2 * t + v0 ) + p0

P = t * ( α / 2 * t + 2 * v0 / 2 ) + p0

P = t * ( (α * t + 2 * v0) / 2 ) + p0

P = t / 2 * ( α * t + 2 * v0 ) + p0

P = t / 2 * ( α * t + v0 + v0 ) + p0

P = t * (V + v0) / 2 + p0


( I ): A = α

( II ): V = A * t + v0

( III ): P = t * (V + v0) / 2 + p0


Key Strokes:


1. Store the time T in Memory 1 ( T [ STO ] 1 )

2. Store the initial velocity in Memory 2 ( v0 [ STO ] 2 )

3. Enter the acceleration constant, α, press [ = ]

4. Calculate the velocity at time T: [ × ] [ RCL ] 1 [ + ] [ RCL ] 2 [ = ]

5. Calculate the position at time T: [ + ] [ RCL ] 2 [ = ] [ × ] [ RCL ] 1 [ ÷ ] 2 [ + ] p0 [ = ]



Examples


Example 1:


α = 1.3

v0 = 0

p0 = 0

T = 10


1. 10 [ STO ] 1

2. 0 [ STO ] 2

3. Acceleration: 1.3 [ = ]

4. Velocity: [ × ] [ RCL ] 1 [ + ] [ RCL ] 2 [ = ] (Result: 13)

5. Position: [ + ] [ RCL ] 2 [ = ] [ × ] [ RCL ] 1 [ ÷ ] 2 [ + ] 0 [ = ] (Result: 65)



Example 2:


α = -9.80665

v0 = 0

p0 = 10000

T = 30


1. 30 [ STO ] 1

2. 0 [ STO ] 2

3. Acceleration: 9.80665 [ +/- ] [ = ]

4. Velocity: [ × ] [ RCL ] 1 [ + ] [ RCL ] 2 [ = ] (Result: -294.1995)

5. Position: [ + ] [ RCL ] 2 [ = ] [ × ] [ RCL ] 1 [ ÷ ] 2 [ + ] 10000 [ = ] (Result: 5587.0075)


Example 3:


α = -0.05

v0 = 10

p0 = 20

T = 15


1. 15 [ STO ] 1

2. 10 [ STO ] 2

3. Acceleration: 0.05 [ +/- ] [ = ]

4. Velocity: [ × ] [ RCL ] 1 [ + ] [ RCL ] 2 [ = ] (Result: 9.25)

5. Position: [ + ] [ RCL ] 2 [ = ] [ × ] [ RCL ] 1 [ ÷ ] 2 [ + ] 20 [ = ] (Result: 164.375)


Example 4:


α = 4.26

v0 = 1.8

p0 = 0

T = 5


1. 5 [ STO ] 1

2. 1.8 [ STO ] 2

3. Acceleration: 4.26 [ = ]

4. Velocity: [ × ] [ RCL ] 1 [ + ] [ RCL ] 2 [ = ] (Result: 23.1)

5. Position: [ + ] [ RCL ] 2 [ = ] [ × ] [ RCL ] 1 [ ÷ ] 2 [ + ] 0 [ = ] (Result: 62.25)


Hope you find this useful.


Happy Halloween, Everyone!


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.

Thursday, February 22, 2018

HP Prime and Casio fx-5800P: The Two Train Problem (updated 2/26/2018)

HP Prime and Casio fx-5800P:  The Two Train Problem
(updated 2/28/2018)

Introduction

Have you ever heard the infamous problem “two trains are heading towards each other…”? 

Today’s blog will cover the following question:

Two trains are heading towards each other, on their own separate train track.  Each train has going at their own speed (velocity).  The trains start out a distance apart.

1. When will the trains cross over the same spot, and


2. Where will the trains cross over the same spot?




According to the diagram above, we have two trains, labeled Train I and Train II, each going at velocity v and acceleration a.  The trains start at distance D apart.  We will call the point where the trains cross over the same spot, x. 

Notes:

1. To make our lives easier, let’s assume that Train I starts at position 0, while Train II starts at position D. 

2. Train I is going at velocity v and acceleration a. 

3. Train II is going at velocity –v and acceleration –a. Why negative?  Train II is traveling in the opposite direction of Train I.

Setting up the Equations

The general distance equation is:  x = x0 + v*t + a*t^2, where x0 is the initial position.

We are going to cover two scenarios:  one where there is no acceleration, that is the velocity of both trains is constant.  The other is where acceleration is present for at least one of the trains.  Acceleration is assumed to be constant. 

In general the distance equations for both trains are:

Train I:  x =        v1*t + 1/2*a1*t^2
Train II: x = D  - v2*t -  1/2*a2*t^2

What this boils down to are a system of two equations, solving for both t and x.

Case 1:  Constant Velocity

The trains are moving at constant velocity in this scenario.  Which means there is no acceleration, and hence a1 = 0 and a2 = 0.  Then:

Train I:  x =        v1*t
Train II: x = D -  v2*t

Subtracting equations gives us:

0 = -D + v1*t – -v2*t
0 = -D + (v1 + v2)*t
D = (v1 + v2)*t
t = D/(v1 + v2)

Once t is known, we can use substitution to find x.  Train I’s equation is simpler, so:

x = v1*t

Case 2:  Non-Zero Acceleration

Start with:

Train I:  x =        v1*t + 1/2*a1*t^2
Train II: x = D  - v2*t -  1/2*a2*t^2

Subtracting the equations and solving for t yields:

0 = -D + v1*t – -v2*t + 1/2*a1*t^2 - -1/2*a2*t^2
0 = -D + (v1 + v2)*t + 1/2*(a1 + a2)*t^2

Using the quadratic equation:

t = ( -(v1+v2) ± √( (v1+v2)^2 + 4*D*1/2*(a1+a2)) ) / (2*1/2*(a1 + a2))
t = ( -(v1+v2) ± √( (v1+v2)^2 + 2*D*(a1+a2)) ) / (a1 + a2)


Note that there are two roots for t.  However, given the problem, negative time does not make sense.  We can eliminate the root for t that is obviously negative.

Hence, our solution for time in this problem is:

t = ( -(v1+v2) + √( (v1+v2)^2 + 2*D*(a1+a2)) ) / (a1 + a2)

Again, we are going to use the simpler equation for Train I to figure x:

x = v1*t + a1*t^2

The Program TRAINS

The program TRAINS will solve this problem.  Below are the codes for both the HP Prime and Casio fx-5800p.  Enter each as a positive value as the directions are accounted for in the program.

In the program, Train I is considered the left train, while Train II is considered the right train.

HP Prime Program: TRAINS

EXPORT TRAINS()
BEGIN
// 2018-02-22 EWS
// 2 trains problem

LOCAL d,t,x;
LOCAL v1,a1,v2,a2;

INPUT({d,v1,a1,v2,a2},
"Two Opposing Trains",
{"Dist:","L Vel:","L Acc:",
"R Vel:","R Acc:"},
{"Distance between trains",
"Left Train: Velocity",
"Left Train: Acceleration",
"Right Train: Velocity",
"Right Train: Acceleration"});

// calculation
IF a1≠0 OR a2≠0 THEN
t:=(−(v1+v2)+√((v1+v2)^2+
2*d*(a1+a2)))/(a1+a2);
x:=v1*t+1/2*a1*t^2;
ELSE
t:=d/(v1+v2);
x:=v1*t;
END;

// results
RETURN {"Time",t,
"Position",x};


END;

Casio fx-5800P Program: TRAINS

“EWS 2018-02-22”
“DISTANCE”?→D
“LEFT-VEL.”?→A
“LEFT-ACC.”?→E
“RIGHT-VEL.”?→B
“RIGHT-ACC.”?→F
If E≠0 Or F≠0
Then
(-(A+B)+√((A+B)^2
+2*D*(E+F)))÷
(E+F)→T
A*T+1/2*E*T^2→X
Else
D÷(A+B)→T
A*T→X
IfEnd
“TIME:”
T
“POSITION:”
X

Examples

Assume compatible units for each example.

Example 1:  Constant Velocity
Train I:  v1 = 40 (a1 = 0)
Train II: v2 = 35 (a2 = 0)
Distance:  300

Results:
Time:  4
Position:  160

Example 2:  Acceleration
Train I:  v1 = 40, a1 = 0.5
Train II: v2 = 35, a2 = 0.8
Distance:  300

Results:
Time:  3.87018761454
Position:  158.552092625

Thank you to Gianfranco Cazzaro, Dieter, and all who wrote to me pointing out the errors.  

Eddie

This is blog is property of Edward Shore, 2018.


Saturday, June 14, 2014

HP Prime: Equations of Motion Under Constant Power


Introduction
 
When considering the motions of automobiles, the calculating acceleration, velocity, and distance can be increased if the power output of the vehicle and the vehicle’s mass are considered. 

It is necessary to go beyond the simple equations of motion when considering vehicles.  For reference, I list the simple of equations of motion here:

v = a*t + v0

x = a*t^2/2 + v0*t + x0

where a is acceleration, v is velocity, and x is position.  v0 and x0 are initial velocity and initial position, respectively.  Acceleration is assumed to be constant.

Considering Power

In the paper “Constant powers equation of motion”, Roger Stephenson (see Sources below) explained that the automobile’s engine can produce constant torque at a certain RPM (revolutions per minute).  However, for the car to accelerate requires either the engine’s rpm or gear ratio linking the engine to the wheels must change.  Drivers aim to change gears to engine rpm at a level where the most power is produced.  This causes torque at the wheels to change.  However, power is kept at a constant level and can be used to modify the equations of motion.

Let P be the power of the vehicle and m it’s mass.  The kinetic energy of the automobile at t=0 is:

KE = ½ * m * v^2 = P * t

Solving for velocity, we get

‘v = √(2*P*t/m)

Stephenson introduced the variable Z, zip, defined as:

Z = √(P/m)

Z nicely combines the vehicle’s constant power and mass.  Deriving the equations of motion started with the recognition of relationship between work and power:

Power = Work / Time

Since Work = Force * Displacement and by Newton’s Second Law, Force = Mass * Acceleration, we arrive at:

P = W /t

P  = m * a * x/t

P/m = a * x/t

Since Z = √(P/m) and v = x/t, and recognizing that a = dv/dt,

Z^2 = dv/dt * v

From there, Stephenson derived the following equations of motion under constant motion in Appendix A in his paper:

 a = Z * (2*t + (v0/Z)^2) ^ (-1/2)

v = Z * (2*t + (v0/Z)^2) ^ (1/2)

x = (Z/3) * ( (2*t + (v0/Z)^2) ^ (3/2) – (v0/Z)^3) ) + x0

Where Z = √(P/m)

Using standard US units, power is stated in ft*lb/s and mass is stated in slugs.   The following conversion factors may be necessary:

1 hp (horsepower) = 550 ft*lb/s

1 slug = 32.17404 lbs (mass * gravity)

1 mph = 22/15 ft/s

1 ft/s = 15/22 mph

The Program CARFORCE

The following HP Prime program, CARFORCE, takes the following for arguments: 

P = power in horsepower (hp)

M = mass in pounds (lb)

I = initial velocity (mph)

T = time to evaluate (seconds)

CARFORCE will return a list of four answers:

Zip (numerical value only (ft/s^1.5))

Acceleration in miles per hour per second

Velocity in miles per hour

Position in feet


This program illustrates the use of units in an HP Prime program.  A way to separate a value from a value_unit couple is to divide such value by 1_unit.  Example:

15_ft / 1_ft = 15

The program listed is shown below.  The program assumes that x0 = 0. 

EXPORT CARPOWER(P,M,I,T)

BEGIN

// 2014-06-14 EWS

// Roger Stevenson, 1980

// Lloyd W. Taylor, 1930

// power (hp),mass (lb),

// initial velocity (mph), time (sec)

LOCAL Z,W,A,V,X,L0;

// convert

P:=CONVERT(P*1_hp,1_(ft*lbf/s))/1_(ft*lbf/s);

I:=CONVERT(I*1_mph,1_(ft/s))/(1_(ft/s));

M:=CONVERT(M*1_lb,1_(slug))/(1_slug);

Z:=√(P/M);

// temp

W:=2*T+I²/Z²;

A:=Z/√W;

V:=Z*√W;

X:=Z/3*(W^1.5-(I/Z)^3);

L0:={Z,A*15/22,V*15/22,X};

L0:=L0*{1,1_(mile/(h*s)),1_(mile/h),1_ft};

 

RETURN L0;

 

END;

 Update:  If you have trouble running the program, here is an alternative program which uses numeric conversions instead of the CONVERT function.

EXPORT CARPOWER(P,M,I,T)
BEGIN
// 2014-07-25 EWS

// Roger Stevenson, 1980
// Lloyd W. Taylor, 1930
// power (hp),mass (lb),
// initial velocity (mph), time (sec)
LOCAL Z,W,A,V,X,L0;
// convert
. use decimal conversions

P:=550*P; // hp to ft*lbf*s^-1
I:=22/15*I; // mph to ft/s
M:=M/32.1740485564;

Z:=√(P/M);
// temp
W:=2*T+I²/Z²;
A:=Z/√W;
V:=Z*√W;
X:=Z/3*(W^1.5-(I/Z)^3);
L0:={Z,A*15/22,V*15/22,X};

RETURN L0;
END;

Example:

Data:  Vehicle has a 100 hp engine, has a mass of 4,000 pounds.  Figure the equations of motion after 10 seconds elapsed.  Assume the vehicle is initially stopped.

CARPOWER(100, 4000, 0, 10) returns

{21.0331445022, 3.2066959696_mile/(h*s), 64.1339193918_mile/h, 627.087211833_ft}

Sources
Lloyd, Taylor W. “The Laws of Motion Under Constant Power”  The Ohio Journal of Science, v30 n4 (July, 1930), 218-220.  https://kb.osu.edu/dspace/bitstream/1811/2458/1/V30N04_218.pdf

Revised 6/12/2014
 
Stephenson, Roger  “Constant power equations of motion”  (Published January 29, 1982) from the compilation book The Physics of Sports edited by Angelo Armenti, Jr.  American Institute of Physics: New York  1992, pp. 284-289
   

Considering power, calculating acceleration, velocity, and position become more accurate.
 
Until next time, have a great day!  Happy Birthday Mom and Dad!  Happy Father’s Day!


Eddie

Earth's Radius by Latitude

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