Showing posts with label HP 17B. Show all posts
Showing posts with label HP 17B. Show all posts

Saturday, October 29, 2022

Plus42 Solver: Derivatives

Plus42 Solver: Derivatives 




Introduction


The Technical Applications book for the HP 27S and HP 19B (and can apply to the HP 17B outside of trigonometry) shows the numerical first and second derivative can be calculated by the formulas:


f ' (x) = (f(x+h) - f(x-h)) / (2 * h)


f ' ' (x) = (f(x + h) - 2 * f(x) + f(x + h)) / h^2 


where h is sufficiently small, like 10^-5 to 10^-12.



Legacy Formulas vs. Plus42 Formulas 


The formulas suggested by the Technical Applications Book are:


First Derivative:



Second Derivative:


Depending on the function FX, this above can turn the above into long equations.  With the ability of user functions, this allows us to use the original definitions.


FX(X): f(x) (insert f(x)


First Derivative:


F'X=(FX(X+H)-FX(X-H))÷(2×H)


Second Derivative:


F''X=(FX(X+H)-2×FX(X)+FX(X-H))÷SQ(H)


SQ:  press by the key sequence [(shift)] (x^2)


':  (ALPHA) [ ↓ ] (PUNC) [ ↓ ] ( ' )


Note:  Radians mode 



Examples 


FIX 5 mode is set.


Example 1:


f(x) = 0.5 * cos(3*x)

x = π/4


FX(X):0.5×COS(3×X)

f'(x) ≈ -1.06066

f''(x) ≈ 3.18198


Example 2:


f(x) = (x^2 + 3*x + 5) / (4*x - 1)

x = 2


FX(X):(X^2+3×X+5)÷(4×X-1)

f'(x) ≈ -0.22449

f''(x) ≈ 0.54227



Functions with Variable Constants


It is easy to expand the user function FX to include variable constants.  For example:


f(x) = -ln(cos(√(a*x)))

Calculate the value and first derivative at x = 0.11 and a = 0.46


Attach variable constants at the end of FX:


FX(X:A):-LN(COS(SQRT(A×X)))

F'X=(FX(X+H:A)-FX(X-H:A))÷(2×H)


f(x:a) ≈ 0.02552

f'(x:a) ≈ 0.23396


The user function makes the calculating numerical derivatives easier.  


Source:


Technical Applications: Step-by-Step Solutions for Your HP-27S or HP-19B Calculator Hewlett Packard.   Edition 2.  Corvallis, OR.   November 1988.  pg. 44


Have any Halloween plans?  Wishing you a great day,


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. 


Sunday, December 5, 2021

HP 17B and HP 27S: Using the Solver for Recursive Functions

HP 17B and HP 27S: Using the Solver for Recursive Functions


Introduction


A simple store and recall procedure can be used with the solver.   


One Initial Condition


u_n = f(u_n-1) with the initial condition u_0


Let B = u_n and A = u_n-1, set up the solver as:


B = F(A)


Initial condition:

u_0 ( A ) ( B )


Subsequent calculations:

[ RCL ] ( B )* [ STO ] ( A ) ( B )


*RCL B is not necessary if you go straight to the next calculation.  


Example:   

u_n = 4*u_n-1 - 3, u_0 = 3


Setup:  B=4×A-3


3 ( A ) ( B )

Result:  9


[ RCL ] ( B) [ STO ] ( A ) ( B )

Result:  33


[ RCL ] ( B) [ STO ] ( A ) ( B )

Result:  129


[ RCL ] ( B) [ STO ] ( A ) ( B )

Result:  513



Two Initial Conditions


u_n = f(u_n-1, u_n-2) with the initial conditions u_0 and u_1


Let C = u_n, B = u_n-1, and A = u_n-2 and set up the solver as:


C = F(A, B)


Initial condition:

u_0 ( A ) u_1 ( B )  ( C )


Subsequent calculations:

[ RCL ] ( B )* [ STO ] ( A ) ( B )


Example:


The Fibonacci Sequence:

u_n = u_n-1 + u_n-2; with u_0 = 1, u_1 = 1


Setup:  C=B+A


1 ( A ) 1 ( B ) ( C )

Result: 2


[ RCL ] ( B ) [ RCL ] ( A ) ( C )

Result:  3



[ RCL ] ( B ) [ RCL ] ( A ) ( C )

Result:  5


[ RCL ] ( B ) [ RCL ] ( A ) ( C )

Result:  8


Nothing to it.


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. 


Saturday, December 4, 2021

HP 17B and HP 27S: Derivatives to the Nth Order (and TI-84 Plus CE Python 5.7 update)

 HP 17B and HP 27S: Derivatives to the Nth Order


With the Solver of the HP 17B family, HP 27S, and the HP 19B calculator, we can calculate derivatives of any order.  Four derivatives are presented here.  You can use any name you want other than those presented here.  Each derivative is to the kth order. 


Derivative 1:   d^k/dx^k a × x^n 


N and K must be positive integers, D is the value of the derivative  


DER1: D=A×X^(N-K)×PERM(N:K)


Example:

Input:  N = 2, K = 1, A = 3, X = 1.5

Result:  D = 9


Derivative 2:   d^k/dx^k e^(a × x) 


K must be a positive integer, D is the value of the derivative


DER2: D=A^K×EXP(A×X)


Example:

Input:  A = 1.8, K =3, X = 3

Result:  D = 213.4409


Derivatives 3 and 4 will require trigonometric functions, which are not available on the HP 17B family.   It is recommended you set the calculator to Radian angle mode.


Derivative 3:  d^k/dx^k sin(a × x)


DER3: D=IF(MOD(K:2)=0:(-1)^(K÷2)×A^K×SIN(A×X):(-1)^((K+3)÷2)×A^K×COS(A×X))


Examples:

Input:  A = 0.75, X = 0.66, K = 2

Result: D = -0.2672


Input:  A = 0.75, X = 0.66, K = 3

Result: D = -0.3712


Derivative 4:  d^k/dx^k cos(a × x)


DER4: D=IF(MOD(K:2)=0:(-1)^(K÷2)×A^K×COS(A×X):(-1)^(K÷2+1÷2)×A^K×SIN(A×X))


Examples:

Input:  A = 0.75, X = 0.66, K = 2

Result: D = -0.4950


Input:  A = 0.75, X = 0.66, K = 3

Result: D = 0.2004


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. 


Thursday, November 25, 2021

HP 17BII+: Update to Normal CDF Formula - Don Phillips

 HP 17BII+:  Update to Normal CDF Formula - Don Phillips


On March 31, 2019, I posted a formula calculate the normal cumulative distributive function (normal CDF) for x ≥ 0:


http://edspi31415.blogspot.com/2019/03/hp-17bii-normal-distribution-and-random.html


Don Phillips provided us with an updated formula to include negative values of x.   Much gratitude for allowing me to post this formula:


NCDF=L(ANS:1-EXP(-ABS(X)^2÷2)÷SQRT(2×PI)×(.4361836×L(T:INV(1+.33267×ABS(X)))-.1201676×G(T)^2+.9372980×G(T)^3))×0+IF(X<0:1-G(ANS):G(ANS))


Example Calculations:

X = -2.50,  NCDF = 0.00622

X = -1.50, NCDF = 0.06680

X = -0.50, NCDF = 0.30855

X = 0.00, NCDF = 0.50000

X = 0.50, NCDF = 0.69145

X = 1.00, NCDF = 0.84135

X = 2.00, NCDF = 0.97724


Thank you Don, 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. 


Monday, October 11, 2021

Comparison Between HP 17B and 17BII+

 Comparison Between HP 17B and 17BII+


This is a quick comparison between the original HP 17B and the current (since 2007) silver HP 17BII+ calculators. I hope the 17BII+ is still being produced and sold, it has been quite a while since an update to the 17BII+.  


The main features of the 17B family have remained constant since the original 17B came to the markets in early 1988:


*  Time Value of Money with Amortization

*  Business Calculations including Percent Change, Cost/Sell/Margin/Markup

*  Four Regression Models:  Linear, Logarithm, Power, Exponential

*  Bond Calculations

*  Depreciation including Straight Line, Sum of the Year's Digits, and Accelerated Cost Recovery

*  Days Between Dates, 10 Alarms, Clock

*  10 Memory Registers with Storage Arithmetic

*  Can use the HP 82240 Infrared Printer (82240A/82240B); even though they are well out of production by now


HP 17B

HP 17BII+

HP 17B Mode Menu

HP 17BII+ Mode Menu

Now for the differences:


HP 17B:  (1988)

*   Available Memory:  6,752 bytes

*   Batteries:  3 x LR 44

*   Case Colors:   Brown, Peach-Orange shift key and text

*   Shift functions are printed above the keys


HP 17BII+:  (2007 - present)

*   Available Memory:  about 31,000 bytes

*   Batteries:  2 x CR2032

*   Case Colors:  Silver, Electric Blue shift key and text

*   Shift functions are printed below the function

*   Double line print option  

*   Currency conversion mode

*   RPN mode (this was added to the HP 17BII in 1990)


I did a quick speed test on the equation:


Σ(I:1:525:1:I)  (Result:  138,075)


The original HP 17B won the speed test.


HP 17B Solver

HP 17BII+ Solver


That is about it.   I love the 17B series, which has a rich set of financial functions and a robust solver that includes ore functions that most calculators have.  (including integer part, fractional part, signum, solve if, Σ, date functions, and yes, the Let and Get functions!)

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. 


Classic RPN Stack Operations

  Classic RPN Stack Operations Starting Stack: T:  d Z:  c Y:  b X:  a OVER :   Copies b to the Z and X stacks, while leaving ...