Showing posts with label quadratic formula. Show all posts
Showing posts with label quadratic formula. Show all posts

Saturday, June 5, 2021

7000G Retro Month - June 5 Edition

7000G Retro Month - June 5 Edition





Introduction


Welcome to the 7000G Retro Month, which features programming for the classic Casio calculators from the mid/late 1980s:  primarily fx-7000G and fx-7500G.  Since the programming language stays similar throughout the years, programs can be translated to the fx-6300G and later graphing calculators with little to no adjustments.  Non graphic programs should be ported to the fx-4000P, fx-4500P (A), fx-3650p (II), fx-50F Plus (II), and fx-5800P with little to no adjustments.  


7000G Retro Month takes place every Saturday during June 2021.


To make text easier to type, I can going to use the following text friendly symbols for the following:


->  for →


/I for ⊿


=> for ⇒


What do you think?   Unicode or simple text equivalents?  


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


Today's subject revolves around General Mathematics.  Enjoy!


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



Day Number of the Year


Returns the day number of a year, with January 1 being Day 1 and December 31 being day 365 (or 366 on leap years).  For LEAP? enter 0 for non leap years or 1 for leap years.   


"MONTH"? -> M

"DAY"? -> D

"LEAP"? -> L

M≤2 => D+Int(30.6M+368.8)-399 -> N

M>2 => D+Int(30.6M+1.6)-34+L -> N


Arithmetic-Geometric Mean


The arithmetic-geometric mean of two positive numbers x and y is a convergence of repeated means:


Arithmetic:  a = (x + y)/2

Geometric:  g = √(x y) 


Tolerance:  decimal to determine desired accuracy.  For example, to eight decimal places, set tolerance to 1E-8.  


"AGM"

"A0"? -> X

"G0"? -> Y

"TOL"? -> T

Lbl 1

(X+Y)÷2 -> A

√(XY) -> G

A -> X : G -> Y

Abs (A-G) ≥ T => Goto 1

A /I

G


The final A and G are displayed to show the convergence.  


Now for two classics.


Determinant of a 3 x 3 Matrix


Here the program makes use of the square brackets and indirect storage.  Yes, indirect storage and recall are possible with the fx-7000G and fx-7500G.  Of course, this program is not necessary in later graphing calculators.


A[0] = A

A[1] = B

A[2] = C

A[3] = D

A[4] = E

A[5] = F

A[6] = G

A[7] = H

A[8] = I


Elements are entered left to right, completing row by row.


The determinant is stored in the variable T.


The Isz command is used to increment K by 1.  Since K starts at 0 and K increases by 1 before comparing it, the next command is never going to be skipped.


"3 X 3 DET"

0 -> K

Lbl 1

? -> A[K]

Isz K

K < 9 => Goto 1

A(EI-FH)-B(DI-FG)+C(DH-EG) -> T


Quadratic Formula


I would consider this the "Hello World" of mathematics programs.   


Ax^2 + Bx + C = 0


Let D be the discriminant:  D = B^2 - 4AC.   D is displayed where you can determine the characteristics of the roots:


D ≥ 0:  roots are real, stored in X and Y

D < 0:  roots are complex, that take the form of X + Yi, X - Yi


"A"? -> A

"B"? -> B

"C"? -> C

B^2-4AC -> D /I

D<0 => Goto 1

(-B+√D)÷(2A) -> X

(-B-√D)÷(2A) -> Y

Goto 2

Lbl 1

-B÷(2A) -> X

√ Abs D ÷(2A) -> Y

Lbl 2

X /I Y


Eddie


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

Sharp EL-5100 Programs

 Sharp EL-5100 Programs



We can use the formula programming engine of the classic Sharp EL-5100 (1979) to store multiple formulas and invoke some simple programs.

Quadratic Formula

ax^2 + bx + c = 0

x = (-b ± √(b^2 - 4ac)) / (2a)

Formulas (AER Mode):

1; f(A,B,C)=(B²-4AC) STO D ◣
2; (-B+√D)÷(2A STO E, (-B-√D)÷(2A STO F

Instructions (COMP Mode):

1.  Press [ 1; ], enter A, B, and C.   D is shown as ANS 1.  If D ≥ 0, then the polynomial have real roots.  Continue to the next step.  If D < 0, then the polynomial has complex roots, stop. 
2.  Press [ 2; ], the two roots are displayed.

Examples:

Example 1:  A = 1, B = -1, C = -3.75;  Results:  2.5, -1.5

Example 2:  A = 2, B = 26, C = 84; Results:  -6, -7


Power of a Complex Number (Principal)

(a + bi)^c  = d + ei   

The →POL stores θ in I and displays r, which r is not automatically stored.

Formulas (AER Mode):

1; f(A,B,C)=A →POL B STO I, I^C×COS(JC) STO D, I^C×SIN(JC) STO E

^ represents Y^X.  

Instructions (COMP Mode):

1.  Set the calculator to Radians mode.  Press [ 1; ]. 
2.  You get three results:  I  (r), real part, imaginary part.   Press [ COMP ] to see each result (ignore the first result)

Examples:

Example 1:  (4 + 4i)^3 = -128 + 128i;  r = 5.56854249

Example 2:  (5 - 6i)^0.5 = 2.5308348108 - 1.18537961766i;  r = 7.810249676

Confidence Interval

Here, we can use one formula to store values for use in the next formula.

confidence interval = A ± J * B / √C

where:
A = mean
B = variance
C = n
J = z*  (see table below)

z* values:
F:  99% confidence level, value = 2.576
G: 98% confidence level, value = 2.326
H: 95% confidence level, value = 1.96
I:  90% confidence level, value = 1.645

Formulas (AER Mode):

1;  2.576 STO F 2.326 STO G 1.96 STO H 1.645 STO I ◣
2;  f(A,B,C,J)=A-JB÷√C STO D, A+JB÷√C STO E

Instructions (COMP Mode):

1.  Initialize by pressing [ 1; ].  When the display says ANS1 = 0, the initialization is complete.
2.  Press [ 2; ], enter mean for A, press [ COMP ], enter variance for B, press [ COMP ], enter n for C, press [ COMP ], choose F, G, H, or I for J (confidence level), press [ COMP ].

Examples:

Example 1:
99% level with mean = 34.56, variance = 19.79, n = 53.  For 99%, enter F for J.
Result: 22.557490316, 41.562509684

Example 2:
90% level with mean = 100, variance = 12, n = 42.  For 90%, enter I for J.
Result:  96.9540518717, 103.045948128

Sum of a Function

On the EL-5100, we will have to manually keep track of the loop.

∑ f(I) from I=A to B (increment 1), result is stored in M.


Formula Template (AER Mode):

1;  f(I)= STO I, 0 →M ◣
2; [enter function here] M+, 1+I STO I

Instructions (COMP Mode):

1.  Press [ 1; ].  At the f(I)= prompt, store the lower limit.  Press [ COMP ] twice to complete the initialization.  
2.  Press [ 2; ].   The first result is f(I).  Press [ COMP ] to increase I by 1.  Repeat the pattern by pressing [ COMP ]. Do this until ANS2 > B (you need to keep track manually)
3.  Press [ RM ] to get the final result.

Example:  

∑( (I-2)×(I+6) ) for I=1 to 5

Setup (AER Mode):

1;  f(I)= STO I, 0 →M ◣
2;  (I-2)×(I+6) M+, 1+I STO I

[1; ] [COMP] [COMP]
[2; ] [COMP] [COMP]  ANS2 = 2
[2; ] [COMP] [COMP]  ANS2 = 3
[2; ] [COMP] [COMP]  ANS2 = 4
[2; ] [COMP] [COMP]  ANS2 = 5
[2; ] [COMP] [COMP]  ANS2 = 6
[ RM ]

Result: 55

Fun to explore different ways to solve problems, and play with retro calculators. 

Eddie

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

Tuesday, March 26, 2019

HP 17BII and HP 27S: Quadratic Formula

HP 17BII and HP 27S:  Quadratic Formula


The following solver equations solve the quadratic equation

A*x^2 + B*x + C = 0

by the famous Quadratic Formula

x = (-B ± √(B^2 - 4*A*C) ) / (2*A)

Define D as the discriminant:  D = B^2 - 4*A*C

If A, B, and C are real numbers and:

D<0, the roots are complex conjugates

D≥0, the roots are real roots

Quadratic Equation:  Real Roots Only

QUAD:X=INV(2*A)*(-B+SQRT(B^2-4*A*C)*SGN(R#))

Input Variables:
A:  coefficient of X^2
B:  coefficient of X
C:  constant
R#:  -1 or 1

Output Variables: 
X:  root

Example:  2X^2 + 3X - 5 = 0

Input:
A: 2
B: 3
C: -5
R#: 1 (or any positive number)

Output:
X = 1

Input:
R#: -1

Output:
X = -2.5

Quadratic Equation:  Real or Complex Roots
(Let (L) and Get (G) functions required)

QUAD:0*(A+B+C+L(D:B^2-4*A*C)+L(E:2*A))
+IF(S(X1):IF(D<0:-B÷G(E):(-B+SQRT(D))÷G(E))-X1:0)
+IF(S(X2):IF(D<0:SQRT(ABS(D))÷G(E):(-B-SQRT(D))÷G(E))-X2:0)

 Input Variables:
A:  coefficient of X^2
B:  coefficient of X
C:  constant

Output Variables:
D:  Discriminant 
If D<0:  X1:  real part, X2:  imaginary part
If D≥0:  X1:  real root 1, X2:  real root 2

Example 1:  -3*X^2 + 8*X - 1= 0

Input:
A: -3
B: 8
C: -1

Output:
D = 52
X1 = 0.1315
X2 = 2.5352

Roots:  x = 0.1315, x = 2.5352

Example 2:  3*X^2 + 5*X + 3 = 0

Input: 
A: 3
B: 5
C: 3

Output:
D = -11
X1 = -0.8333
X2 = 0.5528

Roots:  x = -0.8333 ± 0.5528i

Eddie

All original content copyright, © 2011-2019.  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, March 20, 2016

Programming with the PrgCalcPro iOS App




App Creator: SekApps
Price: I paid $0.99
Platform: iOS
Memory: 1,000 steps with 100 registers 

The PrgCalcPro is based on the Russian scientific calculator Elektronika MK-61.  The MK-61 was in production from 1981 to 1993.  Originally the MK-61 had 15 memory registers and 105 steps.  There are Boolean operations but no built in statistics mode.   

The PrgCalcPro and MK-61 operated by Reverse Polish Notation (RPN), like the Hewlett Packard calculators.  The calculator has 4 stacks. 

The PrgCalcPro has more English key labels instead of Russian.  You can find notes of the MK-61 here:

http://www.thimet.de/CalcCollection/Calculators/Elektronika-MK-61/CmdRef.html


Programming Notes:

M is STO, R is RCL.  There are 15 readily accessible memory registers available from the keyboard:  0-9, a, b, c, d, and e. 

Angle mode is determined by a manual switch.  Unfortunately it can't be programmed (I don't think).  

Certain symbols are used:
[x] Integer Part
{x} Fractional Part
MAX. The maximum of y and x. 
SIG.  Sign of x
Bx. Last X recall. 
lg Common logarithm (base 10, LOG)
tg Tangent function (TAN)
A small recycling symbol ([ F ], [ . ]) represents the Roll Down function. 
<--> represents the exchange function (X<>Y)
x^y: Power function where the base is on the x stack and the exponent is on the y stack.  The exponent remains of the y stack upon calculation and is not "consumed".  

This blog entry will have basic programs, and additional programs will follow on the next few blog entries.  


Eccentricity of an Ellipse
a ≥ b, b is entered first

0: 13  ;  /
   1: 22  ;  X^2
   2: 0B  ;  +/-
   3: 01  ;  1
   4: 10  ;  +
   5: 21  ;  sqr \\ √ 
   6: 50  ;  STOP


The Average of Non-Zero Numbers

Keep entering numbers using n, [RUN].  When you are done, enter 0, [RUN].  The display will show sum (memory 0), press [RUN] to get the number of points (memory 1), and finally press [RUN] to get the average.  

Notes:
The tests for the ProCalcPro (and the MK-61) work slightly differently from Hewlett Packard RPN programming calculators.  

Format:
Test ( x<0, x=0, x≥0, x≠0)
Code Number (00-99), or label
Do this next command instead of test is true 

Example:
x≠0
15
R, 0
+

If the number in the display is non-zero (test is true), then recall memory register 0 and add the number to it.  If the number is zero (test is false), skip to line 15.  

Thanks to thimet.net.  http://www.thimet.de/CalcCollection/Calculators/Elektronika-MK-61/CmdRef.html

Program:   
0: 40  ;  M0
   1: 01  ;  1
   2: 41  ;  M1
   3: 50  ;  STOP
   4: 57  ;  X!=0 \\ X≠0
   5: 15 \\ Goto line 15 if X is zero
   6: 60  ;  R0
   7: 10  ;  +
   8: 40  ;  M0
   9: 61  ;  R1
  10: 01  ;  1
  11: 10  ;  +
  12: 41  ;  M1
  13: 51  ;  JMP \\ Goto line 03 (the next code is a step code number)
  14: 03
  15: 60  ;  R0
  16: 50  ;  STOP
  17: 61  ;  R1
  18: 50  ;  STOP
  19: 13  ;  /
  20: 50  ;  STOP

Quadratic Formula

Equation: Ax^2 + Bx + C = 0
Determinant: D = B^2 - 4AC
Roots:  -B/(2A) ± √(D)/(2A)

Store A, B, and C in the a, b, and c registers respectively.  
Register a: [ . ]
Register b: [ +/- ]
Register c: [ EXT ]

Output Registers:
D = determinant
Memory 0 = root 1 if D ≥0, real part if D < 0
Memory 1 = root 2 if D ≥ 0, imaginary part if D < 0
Complex Roots Format: M0 ± i*M1

   0: 6B  ;  RB // RCL B
   1: 22  ;  X^2
   2: 04  ;  4
   3: 6A  ;  RA
   4: 12  ;  *
   5: 6C  ;  RC
   6: 12  ;  *
   7: 11  ;  -
   8: 4D  ;  MD // STO D
   9: 50  ;  STOP // determinant
  10: 59  ;  X>=0 // if X≥0 Goto line 12, else Goto line 28
  11: 28
  12: 21  ;  sqr // finding the real roots, sqr = √ 
  13: 0E  ;  ^
  14: 6B  ;  RB
  15: 11  ;  -
  16: 53  ;  SUB // execute subroutine located at line 41
  17: 41
  18: 40  ;  M0
  19: 50  ;  STOP
  20: 14  ;  XY
  21: 0B  ;  +- // CHS
  22: 6B  ;  RB
  23: 11  ;  -
  24: 53  ;  SUB
  25: 41
  26: 41  ;  M1
  27: 50  ;  STOP
  28: 31  ;  abs // complex roots
  29: 21  ;  sqr
  30: 6B  ;  RB
  31: 0B  ;  +-
  32: 53  ;  SUB
  33: 41
  34: 40  ;  M0
  35: 50  ;  STOP
  36: 14  ;  XY
  37: 53  ;  SUB
  38: 41
  39: 41  ;  M1
  40: 50  ;  STOP
  41: 6A  ;  RA // subroutine 
  42: 02  ;  2
  43: 12  ;  *
  44: 13  ;  /
  45: 52  ;  RET // return 


This blog is properly of Edward Shore.  2016. 



Sunday, October 12, 2014

New Video: Four-Function Calculator Tricks

With a four-function calculator you can:

* add fractions
* square numbers
* find the area of a circle
* solve quadratic equations
* solve 2 x 2 linear systems


and more!


http://youtu.be/PgjDZ-yi1_Y

Enjoy!  Eddie


This blog is property of Edward Shore - 2014.

 

Sunday, June 29, 2014

Solving y = a*x^2 + b*x + c for x whether y is zero or not.



How to solve y = a*x^2 + b*x + c for x for when y is not necessarily zero.  We can solve for x algebraically using various methods. 

Method 1:  Completing the Square

y = a*x^2 + b*x + c

Divide both sides by a:
y/a = x^2 + b/a * x + c/a

Add  b^2/(4*a^2) to both sides. 
Note that (x + b/(2*a))^2 = x^2 + b/a * x + b^2/(4*a^2).

y/a + b^2/(4*a^2) = x^2 + b/a * x + b^2/(4*a^2) + c/a
y/a + b^2/(4*a^2) = (x + b/(2*a))^2 + c/a
y/a + b^2/(4*a^2) – c/a = (x + b/(2*a))^2

Solving for x gives:
x + b/(2*a) = ±√( y/a + b^2/(4*a^2) – c/a )
x = b/(2*a) ±√( y/a + b^2/(4*a^2) – c/a )

Method 2:  Quadratic Formula

The quadratic formula requires that the polynomial is equal to zero.  Hence:

y = a*x^2 + b*x + c
0 = a*x^2 + b*x + c – y

The constant term is c – y.  By the quadratic formula:

x = (-b ± √(b^2 – 4*a*(c-y))/(2*a)
x = (-b ± √(b^2 – 4*a*c + 4*a*y))/(2*a)

In the term with the square root, divide b^2 – 4*a*c + 4*a*y by 4*a^2:
x = (-b ± √(b^2/(4*a^2) – c/a + y/a))/(2*a)


Hope this helps,

Eddie

This blog is property of Edward Shore.  2014.

Monday, December 3, 2012

Numeric CAS - Part 7: Quadratic Equation

Quadratic Formula

Ax² + Bx + C = 0

Where x = (-B ± √(B² - 4AC)) / (2A)

This is just the popular quadratic formula, except this set of programs allow for complex A, B, and C. (Unlike the Solver applications).

Example:
A = 2 - i
B = -6
C = 14i

x1 ≈ -0.9873 + 1.551i
x2 ≈ 3.3873 - 0.3509i


Casio Prizm:

QUADSLV
Quadratic Equation - Complex Coefficients Allowed
11/23/2012 - 124 bytes

a+bi
"AX²+BX+C=0"
"A"? → A
"B?"→ B
"C?"→ C
√(B²-4AC) → X
(-B - X) ÷ (2A)→ R
(-B + X) ÷ (2A) → S
"X=R Or X=S"
R ◢
S


TI-84+:

QUADSLV
Quadratic Formula - Allows for Complex Coefficients
Ax^2 + Bx + C = 0

a+bi
Disp "AX²+BX+C"
Prompt A,B,C
√(B²-4AC) → X
(-B - X)/(2A) → R
(-B + X)/(2A) → S
Disp "X=R or X=S"
Pause R
Pause S


HP 39gii:

Use the POLYROOT command. POLYROOT([A,B,C])

The vector can represent any polynomial.




This blog is property of Edward Shore. 2012





Saturday, July 14, 2012

Programs for HP 48S and What's Coming Up

HP 48: Law of Sines and Cosines, Quadratic Formula, and Cubic Formula.

Hi everyone! Recently, a poster on the MoHPC HP Calculator Forum asked for programs for solving triangles and finding roots for polynomials. (link here)

I will repost the programs here. They have been done with the HP 48S.

Law of Sines:

sin(θ1)/S1 = sin(θ2)/S2. Apply this to any of the two sides and their corresponding angels.

θ which can be typed by pressing:
HP 48S: [alpha] [right shift] (F)
HP 48G: [alpha] [right shift] (F)
HP 50g: [alpha] [right shift] (T)

LAWSIN:

<< 'SIN(θ1)/S1=SIN(θ2)/S2' STEQ 30 MENU>>

Law of Cosines:

A^2=B^2+C^2-2BC cos θ

LAWCOS:

<< 'SQ(A)=SQ(B)+SQ(C)-2*B*C*COS(θ)' STEQ 30 MENU>>

30 MENU brings up the calculator's solver using whatever is stored in STEQ.

QD: (Quadratic Formula) - Credit goes to the document "1 Minute Marvels" by Wldoek Mier-Jedrzejowicz and Richard Nelson (They have this program named 'quad')

Input:

3: A
2: B
1: C

Output:

2: root 1
1: root 2

<< 3 PICK / SWAP ROT -2 * / DUP SQ ROT - √ + LASTARG - >>

SQRT: Square Root

CU: Cubic Formula Uses the program QD above. This program finds the roots of AX^3+BX^2+CX+D=0

Input:
4: A
3: B
2: C
1: D

Output:
3: root 1
2: root 2
1: root 1

Program:

<< → A B C D
<<
C 3 A * / B SQ 9 A SQ * / - 'Q' STO
C B * A SQ / 3 D * A / - 6 / B 3 ^ 27 A 3 ^ * / - 'R' STO
R Q 3 ^ R SQ + √ + 3 XROOT 'S' STO
R Q 3 ^ R SQ + √ - 3 XROOT 'T' STO
S T + B 3 A * / - 'X' STO
X
B A X * +
C B X * + A X SQ * +
QD
{Q,R,S,T,X} PURGE >> >>

What is Coming Up

Coming in August, I will do a short series which I will use a graphing calculator with programming capabilities, most likely the TI-84 Plus, to demonstrate how programming is used to assist in mathematical applications: including finding the amount of miles between two places, projectile motion, and random walks.

If you get a chance, check out the Math/Maths Podcast. Link: Pulse Project

Until then,

Eddie


This blog is property of Edward Shore. © 2012

HP 15C: The I Squared Rule and HHC 2026

HP 15C: The I Squared Rule and HHC 2026 HHC 2026 Videos Before we start, the videos for HHC 2026 are up! Please take a look, ev...