UP | HOME

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

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 the jacobian program and the jacobian program calls the toColVec program. As another example, the eActivity FunCrt2D makes use of the programs gradient, hessian, and subsList. 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 even
    • evenp(a): 1 if even, 0 if odd
  • Interpreting decimal integers as binary and vice versa
    • bitI(a): dec interpreted as bin
    • bitO(a): bin interpreted as dec
  • Bit Shifting
    • bitSR(a): Shift right 1 bit
    • bitSRn(a,n): Shift right n bits
    • bitSL(a): Shift left 1 bit
    • bitSLn(a,n): Shift left n bits
  • Bit Counting
    • intLog2(a): Int of base 2 log
    • bitSIZE(a): Bits required
    • bitCNT(a): Number of set bits
    • bitCLZ(a): Number of left zeros
  • Binary Bitwise logical operations on fixed sized integers
    • bitANDn(a,b,n): N bit, bitwise and
    • bitXORn(a,b,n): N bit, bitwise xor
    • bitORn(a,b,n): N bit, bitwise or
    • bitNOTn(a,b,n): N bit, bitwise not
  • Binary Bitwise logical operations
    • bitAND(a,b): Bitwise and
    • bitXOR(a,b): Bitwise xor
    • bitOR(a,b): Bitwise or
  • Lists of Bits (utility functions used behind the scenes)
    • bitLIST(a): Reverse list of bits
    • bitLISTn(a,n): Reverse list N bits
    • bitULIST(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 equation
  • slvLinOE(M,B): Find the least squares solution for an over-determined matrix equation
  • augRREF(M,B): Augment two matrices together and RREF
  • invLeft(M): Left inverse
  • invRight(M): Right inverse
  • LU2P(M,L,U): Return the value of \(P\) for \(LU\) decomposition.
  • cPolyS(M): Characteristic polynomial via symbolic computation
  • cPolyN(M): Characteristic polynomial via numeric interpolation
  • matPosP(M): Matrix predicate returning TRUE if all eigenvalues are positive
  • matNegP(M): Matrix predicate returning TRUE if all eigenvalues are negative
  • matInvP(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 points
  • pt2ray(start_point_row_vector,end_point_row_vector): Equation for ray given 2 points
  • sign(v): Like signum(), but returns zero when v is zero.

2.6. Polynomial Stuff (mjrLib/mjrPolynomial)

  • rt2ply(root_list): Polynomial with given roots
  • rt2plym(root_list): Like rt2plym but the returned polynomial is monic
  • slvPly(polynomial_coefficients_list): Solve polynomial numerically
  • compMtrx(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 Stats
    • repMesMI(list_of_measurements): Meas Interval

2.8. Trig Functions (mjrLib/mjrTrig)

  • csc(angle): cosecant
  • sec(angle): secant
  • cot(angle): cotangent
  • havers(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 force
    • u_kgf_lb(v): kg force to US pounds
    • u_N_lb(v): Newtons to US pounds
    • u_lb_N(v): US Pounds to newtons
  • Units (temp)
    • u_F_C(v): Degrees Fahrenheit to Celsius
    • u_C_F(v): Degrees Celsius to Fahrenheit
    • u_K_C(v): Degrees Kelvin to Celsius
    • u_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 inches
    • u_mi_km(v): International miles to kilometers
    • u_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.

    jacobian-ut-01.png
    jacobian-ut-02.png
    jacobian-ut-03.png

  • gradient(expression_in_x_y_and_z): Compute the gradient vector of an expression (always a row vector). This is much like jacobian; however, the functions are always scalar valued – i.e. the \(n\) in the jacobian documentation is equal to one.

    gradient-ut-01.png

  • hessian(expression_in_x_y_and_z): Compute the Hessian matrix of a scalar valued, bivariate/trivariate expression.

    hessian-ut-01.png
    hessian-ut-02.png

  • mkDmat(diag_as_list_matrix_or_vector): Make a diagonal matrix

    mkDmat-ut-01.png
    mkDmat-ut-02.png

  • mkMat(expression_in_i_and_j, number_of_rows, number_of_columns): Make a matrix from an index expression

    mkMat-ut-01.png
    mkMat-ut-02.png

  • 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.

    newtonC1-ut-01.png
    newtonC1-ut-02.png

  • 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 the jacobian 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.

    newtonRn-ut-01.png
    newtonRn-ut-02.png

  • 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 from solve into an equation.

    subsList-ut-01.png
    subsList-ut-02.png

  • 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.

    hessTest-ut-01.png
    hessTest-ut-02.png

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 variable
  • FunCrt2D: Find the critical points of an expression in 2 variables
  • FunCrt3D: Find the critical points of an expression in 3 variables (or any number really)
  • CubicInterp: Cubic Interpolation between two points
  • LinearInterp: Linear Interpolation between two points
  • SolveTri: 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 equation
  • CurrentDiv: Current Divider
  • VoltageDiv: Voltage Divider
  • HarmonicMotion: Harmonic Motion
  • OhmsLaw: 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