Sunday, July 13, 2025

fx-3900PV Programs: Finance Factors

fx-3900PV Programs: Finance Factors


I’m revisiting the fx-3900Pv, which seems to be a hit. The last set of programs from May 3 of this year: https://edspi31415.blogspot.com/2025/05/casio-fx-3900pv-linear-system-poisson.html


Remember: When using the ENT (enter/input) command, we must enter a valid number and then the next step. The number that precedes ENT is not counted as a step and is not recorded.


Example: x + 9


In LRN (learn) mode (Mode EXP):

ENT (enter any number)

+

9

=


Casio fx-3900Pv: Simple Interest


maturity amount = principal amount * (1 + 0.01 * I%) * N ÷ 360

interest accrued = maturity amount – principal amount


I% = annual interest rate

N = number of days


The Act/360 method is used.


Code (23 steps):

ENT # enter principal amount (PV)

Kin 1

×

(

1

+

.

0

1

×

ENT # enter interest rate

×

ENT # enter number of days

÷

3

6

0

)

=

HLT # pause, display maturity amount

-

Kout 1

= # display interest accrued, end program


Example 1:


Inputs:

Principal Amount: 1,000.00

Rate: 5%

Number of Days: 30


Output (rounded to 2 decimal places)

Maturity Amount: 1,004.17

Interest Accrued: 4.17


Example 2:


Inputs:

Principal Amount: 360.00

Rate: 8%

Number of Days: 90


Output (rounded to 2 decimal places)

Maturity Amount: 367.20

Interest Accrued: 7.20



Casio fx-3900Pv: Compound Interest Factor with Compounding Periods


The following program calculates the compound interest factor:


factor = (1 + I% ÷ PYR) ^ (YRS × PVR)


where

I% = annual interest rate

PYR = payments per year (compounding periods)

YRS = number of years (N)


The factor is used in simple compound interest problems:


FV = PV × factor


where:

FV = future value

PV = present value


Code (19 steps):

(

1

+

.

0

1

×

ENT # enter interest rate

÷

ENT # enter payments per year

Kin 1

)

x^y

(

ENT # enter number of years

×

Kout 1

)

=


Example:

Find the compound interest interest factor for: I% = 5%, 12 payments a year, 4 years


Factor: 1.220895351


If an investor expects a $5,000.00 payoff, what should the investor pay?

PV = FV ÷ X

Keys: (with the answer from program displayed: [ 1/x ] [ × ] 5000 [ = ])

PV (rounded): 4,0953.36



Casio fx-3900Pv: Loan Annuity Factor


The following program calculates the loan annuity factor:


factor = ( ( 1 - ( 1 + I% ÷ PYR ) ^ (-YRS × PYR) ) ÷ ( I% ÷ PYR )


where

I% = annual interest rate

PYR = payments per year (compounding periods)

YRS = number of years (N)


The factor is used in loan problems without balloon payments, and assume that the payments occur at the end of each period (ordinary annuity):


PV = PMT × factor


where:

PV = present value

PMT = periodical payments


Code (30 steps):

ENT # enter interest rate

÷

ENT # enter payments per year

Kin 2

×

.

0

1

=

Kin 1 # K1 = I% ÷ PYR

ENT # enter number of years

×

Kout 2

=

Kin 2 # K2 = YRS × PYR = N

(

1

-

(

1

+

Kout 1

)

x^y

Kout 2

+/-

)

÷

Kout 1

=


Example:

A student buys a car at $35,619 (after taxes and fees). The student gets a six year loan at 5.7% and pays at the end of each month. What is the payment?


PMT = PV ÷ factor

where PV = 35619, I% = 5.7, PYR = 12 (monthly payments), YRS = 6


Running the program with inputs 5.7, 12, 6: 60.85819003

Payment: [ 1/x ] [ × ] 35619 [ = ]: 585.28 (rounded)



Casio fx-3900Pv: Sinking Fund Factor (Savings Account)


The following program calculates the sinking factor (used for savings accounts):


factor = ( (1 + I% ÷ PYR) ^ (YRS × PYR) – 1 ) ÷ (I% ÷ PYR)


The factor is used in determining the future value of savings plans with regular deposits made at the end of each period:


FV = PMT × factor


Code (29 steps):

ENT # enter interest rate

÷

ENT # enter payments per year

Kin 2

×

.

0

1

=

Kin 1 # K1 = I% ÷ PYR

ENT # enter the number years

×

Kout 2

=

Kin 2 # K2 = YRS × PYR

(

(

1

+

Kout 1

)

x^y

Kout 2

-

1

)

÷

Kout 1

=


Example:


A child’s parents opens up an account on the child’s first birthday. The parents contribute $200.00 per month for the next 18 years. The account pays a fixed rate of 3% per month. What is the value of the fund when the child turns 18?


Note: The account is opened on the child’s first birthday, hence 17 years pass.


FV = PMT × factor

where PMT = 100, I% = 3, PYR = 12, YRS = 17


Running the program with inputs 3, 12, 17: 265.69267

Future Value: [ × ] 200 [ = ]: 53,138.54 (rounded)



Until next time, stay safe and sane,


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.


The content on this blog is 100% generated by humans. The author does not use AI engines and never will.



Saturday, July 12, 2025

RPN: HP 32S/DM32: Simple Harmonic Motion

RPN: HP 32S/DM32: Simple Harmonic Motion


Introduction


The simple harmonic motion (SHM) of a spring can be described by Hooke’s Law:


F = -K * x(t)


x(t) = position of the spring

F = force of the spring


Note that: F = mass * acceleration = M * x’’(t)

Then:


M * x’’(t) = - K * x(t)

M * x’’(t) + K * x(t) = 0

x’’(t) + (K / M) * x(t) = 0


Without going into much details, two general solutions can have the form:


Case I:

x(t) = A * sin(W * t + B) with W = √(K / M) (A, B are constants)


and


Case II:

x(t) = A * cos(W*T + D) with W = √(K / M) (A, D are constants)


Believe it or not, both solutions work.


Case I:

x(t) = A * sin(W * t + B)

x’(t) = A * W * cos(W * t + B)

x’’(t) = -A * W^2 * sin(W * t + B)


Observe:

x’’(t) = -A * W^2 * sin(W * t + B)

x’’(t) = -W^2 * (A * sin(W * t + B))

x’’(t) = -W^2 * x(t)


W = √(K / M), W^2 = K / M


x’’(t) = -(K / M) * x(t)

M * x’’(t) = -K * x(t)

We are back to Hooke’s Law.


Case II:

x(t) = A * cos(W * t + D)

x’(t) = -A * W * sin(W * t + D)

x’’(t) = -A * W^2 * cos(W * t + D)


Then:

x’’(t) = -W^2 * (A * cos(W * t + D))

x’’(t) = -W^2 * x(t)

x’’(t) = -(K / M) * x(t)

M * x’’(t) = -K * x(t)

We once again arrive at Hooke’s Law. Another valid solution.


These two solutions are chosen for simplicity. A general solution would take the form of:

x(t) = A2 * cos(W * t + D) + A2 * sin(W * t + B)



Determining the Constants


Let:

x0 = initial position, at t = 0

v0 = initial velocity, at t = 0


Let’s use the simplified solutions.


Case I: Sine Approach


x(t) = A * sin(W * t + B)

x’(t) = A * W * cos(W * t + B)


x0 = A * sin(B)

v0 = A * W * cos(B)


x0 = A * sin(B)

v0 / W = A * cos(B)


Square each equation and add:

x0^2 + (v0 / W)^2 = A^2 * ((sin B)^2 + (cos B)^2)

x0^2 + (v0 / W)^2 = A^2 * 1

( x0^2 + (v0 / W)^2 ) = A

A = √( x0^2 + (v0 / W)^2 )


Divide the top equation by the bottom equation:

x0 / (v0 / W) = tan(B) (assume A ≠ 0)

B = arctan( x0 / (v0 / W) )

atan2( x0, (v0 / W)) = arg( (v0 / W) + x0*i ) where i = √-1


Case II: Cosine Approach


x(t) = A * cos(W * t + D)

x’(t) = -A * W * sin(W * t + D)


x0 = A * cos(D)

v0 = -A * W * sin(D)


x0 = A * cos(D)

v0 / W = -A * sin(D)


Square each equation and add:

x0^2 + (v0 / W)^2 = (A * cos(D))^2 + (-A * sin(D))^2

x0^2 + (v0 / W)^2 = A^2 * cos(D)^2 + (-A) *(-A) * sin(D)^2

x0^2 + (v0 / W)^2 = A^2 * cos(D)^2 + A^2 * sin(D)^2

x0^2 + (v0 / W)^2 = A^2 * 1

( x0^2 + (v0 / W)^2 ) = A

A = √( x0^2 + (v0 / W)^2 )


Divide the top equation by the bottom equation:

x0 / (v0 / W) = -cot(D) (assume A ≠ 0)

(v0 / W) / x0 = -tan(D)

-(v0 / W) / x0 = tan(D)

D = arctan(-(v0 / W) / x0)

atan2( -(v0 / W), x0) = arg( x0 - (v0 / W)*i)


The atan2, arg, and similarly, the rectangular to polar conversion functions are used to allow for all angles, including angles in the form of π/2 + n*π.


The following code demonstrates the two basic approaches, using the classic HP 32 (and which can be used on HP 32SII, DM32, HP 33S).



HP 32S Code


The variables:


X = (initial) position of the spring. When the spring is at it’s natural or neutral position, X = 0. (SI: unit m)

V = (initial) velocity of the spring. If V<0, the spring is getting shorter. If V>0, the spring is getting longer.

M = mass of the object attached to the end of the string (SI: unit kg)

K = spring’s force constant (N/m, kg/s^2)

A = amplitude of the spring (m)


Labels:

LBL I: Initialization, calculate W = √(K / M), and A = √(X^2 + V^2/W^2)

(HP 32S Memory: I: 34.5 bytes)


I01 LBL I

I02 INPUT K

I03 INPUT M

I04 INPUT X

I05 INPUT V

I06 RAD

I07 RCL K

I08 RCL÷ M

I09 SQRT

I10 STO W

I11 VIEW W

I12 RCL X

I13 x^2

I14 RCL V

I15 x^2

I16 RCL W

I17 x^2

I18 ÷

I19 +

I20 SQRT

I21 STO A

I22 VIEW A

I23 RTN


Sine Approach: x(t) = A * sin(W*T + B); W = √(K / M)

LBL S: Calculate B, then calculates X from time = 0 seconds to T seconds (per second)

(HP 32S Memory: S: 21.0 bytes, U: 16.5 bytes)


S01 LBL S

S02 RCL X

S03 RCL V

S04 RCL W

S05 ÷

S06 y,x→Θ,r

S07 x<>y

S08 STO B

S09 VIEW B

S10 INPUT T

S11 3

S12 10^x

S13 ÷

S14 STO T

U01 LBL U

U02 RCL T

U03 IP

U04 RCL× W

U05 RCL+ B

U06 SIN

U07 RCL× A

U08 STOP

U09 ISG T

U10 GTO U

U11 RTN



Cosine Approach: x(t) = A * cos(W*T + D); W = √(K / M)

LBL C: Calculate D

LBL D: Calculate X from time = 0 seconds to T seconds (per second)

(HP 32S Memory: C: 22.5 bytes, U: 16.5 bytes)


C01 LBL C

C02 RCL V

C03 RCL W

C04 ÷

C05 +/-

C06 RCL X

C07 y,x→Θ,r

C08 x<>y

C09 STO D

C10 VIEW D

C11 INPUT T

C12 3

C13 10^x

C14 ÷

C15 STO T

E01 LBL E

E02 RCL T

E03 IP

E04 RCL× W

E05 RCL+ D

E06 COS

E07 RCL× A

E08 STOP

E09 ISG T

E10 GTO E

E11 RTN


Examples


The calculator is set to FIX 5 mode.


Example 1:

K = 40, M = 1.33, V = 0, X = 0.3. Up to 5 seconds


Results:

W = 5.48408, A = 0.30000



Sine Approach (LBL S)

Cosine Approach (LBL C)

Time (seconds)

B = 1.57080 (Ï€/2)

D = 0

0

0.30000

0.30000

1

0.20921

0.20921

2

-0.00822

-0.00822

3

-0.22067

-0.22067

4

-0.29955

-0.29955

5

-0.19711

-0.19711



Example 2:

K = 48, M = 3, V = 0, X = -0.5. Up to 5 seconds


Results:

W = 4.00000, A = 0.50000



Sine Approach (LBL S)

Cosine Approach (LBL C)

Time (seconds)

B = -1.57080 (-Ï€/2)

D = 3.14159 (Ï€)

0

-0.50000

-0.50000

1

0.32682

0.32682

2

0.07275

0.07275

3

-0.42193

-0.42193

4

0.47883

0.47883

5

-0.20404

-0.20404



Sources


“Simple Harmonic Motion” Hyperphysics. http://hyperphysics.phy-astr.gsu.edu/hbase/shm.html Retrieved February 7, 2025.


LibreTexts Physics. “15.2: Simple Harmonic Motion” https://phys.libretexts.org/Bookshelves/University_Physics/University_Physics_(OpenStax)/Book%3A_University_Physics_I_-_Mechanics_Sound_Oscillations_and_Waves_(OpenStax)/15%3A_Oscillations/15.02%3A_Simple_Harmonic_Motion Retrieved February 6, 2025.


Rodicek, Danny. Mathematics & Physics for Programmers Hingham, MA. 2005. ISBN 1-58450-330-0


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.  

The content on this blog is 100% generated by humans. The author does not use AI engines and never will.


fx-3900PV Programs: Finance Factors

fx-3900PV Programs: Finance Factors I’m r evisiting the fx-3900Pv, which seems to be a hit. The last set of programs from May 3 of thi...