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.

Saturday, November 8, 2025

RPN: Certain Integrals to Positive Infinity

RPN: Certain Integrals to Positive Infinity


Introduction


Today’s RPN session deals with improper integrals where the upper limit is positive infinity (∞).


∫( f(x) dx, a, ∞) → lim ∫( f(x) dx, a, t) as t → ∞


Some properties that will be use:

lim 1/t^n as t → ∞ approaches 0

lim e^(-t) as t → ∞ approaches 0

lim p(t) ÷ q(t) as t → ∞ approaches 0 where p(t) and q(t) are polynomials and

degree p(t) < degree q(t)

lim p(t) ÷ q(t) as t → ∞ approaches p_n ÷ q_n where p(t) and q(t) are polynomials and

degree p(t) = degree q(t). p_n and q_n are the leading coefficients of p(t) and q(t), respectively.


All integrals presented will have closed formulas because they have very friendly anti-derivatives.


( 1 ÷ (x^n) dx, a, ∞)



∫( 1 ÷ (x^n) dx, a, ∞) = 1 ÷ ((n - 1) * a^(n - 1))


(Abbreviated) Derivation:

∫( 1 ÷ (x^n) dx, a, ∞)

= lim (1 ÷ x^(n - 1) * -1 ÷ (n – 1) as x → ∞) - (1 ÷ a^(n – 1) * -1 ÷ (n – 1))

= ( 0 * -1 ÷ (n – 1) ) + 1 ÷ ((n – 1) * a^(n – 1))

= 1 ÷ ((n – 1) * a^(n – 1))


∫( 1 ÷ (x^n) dx, a, ∞) = 1 ÷ ((n - 1) * a^(n - 1))


HP 15C Code:

[42, 21, 11]: LBL A

[         1]: 1

[        30]: -

[    43, 36]: LSTx

[        20]: ×

[        15]: 1/x

[    43, 32]: RTN


Stack:

Y: a

X: n


Examples:

a = 2.75, n = 2: 4/11 ≈ 0.36364

a = 4.9, n = 3: ≈ 0.02082


( 1 ÷ ((x - r)*(x - s)) dx, a, ∞)


∫( 1 ÷ ((x - r)*(x - s)) dx, a, ∞)

= 1 ÷ (r - s) * ln( abs((a - s) ÷ (a – r)) )

For best results, a > max(s, r)


(Abbreviated) Derivation:

∫( 1 ÷ ((x - r)*(x - s)) dx, a, ∞)


Simply by partial fractions:

1 ÷ ((x - r)*(x – s)) = 1 ÷ ((r – s) * (x – r)) – 1 ÷ ((r – s) * (x – s))


Anti-derivative:

∫( 1 ÷ ((x - r)*(x - s)) dx)

= 1 ÷ (r – s) * ( ln(abs(x – r)) – ln(abs(x – s)) )

= 1 ÷ (r – s) * ln ( abs((x – r) ÷ (x – s)) )


Limit as x → ∞:

1 ÷ (r – s) * ln ( abs((x – r) ÷ (x – s)) )

= 1 ÷ (r – s) * ln ( abs((1 – r ÷ x) ÷ (1 – s ÷ x)) )

= 1 ÷ (r – s) * ln ( abs(1) )

= 1 ÷ (r – s) * ln(1)

= 0


When x = a

1 ÷ (r – s) * ln ( abs((a – r) ÷ (a – s)) )

= 1 ÷ (r – s) * ln ( abs(1 ÷ [(a – r) * (a -s)]) )

= 1 ÷ (r – s) * ln ( 1 ÷ [abs((a – s) ÷ (a – r))] )

= -1 ÷ (r – s) * ln ( abs((a – s) ÷ (a – r)) )


Then:

∫( 1 ÷ ((x - r)*(x - s)) dx, a, ∞) = 0 - (-1 ÷ (r – s) * ln ( abs((a – s) ÷ (a – r)) ))

= 1 ÷ (r - s) * ln ( abs((a - s) ÷ (a – r)) )


Code:

[42, 21, 12]: LBL B

[    44,  1]: STO 1

[        33]: R↓

[    44,  2]: STO 2

[        33]: R↓

[    44,  3]: STO 3

[45, 30,  1]: RCL- 1

[    45,  3]: RCL 3

[45, 30,  2]: RCL- 2

[        10]: ÷

[    43, 16]: ABS

[    43, 12]: LN

[    45,  2]: RCL 2

[45, 30,  1]: RCL- 1

[        15]: 1/x

[        20]: ×

[    43, 32]: RTN


Stack:

Z: a

Y: r

X: s


Examples:

a = 7.25, b = -3, s = 6: (ln 41 - ln 5) ÷ 9 ≈ 0.23379

a = 11, b = 4, s = 9: (ln 7 - ln 2) ÷ 5 ≈ 0.25055


( 1 ÷ e^x dx, a, ∞)


∫( 1 ÷ e^x dx, a, ∞) = 1 ÷ e^a


Code:

[42, 21, 13]: LBL C

[        12]: e^x

[        15]: 1/x

[    43, 32]: RTN


Stack:

X: a


Examples:

a = 4: e^(-4) ≈ 0.01832

a = 6: e^(-6) ≈ 0.00248


( x ÷ e^x dx, a, ∞)


∫( x ÷ e^x dx, a, ∞) = (a + 1) ÷ e^a


Code:

[42, 21, 14]: LBL D

[        12]: e^x

[    43, 36]: LSTx

[         1]: 1

[        40]: +

[        34]: x<>y

[        10]: ÷

[    43, 32]: RTN


Stack:

X: a


Examples:

a = 4: 5 ÷ e^(-4) ≈ 0.09158

a = 6: 7 ÷ e^(-6) ≈ 0.01735


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 author does not use AI engines and never will.


Sunday, November 2, 2025

Quick Review: Casio fx-9910CW 2nd Edition

Quick Review: Casio fx-9910CW 2nd Edition













The Casio fx-9910CW 2nd Edition is an update of the fx-991CW first released in 2023.



Product Pages


United States:

https://www.casio.com/us/scientific-calculators/product.FX-9910CW/


The fx-9910CW has two keyboards: black with gold font and pink with purple font (limited). I have one each and Casio has improved on the readability on the pink edition with the dark purple font.


I’m sure this model will be available world wide soon.



What’s the Same and What’s Different


Overall, the fx-9910CW 2nd Edition has the same mathematical features as the fx-991CW. The modes included are:


Calculate: the main app for mathematical calculations


Statistics: 1 and 2 variable with seven regression models:


Linear:  y=a+bx

Quadratic: y=a+bx+cx^2

Logarithmic:  y=a+b*ln(x)

Exponential:  y=a*e^(bx)

Power I:  y=a*b^x

Power II: y=a*x^b

Inverse:  y=a+b/x


Statistical graphs may be generated with the QR feature.


Distribution: Binomial, Normal, and Poisson distributions, along with their inverses. The functions work with lower-tail probabilities (-∞ or 0 to x).


Spreadsheet: 5 columns, 45 rows. 2,380 byte memory.


Table: Generate a table for up to two functions f(x) and g(x). Generate graphs with the QR feature.


Equations: Linear systems (up to 4 x 4), polynomials up to 4th order, and a general equation solver.


Inequalities: Solve inequalities for polynomials up to the 4th order.


Complex Numbers: Complex number arithmetic with polar/rectangular conversion, integer powers, real/imaginary parts, conjugate


Base N: Base mode for the traditional decimal, hexadecimal, octal, and binary basis. Binary integers are up to 31 bytes with one sign bit.


Matrix: Four matrices, up to size 4 x 4, with basic matrix functions such as determinant, transpose, and inverse.


Vector: Four vectors, 2D or 3D, with dot product, cross product, and norm.


Math Box: Dice Roll and Coin Toss simulations

47 scientific constants (SI units) and unit conversions


We still have the newer Casio style of navigation keys, the Home Key, the Back Key, the Settings key, and the Scroll up and down keys.


What is different?


First, the fx-9910CW is not solar powered, but instead runs on a single AAA battery.


Welcome changes:


The menus all have short cut keys! This eliminates the requirement to scroll down menus, which some get long, to find the sub menus and functions. This makes the operating the calculator a lot easier and more efficient, eliminating additional key strokes by repeatedly pressing the arrow keys.


For example, to get the absolute value in Calculate mode, press [ CATALOG ], [ 3 ] for Numeric Calc, [ 1 ] for Absolute Value.


In the same mode, we call up the Speed of Light constant (c), press [ CATALOG ] , [ 7 ] for Sci Constants, [ 1 ] for Universal, and [ 3 ] for c.


There is a setting to turn the hide the shortcut numbers but thankfully it won’t turn off the ability to navigate by using short cut keys.


The 10^[] and FORMAT keys return to familiar form! Like the fx-CG 100, we have an option on how the 10^[] and FORMAT keys operate.


10^[] Key:

(1) Power: Acts like a power key like the fx-991CW. I read that there are potential problems with calculating with this key leaving calculations to return unexpected answers.

(2) Sci. Notat: This returns this key to the traditional scientific notation key. When this option is selected, the 10^ is shown in a small font. This key now acts like the [ EE ] or [ EXP ] keys on other scientific calculators. This is the default setting.


FORMAT Key:

(1) -Ï€√ ←→ Decimal. Pressing the FORMAT key just toggles between decimal and the exact (when available) format of answers. This brings back the beloved [ S←→D ] key. This is the default settings.

(2) Format Menu. This is the format menu that is presented, similar to the fx-991CW. We trade off the quick toggle for additional formatting options.


Shortcut Catalog. Pressing [ SHIFT ] [ CATALOG ] is a new feature and provides a listing of all mathematical functions available in the active mode. Up to 15 functions are shown, using the arithmetic keys (+, -, ×, ÷) and the decimal point (.) as additional shortcut keys. The shortcut catalog does not have the conversions or constants.


These changes are welcome and enhance the operating experience of the calculator.


My next wish is that the fx-9910CW included the Algo mode (algorithm mode) that allowed small programs (via a mix of Scratch and Casio Basic). You can find out more details here:

https://edspi31415.blogspot.com/2025/08/casio-fx-92-college-plotting-lines.html


I just think the algorithm mode is neat, gives students an introduction to programming, and would have fit the fx-9910CW well.


Great job, Casio. I think Casio listened to calculator users and brought back these improvements, and brought it more in line with operating the fx-CG 100/Graph Math Plus. If you were hesitant about the fx-991CW, the fx-9910CW 2nd Edition is a good time to jump in.




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.













Saturday, November 1, 2025

fx-3650P and TI-68: Quadratic Equation and Arc Length between Roots of a Quadratic Curve

fx-3650P and TI-68: Quadratic Equation and Arc Length between Roots of a Quadratic Curve


Two approaches using two well-liked, classic calculators. The fx-3650P uses Basic like language while the TI-68 handles formulas.



Quadratic Equation


Solve for A x^2 + B x + C = 0, with the discriminant D = B^2 – 4 * A * C.


We know the solutions: X = (-B ± √(B² – 4 * A * C)) / (2 * A)


fx-3650P Program

? → A : ? → B : ? → C :

B² – 4 A C → D ◢

-B ÷ ( 2 A ) → M :

√ ( √ ( D² ) ) ÷ ( 2 A ) → Y :

D ≥ 0 ⇒ Goto 1 : M ◢ Y ◢ Goto 2 :

Lbl 1 : M + Y → X ◢ M – Y → Y ◢ Lbl 2


D: discriminant

If D<0; roots are in the form of M ± Yi

Else, the roots are real and are stored in X, Y


TI-68 Formula


X = 0 × A + (-B + √(B² – 4 × C × A) × J) ÷ (2 × A)


The 0 × A is added to force A to be prompted for first.

J = -1 for one root, J = 1 for the other

TI-68 takes care of both real and complex roots, no worries.

The coefficients can be complex!


Examples

A

B

C

D

Roots

2

-3

-9

81

3, -1.5

1

0

25

-100

5i, -5i

-48

64

28

9472

-0.347127088, 1.680464022



Arc Length of a Quadratic Equation between its Real Roots


Give roots X, Y: (t – X) * (t – Y) = t^2 – (X + Y )* t + X * Y

f(t) = t^2 – (X + Y) * t + X * Y

f’(t) = 2 * t – (X + Y)

arc = ∫( √(1 + f’(t)^2) dt


TI-68 will set up for the outside integral function, while the fx-3650P can use the integral function inside of the program.


We are going to assume that X < Y.


fx-3650P Program

? → A : ? → B : ∫ ( √ (1 + (2 X – A – B) ² ), A, B)


This is the direct approach.


TI-68 Formula

ARC = √(1 + (2 × X – A – B)²)


for X use the integral function (dx)

[ 3rd ] [ Σ+ ] (dx) [ = ]

Enter low, high, and the number of intervals.

The more intervals, generally, the more accurate the integral is.


Examples

I compared results against the fx-991CW.


A

B

TI-68, intv = 16

fx-3650P

fx-991 CW

2

9

26.070832160

26.070800000

26.070797720

0

5

13.903768900

13.904000000

13.903767950

-2

2

9.293567375

9.293568000

9.293567525



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 author does not use AI engines and never will.


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