Showing posts with label floating point numbers. Show all posts
Showing posts with label floating point numbers. Show all posts

Friday, November 13, 2026

Spotlight: HP 35 Calculator (1972)

Spotlight: HP 35 Calculator (1972)








Here it is, the first every handheld scientific calculator: the Hewlett Packard HP 35 from 1972!

I got it at the HHC 2026 Conference earlier this month, and I thank you, David Ramsey, Gene Wright, Ron Grant, and Mark Sims. (Rest in peace, Mr. Sims)


The 35 came with a working Ni-CAD battery pack and the original plug in charger. The keyboard and the leather case are in excellent condition. I also have the little booklet.


The HP 35 is Version 4, and in this version, the functions are labeled on top of the keys instead of above them. All the labels are in capital letters. In earlier versions, some of the labels were in lower case (see the Functions of the 35 section).


I also have a 3-AAA Alkaline battery adapter from Waterhosko that is for HP classic calculator series (35, 45, 55, 80, 65, 67).


I feel like I have finally arrived.


Quick Facts


Model: HP 35

Company: Hewlett Packard

Type: RPN Scientific

Memory: 1 (store, recall)

Years in Production: 1972 to 1975

Display: 10 digits

Original Price: $ 395.00


Hardware, Simulators, and Emulators


The hardware may not be easy to come by, although there are still some HP 35 calculators available through auction sites such as eBay.


There are plenty of simulators and emulators for the HP 35. For example, the pockemul app, available for both Android, Apple iOS, Windows, and mac0S, contains many past calculators and pocket computers. One of the calculators that are offered at no cost is the HP 35 (the version shown is an earlier version (not red dot) where the functions are labeled above the keys).


Site: https://pockemul.com/


A Javascript simulator, hosted by the MoHPC (Museum of HP Calculators) site, is written by Neil Fraser. The simulator may also be downloaded: https://www.hpmuseum.org/simulate/hp35sim/hp35sim.htm


Functions on the HP 35


The HP 35 has one shift key, and that is only for the trigonometric functions.


[ x^y ]: power key, note the order of the variables

[ log ]: common logarithm (log10)

[ ln ]: natural logarithm, base e

[ e^x ]: exponential function

[ √x ]: principal square root

[ sin ]: sine function, angle is in degrees

[ arc ] [ sin ]: arcsine function, returns the angle in degrees

[ cos ]: cosine function, angle is in degrees

[ arc ] [ cos ]: arccosine function, returns the angle in degrees

[ tan ]: tangent function, angle is in degrees

[ arc ] [ tan ]: arctangent function, returns the angle in degrees

[ clr ]: sets all four stacks (X, Y, Z, T) and the memory register to 0

[ 1/x ]: reciprocal

[ x<>y ]: swap the contents of X and Y

[ R↓ ]: roll down the stack (T → Z, Z → Y, Y → X, X → T)

[ STO ]: store the contents of the X stack into memory

[ RCL ]: recall the contents of memory to the X stack, pushes up the contents up the stack (whatever was in stack T was lost)

[ ENTER ]: pushes the contents of memory form the X stack to the Y stack, everything gets pushed up one level (whatever was in stack T was lost). Entering a new number replaces the copied number in the X stack.

[ CHS ]: changes the sign of the number of the X stack. For the HP 35 only, the sign can be changed before or after the number has been entered.

[ - ], [ + ], [ × ], [ ÷ ]: arithmetic keys

[ π ]: Enters pi (π) to the X stack. (3.141592654)


The Power Function


I hope you have noticed something about the power function. Usually the power function on must calculators (especially non-graphing scientific ones) usually are labeled y^x. On most RPN calculators, the number on the Y stack is treated as base while the number on the X stack is treated as the exponent.


This isn’t the case on the HP 35: the key is labeled x^y. The variables are reversed. On the HP 35’s power function, the number on the number of X stack is the base, while the number on the Y stack is treated as the exponent.


For example, let’s try to calculate 1.8^3.

On the HP 35: 3 [ ENTER ] 1.8 [ x^y ] returns 5.832000001


Now try 3^4.

On the HP 35: 4 [ ENTER ] 3 [ x^y ] returns 81.00000001

But 3^4 = 81. Why the extra .00000001?


Accuracy


Try: 1 ÷ 3 × 3

1, [ ENTER ], 3, [ ÷ ], 3, [ × ]

This returns .9999999999

(we would expect 1)


To put it simply, the HP 35 works with floating point numbers which are presented with a 10-digit mantissa and a 2-digit exponent. Numbers are stored as binary-coded decimal as 56 bit numbers. The calculator rounds off results in at 11th decimal place, leaving a possibility of the 10th place of a possible error of ±1 digit.


With the internal algorithms used with trigonometric, exponential, and other transcendental functions, round off errors can build up and show up in the 10th decimal place.


Something to keep in mind when doing calculations: The HP 35 does not have a fixed decimal place setting, so rounding to more accurate results falls to the responsibility of the user.


For more information:



Cochran, David S. “Algorithms and Accuracy in the HP-35” HP Journal. June 1972. Retrieved from

https://www.keesvandersanden.nl/calculators/hp_journals/HP_Journal_7206_Algorithms_and_Accuracy_in_the_HP-35.pdf

(Retrieved November 11, 2026)



“HP 35” Wikipedia. Last Edited on December 13, 2025. Retrieved November 11, 2026.

https://en.wikipedia.org/wiki/HP-35







Final Thoughts



The HP 35 is a well-time honored calculator and has brought the world of scientific computing to many in a handheld package. It is a delight to use and the red LCD display is timeless.


This would make an excellent entry-level scientific calculator for those who are learning RPN for the first time, providing a wealth of functions for a wide range of calculations. I recommend this calculator, physical handled and/or emulator.



Eddie


HHC Conference Videos

Please check out the Youtube page hpcalc.org at https://www.youtube.com/@hpcalc .   

Videos and talks from HP Calculator conferences until HCC 2025 are posted.   Look out for talks from HCC 2026 to posted there soon.  Disclaimer:  I do not run this account.  


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, November 15, 2025

Basic (TI-81) vs. Python (TI-84 Plus CE Python): First and Second Derivative and Integral by Simpson’s Rule

Basic vs. Python: First and Second Derivative and Integral by Simpson’s Rule



Calculators Used


Basic: TI-81

Python: TI-84 Plus CE Python



Task


Estimate the numerical first derivative by the Nearby Secant Line Method:


f'(x) = lim (f(x + h) - f(x - h)) / (2 * h) as h → 0



Estimate the numerical second derivative by:


f''(x) = lim (f(x + h) - 2 * f(x) + f(x - h)) / h^2 as h → 0



Estimate the definite integral by Simpson’s rule:


∫( Y1 dx, x = a to x = b) ≈

(b - a)/(3 * n) + (f(a) + 4 * f1 + 2 * f2 + 4 * f3 + 2 * f4 + ... + 2 * f_n-2 + 4 * f_n-1 + f(b))


n must be an even integer.

fi = f(a + i * (b – a) / n)


BASIC: TI-81


First let’s look at the TI-Basic version with the classic TI-81:


First Order Derivative  (Nearby Secant Line Method)


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


DER1  (61 bytes)

Function

Rad

Disp "D/DX Y1"

1E-4 -> H

Disp "X?"

Input A

A+H -> X

Y1 -> D

A-H -> X

(D-Y1)/(2H)->D

Disp D



Second Order Derivative


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


DER2  (75 bytes)

Function

Rad

Disp "D²/DX² Y1"

1E-4 -> H

Disp "X?"

Input A

A+H -> X

Y1 -> D

A -> X

D-2*Y1 -> D

A-H -> X

(D+Y1)/(H^2) -> D

Disp D


INTGY1  (134 bytes)

Function 

Rad

Disp "SIMPSONS RULE"

Disp "A,B,N?"

Input A

Input B

Input N

A -> X

Y1 -> S

B -> X

S+Y1 -> S

1 -> I

Lbl 1

A+I*(B-A)/N -> X

S+2*Y1 -> S

If Fpart (I/2)≠0

S+2*Y1 -> S

IS>(I,N-1)

Goto 1

S*(B-A)/(3*N) -> S

Disp S


Examples


f(x) = 3*x^3 + 4*x – 1


Y1 = 3 * X³ + 4 * X – 1

f’(2.4): DER1 returns: 55.84

f’’(2.4): DER2 returns: 43.2


∫( 3 * X³ + 4 * X – 1 dX, 0.5, 1.5):

INTGY1 returns with N = 40 returns 6.75


Notes for BASIC


Before running the programs, store the function to the variable Y1. Calling Y1 evaluates the function of the value stored in variable X. Evaluate Y1 at X: [2nd], (Y-VARS), 1


The TI-81 MUST be in Function mode to evaluate Y1, unless an error occurs. The programs set the angle mode to Radians. The value of h is set to a "default" value of 10^-4. We want h to be small, but not too small. A value of h too small can run the risk of floating point errors.


In the integral program:


* I/2 - Ipart (I/2) is Fpart(I/2), but the long way. Python does not have a built-in fractional part function.


* IS>(I,N-1) translates to:


I=I+1

If I>N-1

Goto 1


IS> is the increment (by 1) and skip, a command in TI-Calculator Basic.


In general BASIC languages, evaluation Y1 may take a different approach, depending on the calculator, pocket computer, or computer:


General Basic:


### ...

### X = g(A)

### GOSUB ***

### ...


*** Y = <evaluate f(X)>

*** RETURN


Another approach on a calculator: Use another program


Prog <main>

...

g(A) -> X

Prog "FX" (see below, answer is stored in Y)

...


Prog "FX" (or any name of your choosing)

<evaulate f(X)> -> Y

<end program, an implied Return is executed here>



PYTHON: TI-84 Plus CE Python Edition


The code presented here uses the math module and built-in functions, and should work with any calculator with Python.


DERINTG.py


from math import *

# derivatives and integrals

# 2025-06-01


print("MATH MODULE IS IMPORTED")


# first derivative function

def der1(fx,x,h=1E-3):

  # fx is a string

  # h is optional (def 1E-3)

  # set up lambda

  f=eval("lambda x:"+fx)

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

  return d


# second derivative function

def der2(fx,x,h=1E-3):

  # fx is a string

  # h is optional (def 1E-3)

  # set up lambda

  f=eval("lambda x:"+fx)

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

  return d


# integrals by simpsons rule

def intg(fx,a,b,n=64):

  # fx is a string

  # n is even, optional (def 64)

  # set up lambda

  f=eval("lambda x:"+fx)

  s=f(a)+f(b)

  for i in range(1,n):

    w=f(a+i*(b-a)/n)

    s+=(2*w) if (i/2-int(i/2)==0) else (4*w)

  s*=(b-a)/(3*n)

  return s


I decided to make a script of three functions.


Python uses binary arithmetic, so be prepared to possibly see answers such as 2.999999999999 and 5.00000000000001. The code leaves the answer in floating point form. Feel free to use the round function and/or format specifiers as you see fit.


f(x) = 3*x^3 + 4*x – 1


In Python:

f(x) = 3*x**3+4*x-1


Examples


Store the string to s:

s=”3*x**3+4*x-1”

der1(s,2.4) returns 55.84000299999303

der2(s,2.4) returns 43.19999999324864

intg(s,0.5,1.5) returns 6.75



I hope you find this useful. 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.

Symmetric Quartic Equation - Python

Symmetric Quartic Equation - Python Note: The code is programmed with a TI-84 Evo. No modules are used, so the scripts should be adopt...