Classpad II Stuff
Author: | Mitch Richling |
Updated: | 2025-05-25 12:53:51 |
Generated: | 2025-05-25 12:53:53 |
Copyright © 2025 Mitch Richling. All rights reserved.
Table of Contents
- 1. Introduction
- 2. Library Functions
- 2.1. CAS Stuff (
mjrLib/mjrCAS
) - 2.2. Physical Constants (
mjrLib/mjrConstants
) - 2.3. Integer Stuff (
mjrLib/mjrIntegers
) - 2.4. Linear Algebra (
mjrLib/mjrLinearAlg
) - 2.5. Misc Math (
mjrLib/mjrMiscMath
) - 2.6. Polynomial Stuff (
mjrLib/mjrPolynomial
) - 2.7. Repeated Measurement (
mjrLib/mjrRepMeas
) - 2.8. Trig Functions (
mjrLib/mjrTrig
) - 2.9. Units Functions (
mjrLib/mjrUnits
)
- 2.1. CAS Stuff (
- 3. Programs (
mjrProg/
) - 4. Computational eActivities (
mjrComp/
) - 5. Formulas & Equations eActivities (
mjrEqn/
) - 6. Shift Key Assignments
1. Introduction
Just some stuff I've written for the Casio Classpad II calculator.
All of the programs mentioned here may be found on github: https://github.com/richmit/classpad2
WARNING: Many of these items depend upon each other. For example the programs
gradient
&hessian
both call thejacobian
program and thejacobian
program calls thetoColVec
program. As another example, the eActivityFunCrt2D
makes use of the programsgradient
,hessian
, andsubsList
. If you run into unresolved names, then double check that the programs are in the "library" folder, and the functions in the eActivities have been evaluated.
2. Library Functions
Functions intended to be placed in the Library
folder. The functions are contained inside eActivities so that one may pick and choose which functions they
wish to have defined – simply open the function strip, and evaluate the lines with the functions desired.
2.1. CAS Stuff (mjrLib/mjrCAS
)
Just a couple simple algebraic manipulation short cuts.
tbmxs(expression)
: Multiply top & bottom of a fraction by a factor. The top & bottom are then separately expanded and simplified twice.xxs(expression)
: Expand, Expand, Simplify
2.2. Physical Constants (mjrLib/mjrConstants
)
All physical constants functions take the number of significant digits requested. A \(0\) means to return all available digits. All of these are from the 2018
NIST standard values. Note many constants are defined in Casio's Physium
application – I just like to have these available in the keyboard function
catalog because I use them quite frequently.
Note: These all start with c_
so they show up clumped together in the keyboard function catalog.
c_c0(d)
: Speed of light (299792458)c_g(d)
: Standard acceleration of gravity (9.80665)c_G(d)
: Newtonian constant of gravitation (6.67430e-11)c_atm(d)
: Standard atmospheric pressure (101325)c_avogadro(d)
: Avogadro constant (6.02214076e23)
2.3. Integer Stuff (mjrLib/mjrIntegers
)
Most of these functions accept & return non-negative integers. The idea is to be able to perform bit manipulation operations on regular integers. We can
provide binary-like input and output from these functions with the bitI
and bitO
functions. It's no HP-16C, but it will work in a pinch.
- General Integer Stuff
oddp(a)
: 1 if odd, 0 if evenevenp(a)
: 1 if even, 0 if odd
- Interpreting decimal integers as binary and vice versa
bitI(a)
: dec interpreted as binbitO(a)
: bin interpreted as dec
- Bit Shifting
bitSR(a)
: Shift right 1 bitbitSRn(a,n)
: Shift right n bitsbitSL(a)
: Shift left 1 bitbitSLn(a,n)
: Shift left n bits
- Bit Counting
intLog2(a)
: Int of base 2 logbitSIZE(a)
: Bits requiredbitCNT(a)
: Number of set bitsbitCLZ(a)
: Number of left zeros
- Binary Bitwise logical operations on fixed sized integers
bitANDn(a,b,n)
: N bit, bitwise andbitXORn(a,b,n)
: N bit, bitwise xorbitORn(a,b,n)
: N bit, bitwise orbitNOTn(a,b,n)
: N bit, bitwise not
- Binary Bitwise logical operations
bitAND(a,b)
: Bitwise andbitXOR(a,b)
: Bitwise xorbitOR(a,b)
: Bitwise or
- Lists of Bits (utility functions used behind the scenes)
bitLIST(a)
: Reverse list of bitsbitLISTn(a,n)
: Reverse list N bitsbitULIST(a)
: Bit list to number
2.4. Linear Algebra (mjrLib/mjrLinearAlg
)
diagR(M)
: Diagonal for matrix (Matrix need not be square)dprod(M)
: Product of diagonal (Matrix need not be square)dsum(M)
: Diagonal Sum or trace (Matrix need not be square)slvLin(M,B)
: Solve matrix equationslvLinOE(M,B)
: Find the least squares solution for an over-determined matrix equationaugRREF(M,B)
: Augment two matrices together and RREFinvLeft(M)
: Left inverseinvRight(M)
: Right inverseLU2P(M,L,U)
: Return the value of \(P\) for \(LU\) decomposition.cPolyS(M)
: Characteristic polynomial via symbolic computationcPolyN(M)
: Characteristic polynomial via numeric interpolationmatPosP(M)
: Matrix predicate returning TRUE if all eigenvalues are positivematNegP(M)
: Matrix predicate returning TRUE if all eigenvalues are negativematInvP(M)
: Matrix predicate returning TRUE if M is inevitable
2.5. Misc Math (mjrLib/mjrMiscMath
)
pt2ln(p1_row_vector,p2_row_vector)
: Equation for line given 2 pointspt2ray(start_point_row_vector,end_point_row_vector)
: Equation for ray given 2 pointssign(v)
: Likesignum()
, but returns zero when v is zero.
2.6. Polynomial Stuff (mjrLib/mjrPolynomial
)
rt2ply(root_list)
: Polynomial with given rootsrt2plym(root_list)
: Likert2plym
but the returned polynomial is monicslvPly(polynomial_coefficients_list)
: Solve polynomial numericallycompMtrx(polynomial_coefficients_list)
: Companion matrix
2.7. Repeated Measurement (mjrLib/mjrRepMeas
)
I have a much more sophsticated solution for the HP-42S calculator: https://richmit.github.io/hp42/meas.html
- Mean & Standard Deviation
repMesNS(list_of_measurements)
: Meas Stats (μ & σ)repMesNI(list_of_measurements)
: Meas Interval (μ±σ)
- Median & Interquartile Range
repMesMS(list_of_measurements)
: Meas StatsrepMesMI(list_of_measurements)
: Meas Interval
2.8. Trig Functions (mjrLib/mjrTrig
)
csc(angle)
: cosecantsec(angle)
: secantcot(angle)
: cotangenthavers(angle)
: haversine: \(\frac{1-\cos(x)}{2}\)cis(angle)
: Cosine-I-Sine: \(\cos(x)+i\cdot\sin(x)\)
2.9. Units Functions (mjrLib/mjrUnits
)
Note: These all start with u_
so they show up clumped together in
the keyboard function catalog.
- Units (volume)
u_gal_L(v)
: US Gallons to liters (A US gallon is about 0.83267 Imperial gallon)u_L_gal(v)
: liters to US Gallons
- Units (force)
u_lb_kgf(v)
: US Pounds to kg forceu_kgf_lb(v)
: kg force to US poundsu_N_lb(v)
: Newtons to US poundsu_lb_N(v)
: US Pounds to newtons
- Units (temp)
u_F_C(v)
: Degrees Fahrenheit to Celsiusu_C_F(v)
: Degrees Celsius to Fahrenheitu_K_C(v)
: Degrees Kelvin to Celsiusu_C_K(v)
: Degrees Celsius to Kelvin
- Units (length)
u_in_cm(v)
: International inches to centimeters (2.54 inches to the centimeter)u_cm_in(v)
: Centimeters to international inchesu_mi_km(v)
: International miles to kilometersu_km_mi(v)
: kilometers to international miles
3. Programs (mjrProg/
)
One of the best ways to understand how to use these programs is to look at the "Unit Tests" in the (mjrProgUnitTests/
) directory. These are just
eActivities that put each program through a few tests. The images below each program are taken from these eActivities.
3.1. Interactive
jacobian(expression_in_x_y_and_z)
: Compute the Jacobin matrix of an expression
This program takes an expression in up to three variables. The second argument is the number of variables in the expression. The expression is interpreted as a function with values in \( \mathbb{R}^n \). When \(n=1\) the expression in normally a simple algebraic expression, but it may also be a one element list or vector. When \(n>1\) the expression must be a list of expressions or a vector (row or column) of expressions. No matter the form of the input, the result will be in the standard matrix form. For example a function \( \mathbb{R}^n\rightarrow\mathbb{R} \) will have a column vector jacobin and a row vector gradient.
gradient(expression_in_x_y_and_z)
: Compute the gradient vector of an expression (always a row vector). This is much likejacobian
; however, the functions are always scalar valued – i.e. the \(n\) in thejacobian
documentation is equal to one.hessian(expression_in_x_y_and_z)
: Compute the Hessian matrix of a scalar valued, bivariate/trivariate expression.
mkDmat(diag_as_list_matrix_or_vector)
: Make a diagonal matrix
mkMat(expression_in_i_and_j, number_of_rows, number_of_columns)
: Make a matrix from an index expression
newtonC1(expression_in_x, initial_guess, epsilon)
: Search for a root of a univariate expression using Newton's method with complex arithmetic. Every 10 iterations the program will ask the user if they wish to continue the search.
newtonRn(expression_in_x_y_z, initial_guess, epsilon)
: Search for a root system of 1-3 real valued expressions using Newton's method. This program accepts an expression with 1 to 3 components as it's first argument (just like thejacobian
program), and a point with the same number of components as it's second argument. Each argument may be provided as a list, row vector, or column vector. No mater the input form, the result will always be a column vector. Every 10 iterations the program will ask the user if they wish to continue the search.
subsList(expression, substitution_expression_or_list)
: Form a list by substituting each substitution into expression. This is a very handy way to substitute all the solutions fromsolve
into an equation.
hessTest(hessian_or_list_of_hessians)
: Preform the second derivative test on one or more Hessians. Univariate hessians may be provided as a number, or a matrix with a single element. Multivariate hessians must be provided as a matrix. When a list of Hessians is given, they do not need to be of the same size.
3.2. Utilities
These programs are designed to be used by other programs, and are far from user friendly. Still, they can be used interactively so long as one is willing
to deal with the grumpy user interface. :)
toColVec(expression_list_or_vector)
: Convert object to a column vector. This is used by numerous programs to transform arguments into a canonical form.subsCVec(expression, column_vector)
: Use the components of a tuple (provided as column vector) to substitute into variables x, y, & z.
4. Computational eActivities (mjrComp/
)
These are eActivities I saved off because they contain a general computational pattern I can reuse.
FunCrt1D
: Find the critical points of an expression in 1 variableFunCrt2D
: Find the critical points of an expression in 2 variablesFunCrt3D
: Find the critical points of an expression in 3 variables (or any number really)CubicInterp
: Cubic Interpolation between two pointsLinearInterp
: Linear Interpolation between two pointsSolveTri
: Solve triangles. I add cases as I encounter them, and so far I have ASA, SSS, SAS, & AAS.SolveTriGeom
: Just a couple geometry applications with triangles.DiodeModel
: Compute SPICE model parameters from bench measurements
5. Formulas & Equations eActivities (mjrEqn/
)
These eActivities provide a reference & computational environments for various formulas & equations.
Diode
: Shockley Diode equationCurrentDiv
: Current DividerVoltageDiv
: Voltage DividerHarmonicMotion
: Harmonic MotionOhmsLaw
: Ohm's Law
6. Shift Key Assignments
approx = |
cut \(x\) |
paste \(y\) |
undo \(z\) |
\(\sqrt{\square}\) ^ |
\(\frac{\square}{\square}\) \(\div\) |
[] ( |
\(7\) |
\(8\) |
\(9\) |
\(\times\) |
{} ) |
\(e^\square\) \(4\) |
\(\ln\) \(5\) |
\(\log_\square(\square)\) \(6\) |
\(-\) |
\(\vert\) , |
\(\sin\) \(1\) |
\(\cos\) \(2\) |
\(\tan\) \(3\) |
\(\circ\) \(+\) |
\(\Rightarrow\) (-) |
\(\pi\) \(0\) |
\(i\) . |
\(\angle(\) EXP |
ans EXE |