Monday, June 6, 2022

Plus42: Integration in Solver

Plus42: Integration in Solver


The Plus42 adds an integral function to the solver engine.


Just a Reminder:  Get the Plus42 App


Author:  Thomas Okken


App: 

Android:  $9.99

iOS:  $9.99

PC/MacOS/Linux:  Free

Donations Accepted


Link:  https://thomasokken.com/plus42/


Plus42 ∫ Syntax


∫(EXPR:VAR:LLIM:ULIM[:ACC])


EXPR:  expression to be integrated


VAR:  variable to be integrated


LLIM: lower limit


ULIM:  upper limit


ACC:  accuracy factor, an optional argument.  If ACC is omitted, then Plus42 uses the highest accuracy factor.   


Let's take a look at some of the integrals that can be used.  In this blog, all results are rounded to four decimal places (FIX 4 is the default setting of Plus42)


Example 1:  Basic Integral


I = ∫(x^2 + 1 dx, x = 0, 3)


Solver syntax:

I=∫(X^2+1:X:1:6)


This integral calculates the numerical integral of x^2 + 1 from x = 1 to x = 6.   In calculation mode, pressing ( I ) twice would definitely get the result.  


Result:  I=76.6667


Example 2:  Variable Upper Limit


I = ∫(x^3/3 - 2 dx, x = 0, A),   A is the upper limit


Solver syntax:

I=∫(X^3÷3-2:X:0:A)


Upper limit known, find the integral:

A = 4;  result:  I = 13.3333


Integral known, find the upper limit:

I = 4;  result:  A = 3.3692 (it may take have time depending on the initial guess)


I like how the solver can find both the value of the integrals and solve for the limits of the integral.


Example 3:  Variable in the Integrand


I = ∫((x^2 * (x - B)) / (B^2 + x^2) dx, x = 0, 1),  B is a variable constant


Solver syntax:

I=∫((X^2×(X-B))÷(B^2+X^2):X:0:1)


B = 1; I = -0.0612

B = 3; I = -0.0784  (I set the initial guess of I = 0)


B can be solved for if you have a good guess and you are willing to wait for the solver to work.


I = -0.07; B = 3.6139


Full Precision:  3.613900797617638382718999085866498


Eddie 


All original content copyright, © 2011-2022.  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. 


Sunday, June 5, 2022

TI-84 Plus CE Python: Polygon Path (ppath.py)

TI-84 Plus CE Python:  Polygon Path (ppath.py)


Introduction


The program PPATH:


Between two points:  


1.  Calculates the required leftward, counter-clockwise angle.


2.  Calculates the distance to be traveled. 


The path starts at the origin (0,0).  You can create open paths or closed polygons.  For polygons, add another point and include (0,0) as the last point.  


TI-84 Plus CE Python Program:  PPATH - Python (ppath)


Download the TI-84 Plus CE Python file here:  https://drive.google.com/file/d/1QnPP9ikx45i7gAH22fTkFAmE-pBFQwTD/view?usp=sharing


Copy the code for a text file.  


print("Poly Path \nEdward Shore")

# 2022-04-27

from math import *

from turtle import *

t=Turtle()

# t is required for turtle

from ti_system import *


# hide the grid

t.hidegrid()


# obtain the points

x=[0]

y=[0]

# angles

g=[0]

# degree difference

q=[0]

# distance

d=[0]


print("Point 0: (0,0)")

print("#_0 to #_n-1")

n=eval(input("# points? "))


for i in range(1,n):  

  a=eval(input("x"+str(i)+"? "))

  b=eval(input("y"+str(i)+"? "))

  x.append(a)

  y.append(b)

  r=sqrt((a-x[i-1])**2+(b-y[i-1])**2)

  d.append(r)

  m=degrees(atan2(b-y[i-1],a-x[i-1]))

  v=m-g[i-1]

  if v<0:

    v+=360

  g.append(m)

  q.append(v)

  r6=round(r,6)

  m6=round(v,6)

  print("Distance: "+str(r6))

  print("Left Turn: "+str(m6)+"\u00b0")


print("\nPress [clear] to continue.")

disp_wait()


t.home()

t.pencolor(0,128,0)

# set speed

t.speed(4)

for i in range:

  t.left(q[i])

  t.forward(d[i])

t.done()


Notes:


1.  Turtle is a add-in module for the TI-84 Plus CE Python, which must be downloaded. Download the Turtle module here:  https://education.ti.com/en/product-resources/turtle-module/ti84ce-python


2.  Calling the Turtle module automatically assigns the variable t to a drawing turtle by the line t=Turtle().


3.  The ti_system module is exclusive to the TI-84 Plus CE.  This allows the program to pause with the disp_wait command.  


4.  The underscore character ( _ ) can be typed by the [ 2nd ] [ (-) ] (ans) sequence.  


5.  The hashtag character ( # ) can be typed by the [ 2nd ] [ 3 ] (L3) sequence.  


6.  The line for i in range(1,n) starts a for loop with i taking the values from 1 to n-1. This is good for lists when the initial point (point 0) does not need further processing. 


7.  The default operating angle measurement in Python is Radians.  


8.  The angle difference, which tells us how many degrees to turn left, is normalized to the 0°-360° range.   This is optional.   


9.  The line t.home() sets the turtle to point (0,0) and sets the turtle's orientation to 0° (facing right, forward on the x-axis).


10.  The line t.done() shows the results of the turtle commands. 


Examples


Example 1: Quadrilateral




Example 2:  An Open Path




Enjoy!  


Eddie 



All original content copyright, © 2011-2022.  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, June 4, 2022

TI-84 Plus CE, TI-Basic and Python: Dynamic and Goal Average

TI-84 Plus CE, TI-Basic and Python:  Dynamic and Goal Average 



Dynamic Average


The dynamic average is defined as:


Σx_i / m   from i = 1 to m, m ≤ n


A new list is created:


1st point has the value of the first data value,

2nd point has the value of the first two data values, 

3rd point has the value of the first three data values,

...

nth point is the arithmetic average of the entire list.


The TI-Basic Version plots the averages in a stat plot, while the Python version returns a list.


Remember:  In TI-Basic, the pointer starts at 1, while with Python, the pointer starts at 0.  Also, my Python programs will require you to enter the number of data points in advance. 


TI-84 Plus CE TI-Basic Program:  DYNAVG


"EWS 2022-04-18"

Input "DATA? ", L1   // [ 2nd ] [ 1 ]

seq(X,X,1,dim(L1),1)→L2   // [ 2nd ] [ 2 ]

cumSum(L1)/L2→L3   // [ 2nd ] [ 3 ]

Func: FnOff : PlotsOff

Plot1(Scatter,L2,L3)

ZoomStat


TI-84 Plus CE Python File: dynavg.py


# 2022-04-20 EWS


d=eval(input("# points? "))

x=[ ]

s=[ ]

a=[ ]


for i in range(d):

  w=eval(input("point "+str(i+1)+"? "))

  x.append(w)

  t=sum(x)

  s.append(t)

  v=t/(i+1)

  a.append(v)


print("cumulative sum:")

print(s)

print("dynamic average:")

print(a)


Example:


Input:  Data Points:  {4, 5.6, 3.9, 5.6, 5.7, 5.8, 7.2, 6.4}

Result: Dynamic Averages: {4, 4.8, 4.5, 4.775, 4.96, 5.1, 5.4, 5.525}





Goal Average


You have a goal, for example:  

*  reach a set number of steps

*  raise a set amount of revenue

*  score a set amount of points during a season of basketball


You have a set amount of times (days, months, years, etc.) (n) and you have a certain amount of data points (m).   Assuming you have time left in your program, what is the remaining amount needed and average per period left?  (This assumes that m < n).  


TI-84 Plus CE TI-Basic Program:  GOALAVG


"2022-04-18 EWS"

Input "GOAL? ", T

Input "TIMES? ", n

Input "DATA? ", L1

sum(L1)→S

dim(L1)→M

If S≥T

Then

Disp "GOAL MADE"

Else

T-S→D

D/(N-M)→A

Disp "TO GO =",D

Disp "AVG =",A

End


TI-84 Plus CE Python File: goalavg.py


# 2022-04-20 EWS


t=eval(input("Goal? "))

n=eval(input("# times? "))

m=eval(input("# data points? "))


s=0

x=[ ] 


for i in range(m):

  w=eval(input("point "+str(i+1)+"? "))

  x.append(w)

  s+=w


if s>=t:

  print("Goal made!")

else:

  d=t-s

  a=d/(n-m)

  print("To go: "+str(d))

  print("Average: "+str(a))


Example:


Input:  

Goal:  100,000

# Times:  14  (n)

# Data Points: 6  (m)

Data:  {5466, 8316, 8821, 9340, 6726, 8011}


Results:

To Go:  53539

Average:  6692.375




Eddie


All original content copyright, © 2011-2022.  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. 


Friday, June 3, 2022

Quick TI Thoughts

Quick TI Thoughts


Calculator Succession


TI-86 ->  TI-NSpire CX -> TI-NSpire CX II


TI-89 -> TI-NSpire CX CAS -> TI-NSpire CX II CAS


What do you think?   I think the TI-Nspire has more than a TI-84 Plus, at least in complex numbers and Boolean conversions.  


The CX II adds Python.  The non-CAS does neither have a computer algebra system nor an exact answer engine (can return answers in terms of pi or factor square roots).


------------------------------------


Also:  why do the TI-Nspire non-CAS and TI-84 Plus (CE) does not have an exact answer engine but the TI-36X Pro does?  


Future Dream Calculator?   The TI-84 Solar Edition:  basically the TI-36X Pro plus graphing, programming (at least TI-Basic).  The TI-36X Pro already has a battery backup. 


Eddie 



All original content copyright, © 2011-2022.  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. 


Monday, May 30, 2022

Plus42: The FOR Function

Plus42:  The FOR Function



About the Plus42 App


Author:  Thomas Okken


App: 

Android:  $9.99

iOS:  $9.99

PC/MacOS/Linux:  Free

Donations Accepted


Link:  https://thomasokken.com/plus42/


Please give Okken some love!   Free42 and Plus42 are both awesome apps and emulators, both emulate the HP 42S engine.  The Plus42 adds the solver of the HP 17B/19B/27S and unit conversions of the HP 48/49/50 family.   The Plus42 can also graph functions.   You can find a lot more information on the link above!


(Disclaimer:  I am not being paid.)


I am now including apps like the Plus42 in my rotation for blogs, please be on the look out for those.  


Today's blog entry will cover one of the additional solver functions for the Plus42:  FOR.


Plus42 FOR Syntax


FOR(INIT:COND:NEXT:EXPR)


INIT:  Initial commands


COND:  condition

If the condition is true:  execute EXPR (there can be more than one EXPR statements), then NEXT

If the condition is false:  the loop ends


NEXT:  next command,  this is where the counter variable is incremented or decremented


EXPR:  the main loop


Examples 


Example 1:  Add from 1 to 4.


HP 39G/Prime Code:

A:=0;

FOR K FROM 1 TO 4 DO  (STEP 1)

A:=A+K;

END;


Plus42 Equation Code:

S=FOR((L(A:0)+L(I:1))×0:G(I)≤4:L(I:G(I)+1):L(A:G(A)+G(I)))


Variables:

S = sum_final answer

A = sum

I = counter variable


Result:  S = 10


S=:   set the result to the variable S, S = A

INIT:  (L(A:0)+L(I:1))×0;  set A = 0 and I = 1

COND:  G(I)≤4;  test if I≤4; if true continue, if false exit the loop

NEXT:  L(I:G(I)+1); this happens at the end of the loop, this is like the general STEP incr/decr command

EXPR: L(A:G(A)+G(I))


The use of the Get function allows the variable to used automatically and not be displayed in the CALC menu.  


Something that threw me off is that the order of NEXT and EXPR, which the EXPR (which I think there could be more than one EXPR statements), I am used to NEXT either at the end of the FOR loop or implied (end of indentation in Python, for example).


Example 2:  Product


Calculate Π(n/4, n=1 to m) = 1/4 * 2/4 * 3/4 * ... * m/4


Plus42 Equation Code:

P=FOR((L(A:1)+L(N:1)+M)×0:G(N)≤IP(M):L(N:G(N)+1):L(A:G(A)×(G(N)÷4)))


Variables:

P = product_final answer

N = counter

M = higher limit


P=:   set the result to the variable P, P = A

INIT:  (L(A:1)+L(N:1)+M)×0; set A = 1, N = 1, ask for M

COND: G(N)≤IP(M); if N ≤ IP(M); if true continue, if false exit the loop

NEXT:  L(N:G(N)+1)

EXPR: L(A:G(A)×(G(N)÷4))


Results:

3 → M; P → 0.0938

6 → M; P → 0.1758

12 → M; P → 28.5507


Example 3:  Recursive


Given an initial condition u_0, calculate the recursion:


u_n = 2 * u_n-1 - 3


for n terms.


Plus42 Equation Code:

S=FOR((U+N+L(I:1))×0:G(I)≤N:L(I:G(I)+1):L(U:2×G(U)-3))


Variables:

S = final answer

U = recursive variable

N = number of terms


S=:  final answer

INIT:  (U+N+L(I:1))×0

COND: G(I)≤N

NEXT:  L(I:G(I)+1)

EXPR:  L(U:2×G(U)-3)


Results, enter U, N first before calculating for S:

2 → U, 3 → N; S → -5

5 → U, 2 → N; S → 11


Enjoy and hope this helps,


Eddie 


All original content copyright, © 2011-2022.  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. 

Sunday, May 29, 2022

HP 42S/DM42: Base Programs

 HP 42S/DM42:   Base Programs


Unsigned NOT


The program UNOT applies a NOT to a binary integer (flips zeros to ones and ones to zeros) using unsigned binary integers.  The number of bits (size) is prompted.


HP 42S/DM42 Program UNOT


00  {40-Byte Prgm}

01  LBL "UNOT"

02  BINM

03  "BIN?"

04  PROMPT

05  STO 01

06  EXITALL

07  "SIZE?"

08  PROMPT

09  STO 02

10  2

11  X<>Y

12  Y↑X

13  RCL- 01

14  STO 02

15  1

16  -  

17  BINM

18  END


Examples:


Unsigned NOT of 10100, size 5:  1011  (01011)


Unsigned NOT of 10100, size 8:  11101011


Shift Left


Makes a binary integer shift left: a zero is added to the right side of the integer and "drops" off the left most digit.  The number of bits (size) is prompted.  The binary number is assumed to be non-negative. 


HP 42S/DM42 Program SL16


00  {35-Byte Prgm}

01  LBL "SL16"

02  BINM

03  "BIN?"

04  PROMPT

05  EXITALL

06  2

07  ×

08  "SIZE?"

09  PROMPT

10  2

11  X<>Y

12  Y↑X

13  MOD

14  BINM

15  END


Examples:


Shift Left:  10100, size 5:  1000   (01000)


Shift Left:  10100, size 8:  101000  (00101000)


Shift Right (Logical)


Makes a binary integer shift right: a zero is added to the left side of the integer and "drops" off the left most digit.  The binary number is assumed to be non-negative. A logical shift right divides an integer by 2 and taking the integer result.


HP 42S/DM42 Program SR16


00  {24-Byte Prgm}

01  LBL "SR16"

02  BINM

03  "BIN?"

04  PROMPT

05  EXITALL

06  2

07  ÷

08  IP

09  BINM

10  END


Examples:


Shift Right:  10100:  1010


Shift Right:  1010:  101


The next two programs deals with RGB and HEX codes for computer colors.


HP 42S/DM42 Program CLR→:   RBG to Hexadecimal Code


00  {51-Byte Prgm}

01  LBL "CLR→"

02  DECM

03  "RED?"

04  PROMPT

05  65536

06  BASE×

07  "GREEN?"

08  PROMPT

09  256

10  BASE×

11  BASE+

12  "BLUE?"

13  PROMPT

14  BASE+

15  HEXM

16  END


Example:

Red: 221, Green: 80, Blue 109

Result:  HEX Code:  DD506D


HP 42S/DM42 Program  →CLR:   Hexadecimal to RGB Code


00  {63-Byte Prgm}

01  LBL "→CLR"

02  HEXM

03  "HEX CODE?"

04  PROMPT

05  STO 00

06  DECM

07  65536

08  BASE÷

09  STOP   // Red

10  65536

11  BASE×

12  RCL 00

13  X<>Y

14  BASE-

15  STO 00

16  256

17  BASE÷

18  STOP   // Green

19  256

20  BASE×

21  RCL 00

22  X<>Y

23  BASE-

24  END


Example:  

HEX Code:  103E22

Result:  Red:  16, Green:  62,  Blue:  34


Eddie



All original content copyright, © 2011-2022.  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 28, 2022

Casio fx-4000P: Orthonormal 2D Vector Test

Casio fx-4000P:  Orthonormal 2D Vector Test


Introduction


A set of vectors form an orthonormal basis if the vectors are mutually perpendicular and are of unit length.  


Mutual perpendicular means the dot product of two different vectors in the space is 0:


v_i ∙ v_j = 0,  i ≠ j


Unit length means that the norm of each vector is 1:


|v_i| = 1



 For two 2D vectors [ A, B ] and [ C, D ], the two vectors form an orthonormal basis if:


A^2 + B^2 = 1

C^2 + D^2 = 1

A * D + B * C = 0


Casio fx-4000P Program:  Orthonormal 2D Vector Test

Bytes:  84 steps

(line returns are included for readability)


"A":

?→A:

"B":

?→B:

"C":

?→C:

"D":

?→D:

A²+B²≠1⇒Goto 0:

C²+D²≠1⇒Goto 0:

AD+BC≠0⇒Goto 0:

"YES" ⊿

Goto 1:

Lbl 0:

"NO" ⊿

Lbl 1


Examples


Example 1:

[1, 0], [0, 1]

A = 1, B = 0, C = 0, D = 1


"NO"   (1*1 - 0*0 = 1)


Example 2:

[1/√2, 1/√2], [1/√2, -1/√2]

A = 1/√2, B = 1/√2, C = 1/√2, D = -1/√2


"YES"


Source:


Rowland, Todd. "Orthonormal Basis." From MathWorld--A Wolfram Web Resource, created by Eric W. Weisstein. https://mathworld.wolfram.com/OrthonormalBasis.html

Last Accessed April 7, 2022


Eddie 


All original content copyright, © 2011-2022.  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. 


Monday, May 23, 2022

Retro Review: Radio Shack EC-4026

Retro Review:   Radio Shack EC-4026







Quick Facts:


Model:  EC-4026

Company:  Radio Shack

Equivalent Of:  Casio fx-4500P, Casio fx-4500PA

Years:  1989-1991

Type:  Scientific, Programming

Batteries: 1 x CR-2025

Operating Mode:  Algebraic

Memory Registers: 26 (can be extended to 163 through the Defm command)

Program Steps:  1,103 (minimum of 7)

Number of Digits: 10 (display), 12 (precision)


Features


The Radio Shack EC-4026, a clone of the Casio fx-4500P, has a two line display.  On the top row shows formulas, equations, and prompts; and the bottom row displays results, and line numbers in programming mode.  


The modes of the EC-4026 include:


*  Angle Mode:  Degrees, Radians, Grads

*  Display Mode: Fix, Scientific Notation, Norm, Engineering Notation

*  Programming Write 

*  BASE-N:  base conversions and Boolean Logic.  Binary numbers have 32 bits, signed.

*  Linear Regression:  y = A + Bx

*  Single Variable Regression (SD:  Standard Deviation mode)


Extended Memory


By default, there are 26 memory registers, A-Z.   You can use the square brackets [ ] to refer to memory registers indirectly, with the syntax  letter[# registers from letter].


A[ 0 ]: A

A[ 1 ]: B

A[ 2 ]: C

A[ 3 ]: D

...

Z[ 0 ]:  Z


To extend the number of memory registers, execute [ MODE ] [ Ans ] and enter the number of extended memory registers. For example, Defm 10 extends the number of registers to 36, allowing for registers Z[ 1 ] to Z[ 10 ].


Defm 0 returns he number of registers to the default 26. 


Each extended memory costs 8 programming steps.


Independent Memory


The memory M is considered an independent memory with M+ and M- functions.


Formulas

 

In regular mode, we can store one formula (up to 127 steps) into memory with the IN command.  


Expressions can be entered.  If the expression is entered in the form of var=formula, the result is stored into the variable.   


The best part is that you can make prompts and result markers by adding a quoted comment next the variable.  


Use the OUT command to recall the formula and CALC command to run the calculation.


Example:


A"AREA"=π×R"RADIUS"²  [ IN ]


[ CALC ]

RADIUS?    (8.8)

AREA=     (243.2849351)


Integration


The integral command (∫) calculates the integrals of f(x) using Simpson's Rule.  


∫( f(X), low, high, n) 


n is an optional argument.  If n is included, the calculator uses 2^n partitions.  The maximum amount of partitions is 2^9 (512).   During calculation, the screen goes blank except for mode indicators.


Programming


The programming module is an early version of Casio basic.   Each program can have a file name.  The file names are sorted by chronologically.  In write mode, each line has a file number and a line number. (F# L#).  


Store calculations by using the syntax:


var=expressions


Variables can be either be defined (with their values) or undefined (the program will ask for the values each time a loop returns).   Define all the variables with the Fixm command.   We can undefine variables with the curly brackets { }.


The If structure is a little different, with the following symbols are used:


⇒  Then

≠⇒ Else  ( [ 2ndF ] [ a b/c ] )

◺ EndIf


(condition) ⇒ (do if true) : or ⊿ ≠⇒ (do if false) : or ⊿ ◺ (the if loop ends)


Subroutines, Pause (up to 4.5 seconds, with terms of half-seconds), and Goto/Labels (0-9, specific to each program) are included.  


The manual will also list a way to designate a program file as a data bank of names and their telephone numbers.


Sample programs follow.


Volume of a Frustum of a Cone:


Name:  FRUSTUM.CONE

F# L1  {H,Q,R}      // undefine H, Q, R

F# L2  H"HEIGHT"   // prompt for H with the prompt "HEIGHT?"

F# L3  Q"SMALL R" // prompt for Q with the prompt "SMALL R?"

F# L4  R"BIG R"  // prompt for R with the prompt "BIG R?"

F# L5  V"VOL"=H×(Q²+R²+Q×R)×π/3    // calculate volume, display V with "VOL="


Function Table


Name: TABLE

F# L1  {A,B,C}   // undefine A,B,C

F# L2  A"BEG"  // prompt for A with the prompt "BEG?"

F# L3  B"END" // prompt for B with the prompt "END?"

F# L4  N"POINTS" // prompt for N with the prompt "POINTS?"

F# L5  H=(B-A)/N

F# L6  X=A

F# L7  Lbl 0   // start the table

F# L8  X⊿   // display X

F# L9  F=2X-1⊿  // insert f(x) here (F=f(x))

F# L10  X=X+H

F# L11  X≤B⇒Goto 0:◺"FIN"  // if-then structure


Closing Thoughts


The EC-4026 is a great programming calculator.  The programming structure does present a learning curve due it being a beginning version of Casio basic.   


Sources


"Radio Shack EC-4026"  MyCalcDB.  April 21, 2014.   Last Accessed April 3, 2022.  http://mycalcdb.free.fr/main.php?l=0&id=4059


Toth, Viktor T.  "Casio fx-4500P"  rskey.org   2022.   Last Accessed April 3, 2022.  https://www.rskey.org/fx4500p


Toth, Viktor T. "Radio Shack EC-4026" rskey.org.  2022.  Last Accessed April 3, 2022.  https://www.rskey.org/ec4026


Until next time,


Eddie


All original content copyright, © 2011-2022.  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. 


Sunday, May 22, 2022

Converting a Line in Parametric Line to a Function Line

Converting a Line in Parametric Line to a Function Line 


From (x(t), y(t)) to y(x)


Express a line, presented in parametric form:


x = A * t + B

y = C * t + D


where A, B, C, and D are constants, and convert it to function form (y(x) or f(x)).


Here is one way to do this:


x = A * t + B

A * t = x - B

t = x / A - B / A


y = C * (x / A - B / A) + D

y = (C/A) * x - B*C/A + D

y = (C/A) * x + (D - B*C/A)


We know have a function in the slope-intercept form where:


slope = C/A


intercept = D - B*C/A


Casio fx-4000P Program:  Converting Parametric Lines to Functional Line

Size:  77 bytes

(line breaks added for readability)


"X=AT+B; A":

?→A:

"B":

?→B:

"Y=CT+D; C":

?→C:

"D":

?→D:

"SLOPE="⊿

C÷A→M⊿

"ITC="⊿

D-B×M→I


Examples


Graph screens are created by the Numworks emulator:  https://www.numworks.com/simulator/


Example 1:

x = 3 * t  - 4 

y = 2 * t + 8


A = 3, B = -4, C = 2, D = 8


Results:

SLOPE = 0.666666667

ITC = 10.66666667






Example 2:

x = -2 * t + 6

y = 4 * t + 3


A = -2, B = 6, C = 4, D = 3


Results:

SLOPE = -2

ITC = 15





Hope you find this useful.  Take care,


Eddie 


All original content copyright, © 2011-2022.  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 21, 2022

Swiss Micros DM41X and HP 41C: Numeric Derivatives

Swiss Micros DM41X and HP 41C:  Numeric Derivatives


Introduction


The program DFX calculates one of three types of derivative:


1.  Normal Derivative   (DX)

2.  Logarithmic Derivative (LN)

3.  Power Derivative (PWR)


Where:


Normal Derivative:  f'(x)


Logarithmic Derivative:  d/dx( ln f(x) ) = f'(x) / f(x)  


Power Derivative:  d/dx( f^n(x) ) = n * f^(n-1)(x) * f'(x),  n doesn't have to be an integer


where f'(x) is estimated by:


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


Variables:  x, h


The program uses a subroutine FX, see the examples for details.  


DM41X and HP 41C Program:  DFX


Uses program FX as a subroutine as f(x).


01 LBL ^T FX

02 RCL 01

03 ^T X?

04 ARCL 01

05 PROMPT

06 STO 01

07 RCL 02

08 ^T H?

09 ARCL 02

10 PROMPT

11 STO 02

12 RCL 01

13 XEQ ^T FX

14 RCL 03

15 RCL 01

16 RCL 02

17 +

18 XEQ ^T FX

19 RCL 03

20 -

21 RCL 02

22 /

23 STO 04

24 ^T 1 DX 2 LN 3 ↑N

25 PROMPT

26 INT

27 STO 05

28 GTO IND 05


29 LBL 01

30 RCL 04 


31 LBL 02

32 RCL 04

33 RCL 03

34 / 

35 GTO 04


36 LBL 03

37 RCL 03

38 ^T N?

39 PROMPT

40 1

41  - 

42 Y↑X

43 LASTX

44 1

43 +

44 *

45 RCL 04

46 *


50 LBL 04

51 RTN



The function FX:


x is loaded in the X stack register (and on display)


01 LBL ^FX

02  execute f(x)

...

##  RTN


For DFX, do not use R01, R02, R03, R04, and R05 in FX.  


Notes:


Sequences such as:

02 RCL 01

03 ^T X?

04 ARCL 01

05 PROMPT


Puts the prompt as X? [contents of R1].   If you want the previous value, press R/S.  Otherwise enter a new value, then press R/S.


This program uses indirect goto statements.  R05 is used to hold the person's choice and uses it to direct which label is executed.


Examples


Example 1:  f(x) = x * sin x


Set FX as:

01 LBL^T FX

02 RAD

03 ENTER

04 ENTER

05 SIN

06 * 

07 RTN


Setting H to 10^-6  (1E-6):


DF:   f'(x)

x = 0.5, Result:  0.9182; x = 1.6, Result: 0.9530


LN:  ln f'(x)

x = 0.5, Result:  3.8305; x = 1.6, Result:  0.5959


PWR: with n = 3,   (f'(x))^3

x = 0.5; Result:  0.1583; x = 1.6;  Result: 7.3128



Example 2:  f(x) = x^2 + 3 * x + 1 = x * (x + 3) + 1


Set FX as:

01 LBL^T FX

02 ENTER

03 ENTER

04 3

05 +

06 *

07 1

08 + 

09 RTN


Setting H to 10^-6  (1E-6):


DF:   f'(x)

x = 3.2, Result:  9.4000; x = 6.8, Result: 16.6000


LN:  ln f'(x)

x = 3.2, Result:  0.4511; x = 6.8, Result: 0.2454


PWR: with n = 1.5,   (f'(x))^1.5

x = 3.2, Result:  64.3677; x = 6.8, Result: 204.7864



Until next time, 


Eddie


All original content copyright, © 2011-2022.  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. 


DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues The programs are listed for the Swiss Micros DM42 an...