Showing posts with label TI-84 Plus CE Python. Show all posts
Showing posts with label TI-84 Plus CE Python. Show all posts

Saturday, May 16, 2026

Python (TI-84 Plus CE) and Swiss Micros DM32: The Integral of y = abs(r * x + s)

Python (TI-84 Plus CE) and Swiss Micros DM32: The Integral of y = abs(r * x + s)




The Integral of y = abs(r * x + s)



This algorithm calculates the integral of ∫ abs(r * x + s) dx, from x = a, x = b), where r and s are constants. For clarity, I am using abs to stand for absolute value instead of the customary pipe characters (|x|).



Let the function y = abs(r * x + s). Then the function can be defined as a piecewise function (without loss of generality):

y =

{ -(r * x + s), x < xc

{ (r * x + s), x ≤ xc



The point x = xc is the critical point because it is the root (zero) of this function:

abs(r * x + s) = 0

Because abs(0) = 0:

r * x + s = 0

r * x = -s

x = -s/r



and:

-(r * x + s) = 0

r * x + s = 0

x = -s/r



Let the critical point xc = -s/r



Taking the indefinite integral of y(x) yields:

∫ y(x) dx =

{ -r * x^2 ÷ 2 – s * x + C, x < xc

{ r * x^2 ÷ 2 + s * x + C, x ≥ xc

and C is an arbitrary integration constant.



Let f(x) = r * x^2 ÷ 2 + s * x and find the definite integral from x = a to x = b.



Case 1: a ≥ xc and b ≥ xc, where both a and b are greater than the critical point. This is the simplest case.



∫ ( r * x + s dx, x = a to x = b)

= (r * b^2 ÷ 2 + s * b) - (r * a^2 ÷ 2 + s * a)

= f(b) – f(a)



Case 2: a < xc and b < xc, both a and b are less than the critical point.

∫ ( r * x + s dx, x = a to x = b)

= -(r * b^2 ÷ 2 + s * b) - -(r * a^2 ÷ 2 + s * a)

= -(r * b^2 ÷ 2 + s * b) + (r * a^2 ÷ 2 + s * a)

= (-r * b^2 ÷ 2 - s * b) + (r * a^2 ÷ 2 + s * a)

= -f(b) + f(a)

= -(f(b) - f(a))



Combining cases 1 and 2, the area can be calculated as:

area = abs(f(b) – f(a))

with (a – xc) * (b – xc) ≥ 0



Case 3: a < xc and b ≥ xc

∫ ( r * x + s dx, x = a to x = b)

= ∫ ( -(r * x + s) dx, x = a to x = xc) + ∫ ( r * x + s dx, x = xc to b)

= -(r * xc^2 ÷ 2 + s *xc) + (r * a^2 ÷ 2 + s * a) + (r * b^2 ÷ 2 + s * b) – (r * xc^2 ÷ 2 + s * xc)

= -f(xc) + f(a) + f(b) – f(xc)

= f(a) – 2 * f(xc) + f(b)

Since area must be positive: abs(f(a) – 2 * f(xc) + f(b)).

Consequently: (a – xc) * (b – xc) < 0.



In summary:

Let xc = -r/s

If (a – xc) * (b – xc) ≥ 0: area = abs(f(b) – f(a))

Else if (a – xc) * (b – xc) < 0: area = abs(f(a) – 2 * f(xc) + f(b))

where f(x) = r * x^2 ÷ 2 + s * x



Please note: ∫ abs(r * x + s) dx ≠ abs(a * x^2 ÷ b * x)



TI-84 Plus CE Python Edition: abslin1.py



Programmed with TI-84 Plus CE Python, but can be used on any calculator with Python since only the math module is used.



# Math Calculations
from math import *

# Python Version
# 2026-01-05 EWS

print("integral of abs(rx+s)")
r=eval(input("r? "))
s=eval(input("s? "))
a=eval(input("lower limit? "))
b=eval(input("upper limit? "))

# critical point
c=-s/r

# integral
f=lambda x:r*x**2/2+s*x
f0=f(c)
f1=f(a)
f2=f(b)

if (a-c)*(b-c)>=0:
  t=abs(f2-f1)
else:
  t=abs(f1-2*f0+f2)

print("area = ",str(t))



Swiss Micros DM32 Program: asblin



Three labels are used: A (172 bytes), Z (20 bytes), Y (17 bytes), total 209 bytes

Text strings can be eliminated.



A01 LBL A

A02 SF 10

A03 “AREA ABS(RX +S)”

A04 INPUT R

A05 INPUT S

A06 x<>y

A07 ÷

A08 +/-

A09 STO C

A10 XEQ Y

A11 STO D

A12 “LOW=A HIGH=B”

A13 INPUT A

A14 XEQ Y

A15 STO E

A16 INPUT B

A17 XEQ Y

A18 STO F

A19 RCL B

A20 RCL- C

A21 RCL A

A22 RCL- C

A23 ×

A24 x≥0?

A25 GTO Z

A26 RCL E

A27 RCL D

A28 2

A29 ×

A30 -

A31 RCL+ F

A32 ABS

A33 STO Z

A34 CF 10

A35 RTN



Z01 LBL Z

Z02 RCL E

Z03 RCL- F

Z04 ABS

Z05 STO Z

Z06 CF 10

Z07 RTN



Y01 LBL Y (Note: f(x) = r*x^2 ÷ 2 + s*x)

Y02 ENTER

Y03 x^2

Y04 RCL× R

Y05 2

Y06 ÷

Y07 x<>y

Y08 RCL× S

Y09 +

Y10 RTN



Examples



Example 1:

y = abs(4 * x + 3)

r = 4, s = 3, xc = -0.75





Lower Limit (a)

Higher Limit (b)

Area

-4

5

87.25

-4

-1

21

0

5

65



Example 2:

y = abs(-3 * x + 6)

r = -3, s = 6, xc = 2



Lower Limit (a)

Higher Limit (b)

Area

-5

5

87

3

5

12

-5

1

72


Hope you find this helpful and have a great day,


Eddie


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, May 2, 2026

TI-84 Plus CE, HP 15C, and HP 12C: Decoding the Gradematic 100

TI-84 Plus CE, HP 15C, and HP 12C: Decoding the Gradematic 100





GPA as a function of grade



Last December, we have gave a spotlight on the Calculated Industries 100 from 1983. The Gradematic 100 was a specialty calculator that determines the GPA average for a student or a bunch of students in a class. We can either use numerical grades, where the maximum total score and the minimum passing grade (better than E (or F)) are set, or letter grades, where the letters are given an approximated. To see the review, click the link below:



https://edspi31415.blogspot.com/2025/12/spotlight-calculated-industries.html



Using the standard grade scale for a single assignment, with a perfect score being 100 and the minimum passing grade is 60, the following scores are given the GPA:



GRADE (0 – 100)

GPA

Letter Grade Given by Gradematic 100

0

0.00

E (can stand for F)

10

0.08

E (can stand for F)

20

0.16

E (can stand for F)

30

0.25

E (can stand for F)

40

0.33

E (can stand for F)

50

0.41

E (can stand for F)

55

0.45

E (can stand for F)

60

0.50

D-

65

1.00

D

70

1.50

C-

75

2.00

C

80

2.50

B-

85

3.00

B

90

3.50

A-

95

4.00

A

100

4.50

A+



Plot of values (using a TI-84 Plus CE):







As we can see, the plot consists of two line segments: one where grades value from 0 to 60, and one where grades value from 60 and higher. It is apparent that that the two parts makes a piece-wise function consisting of two lines.






Note: the graphs and statistics were done with the TI-84 Plus CE Python (will work with any TI-84 CE family). The piecewise function is from the math-math menu.



The Gradematic 100 distributes the GPA as:

E: 0.00 (or F)

D+: 1.33

C+: 2.33

B+: 3.33

A+: 4.33

D-: 0.66

C-: 1.66

B-: 2.66

A-: 3.66


D: 1.00

C: 2.00

B: 3.00

A: 4.00




Note: The distributed GPA scales will vary among the school districts and systems. However, we will assume the system that matches the default 60/100 system.



HP 15C and HP 12C: Find the GPA given numeric grade



HP 15C Code:

LBL C

001

42, 21, 13

6

002

6

0

003

0

x≤y

004

43, 10

GTO 1

005

22, 1

2

006

2

×

007

20

÷

008

10

RTN

009

43, 32

LBL 1

010

42, 21, 1

CL x

011

43, 35

1

012

1

0

013

0

÷

014

10

5

015

5

.

016

48

5

017

5

-

018

30

RTN

019

43, 32



HP 12C Code:



6

01

6

0

02

0

x≤y

03

43, 34

GTO 09

04

43, 33, 09

2

05

2

×

06

20

÷

07

10

GTO 00

08

43, 33, 00

CL x

09

35

1

10

1

0

11

0

÷

12

10

5

13

5

.

14

48

5

15

5

-

16

30

GTO 00

17

43, 33, 00



Eddie





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, March 21, 2026

TI-83 Premium CE Edition Python and Casio fx-92 Collège: Graphing Roses

TI-83 Premium CE Edition Python and Casio fx-92 Collège: Graphing Roses


Introduction


The scripts presented today will draw a rose with the following polar equation:


r = a * cos(n * Θ)


If n is odd, then the rose will have n petals, but if n is even, then the rose will have double the petals (2*n petals).



TI-83 Premium CE Edition Python (and TI-84 Plus CE Python): ROSE84.PY


from math import *

from turtle import *

t=Turtle()

t.clear()

t.hidegrid()

t.hideturtle()

t.pencolor(255,0,0)


# set pedal length

a=100

t.penup()

t.goto(a,0)


# ask for pedals

print(“** rose **”)

print(“odd n: n pedals”)

print(“even n: 2*n pedals”)

n=eval(input(“n? “))

t.clear()


# draw

t.pendown()

for i in range(129):

  # theta

  m=i/128*2*pi

  # r

  r=a*cos(n*m)

  t.goto(r*cos(m),r*sin(m))

t.done()






Casio fx-92 Collège: Graphing a Rose


Note: The instructions are in French.


INSTRUCTION

DETAIL

ENGLISH TRANSLATION

Style Criox


Cross Cursor Style

? → B

Demander valuer B

Input B

20 → A

Metrire var á 20 → A

Set A = 20

Aller á x = A; y = 0


Goto (A, 0)

Stylo écrit


Pen down

Répéter 128


Repeat 128 times (loop):

C ÷ 128 × 2 × Ï€ → D

Metrire var á C ÷ 128 × 2 × Ï€ → D

Set D = C/128*2*Ï€

A × cos((B × D)^r) → E

Metrire var á A × cos((B × D)^r) → E

Set E = A*(cos(B*D)), B*D is in radians.

Aller à x=E×cos(D^r); y=E×sin(D^r)


Goto (E * cos D, E * sin D). D is in radians.

C + 1 → C

Metrire var á C + 1 → C

Set C = C + 1


End of loop


Note: To designate a measure of an angle to be radians regardless of calculator setting, press [ CATALOG ] >> Angl/Coord/Sexag >> Radians.






Drawing roses on the first day of spring,



Eddie


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.

Python – Earth’s Radius and Gravity in US Units

Python – Earth’s Radius and Gravity in US Units Introduction The following script, gravus2.py, estimates the Earth’s gravity i...