Showing posts with label numbers. Show all posts
Showing posts with label numbers. Show all posts

Saturday, February 11, 2023

Sum and Product Problem with the Casio fx-4000P

Sum and Product Problem with the Casio fx-4000P



The Sum and Product Problem


For the numbers a and b with the sum s, and product p:


a + b = s

a * b = p


Let's find a solution for a and b:


a + b = s

b = s - a


a * b = p

a * (s - a) = p

a * s - a^2 = p

0 = a^2 - a * s + p


a = (s ± √(s^2 - 4 * p))/2


Then:


b = s - a

= s -  (s ± √(s^2 - 4 * p))/2

= (2*s)/2 -  (s ± √(s^2 - 4 * p))/2

= (2*s -s ±√(s^2 - 4 * p))/2

=  (s ± √(s^2 - 4 * p))/2


Note that addition and multiplication are communitive.  


Without loss of generality, let:


a = (s + √(s^2 - 4 * p))/2


b = (s - √(s^2 - 4 * p))/2


Verification:


a + b 

= (s + √(s^2 - 4*p))/2 + (s - √(s^2 - 4*p))/2

= (s + √(s^2 - 4*p) + s - √(s^2 - 4*p))/2

= (2 * s)/2

= s


a * b

= (s + √(s^2 - 4 * p))/2 * (s + √(s^2 - 4 * p))/2

= (s/2)^2 - (√(s^2 - 4 * p)/2)^2

= s^2/4 - (s^2 - 4 *p)/4 

= (s^2 - s^2 + 4 * p)/4

= (4 * p)/4

= p



Casio fx-4000P Program:  Sum and Product Problem


This program can be adopted to many programming and graphing calculators. 


Program:


"A+B=":?→S:

"AB=":?→P:

(S+√(S²-4P))÷2→A◢

S-A→B



Examples


S:  Sum

P:  Product


Example 1:

S = 12, P =32;

Results: 8, 4


Example 2:

S = 8, P = 15;

Results: 5, 3



Enjoy!  Until next time,


Eddie


All original content copyright, © 2011-2023.  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, October 27, 2019

HP 12C and HP 41C/DM41L: Rounding Numbers

HP 12C and HP 41C/DM41L:  Rounding Numbers

Introduction

The following program rounds positive numbers to the desired decimal amount of places.  For example,  √3 rounded to 3 places is 1.732.  e^2 rounded to 2 places is 7.39. 

Set up your stack like this:
Y:  number
X: number of decimal places

HP 12C Program: Rounding

Step;  Code;   Key
01;  1;  1
02;  0;  0
03;  34;  x<>y
04;  21;  y^x
05;  36;  ENTER
06;  33;  R↓
07;  20;  *
08;  36;  ENTER
09;  43,24;  FRAC
10;  40;  +
11;  43, 25;  ITNG
12;  33;  R↓
13;  33;  R↓
14;  33;  R↓
15;  10;  ÷
16;  43,33,00;  GTO 00

HP 41C Program:  Rounding

01  LBL^T ROUND
02  10↑X
03  STO T
04 *
05 ENTER↑
06 FRC
07 +
08 INT
09 R↑
10 /
11 RTN
12 END

Examples:

Round √3 rounded to 3 places

Y:  3, sqrt   (√3)
X:  3

Result:  1.732

Round e^2 rounded to 2 places. is 7.39. 

Y: 2,  e^x  (e^2)
X:  2

Result:  7.39

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.

Monday, November 26, 2018

TI-84 Plus and HP 12C Platinum: Banker's Rounding Method

TI-84 Plus and HP 12C Platinum:  Banker's Rounding Method

Introduction 

The banker's  rounding method involves rounding numeric amounts to the nearest integer.  When the number ends in 0.5  (1.5, 3.5, 8.5, etc), special rules apply:

The decimal gets rounded to the nearest even integer.  For example:  0.5,  2.5, and 4.5 round down to 0, 2, and 4 respectively.  However, 1.5, 3.5, and 5.5 are rounded up to 2, 4, and 6 respectively.

TI-84 Plus Program:  BANKRND

"2018-11-22 EWS"
Disp "BANKER'S ROUNDING"
Prompt X
iPart(X) → I
fPart(X) → F

If F=0.5
Then

If fPart(I/2)=0
Then
I → N
Else
I+1 → N
End

Else
round(X,0) → N
End
Disp N

HP 12C Platinum Program: Banker's Rounding

Note: Use two-digit addresses for the regular HP 12C.

Memory addresses needed: registers 0 through 4.  

Step  Key

001  STO 0
002  INTG
003  STO 1
004  LSTx  
005  FRAC
006  STO 2
007   .
008  5
009   -
010   x=0
011   GTO 018
012   RCL 0
013   FIX 0
014   RND
015   STO 4
016   FIX 2
017   GTO 000
018   RCL 1 
019   2
020   ÷
021   FRAC
022   x=0
023   GTO 029
024   RCL 1
025   1
026   +
027   STO 4
028   GTO 000
029   RCL 1
030   STO 4
031   GTO 000

Source:

"Bankers Rounding"  http://wiki.c2.com/?BankersRounding  Retrieved November 22, 2018


Eddie

All original content copyright, © 2011-2018.  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.  Please contact the author if you have questions.

Trigonometry Reduction Formula and Solving Simple Arcsine and Arccosine Equations

Trigonometry Reduction Formula and Solving Simple Arcsine and Arccosine Equations Some Background and Periodic Reduction Formulas ...