Showing posts with label product. Show all posts
Showing posts with label product. Show all posts

Sunday, August 10, 2025

The Product Formula Chart Aid: P = A × B

The Product Formula Chart Aid: P = A × B


A Learning and Memorization Aid


A lot of mathematical formulas, basic relationships in physics and other applications are often in the form of:


P = A × B


where P is the product of two factors, A and B.


Examples include:


Distance: distance = velocity × time

Ohm’s Law: power = current × voltage

Newton’s Second Law: force = mass × acceleration


A chart in a shape of a circle (some people use a triangle) can be used to illustrate the relationship between the three variables.  I see charts of this time in various math books and videos applied to many applications.  An example is Ohm's Law as illustrated by Electrician U (skip to https://youtu.be/-oHzc_DbaGw?t=17).


P = A × B,  A = P ÷ B,  B = P ÷ A



Going across means multiply, while vertically means divide.


P = A × B

A = P ÷ B

B = P ÷ A





Hope you find this helpful,


Eddie


Source:  

Electrician U.  "5 Formulas Electricians Should Have Memorized!"  March 15, 2023.   https://www.youtube.com/watch?v=-oHzc_DbaGw.  Accessed May 27, 2025


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.


All posts are 100% generated by human effort.  The author does not use AI engines and never will.


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. 

 

Saturday, November 6, 2021

TI-92 Plus and TI-Nspire CX II: List Filters

TI-92 Plus and TI-Nspire CX II:  List Filters




For this particular post, I also have a TI-Nspire CX II CAS document which can be downloaded here:  https://drive.google.com/file/d/1Rm5vIWdUMg5OEyXi4VecNfuIGdiGRtan/view?usp=sharing


The functions are public and are available in the catalog.  Examples and syntax are included.  


The Filters


filters(list, criteria): filters out a list 

sumfilt(list, criteria): sum of selected elements of a list

avgfilt(list, criteria): arithmetic average of elements of a list

prdlist(list, criteria): product of selected elements of a list

dimfilt(list, criteria): returns a count of list elements that fit a criteria


This is similar to Excel functions filter, sumifs, averagefits, and countifs; there is no productifs in Excel.  


The criteria is a string, using x as a variable.  Examples:

"x<10": select elements less than 10

"x≥20": select elements greater than or equal to 20

"10<x and x<20": select elements between 10 and 20, not including 10 or 20

"10≤x and x≤20": select elements between 10 and 20, including 10 or 20


TI-92 Plus Functions: Filters


Note:  I am using the symbol [| for comment; in the program editor, select F2, option 9.  


TI-92 Plus Function:  filters


filters(list1,cr) 

Func

[| list, criteria string with x

[| EWS 2021-08-13

[| filter function

Local list2,d,i,t,x

{}→list2

dim(list1)→d

For i,1,d

expr(cr)|x=list1[i]→t

If t Then

augment(list2,{list1[i]})→list2

EndIf

EndFor

Return list2

EndFunc


TI-92 Plus Function: sumfilt


sumfilt(list1,cr) 

Func

[| list, criteria string with x

[| EWS 2021-08-14

[| sum-if filter function

Local list2,d,i,t,x

{}→list2

dim(list1)→d

For i,1,d

expr(cr)|x=list1[i]→t

If t Then

augment(list2,{list1[i]})→list2

EndIf

EndFor

Return sum(list2)

EndFunc


TI-92 Plus Function: avgfilt


avgfilt(list1,cr) 

Func

[| list, criteria string with x

[| EWS 2021-08-14

[| average-if filter function

Local list2,d,i,t,x

{}→list2

dim(list1)→d

For i,1,d

expr(cr)|x=list1[i]→t

If t Then

augment(list2,{list1[i]})→list2

EndIf

EndFor

Return sum(list2)/(dim(list2))

EndFunc


TI-92 Plus Function:  prdfilt


prdfilt(list1,cr) 

Func

[| list, criteria string with x

[| EWS 2021-08-14

[| product-if filter function

Local list2,d,i,t,x

{}→list2

dim(list1)→d

For i,1,d

expr(cr)|x=list1[i]→t

If t Then

augment(list2,{list1[i]})→list2

EndIf

EndFor

Return product(list2)

EndFunc


TI-92 Plus Function:  dimfilt


dimflt(list1,cr) 

Func

[| list, criteria string with x

[| EWS 2021-08-13

[| count-if filter function

Local list2,d,i,t,x

{}→list2

dim(list1)→d

For i,1,d

expr(cr)|x=list1[i]→t

If t Then

augment(list2,{list1[i]})→list2

EndIf

EndFor

Return dim(list2)

EndFunc


Examples:


list0 = {2,4,5,6,9,10,11,13,14,15,18}


filters(list0,"x≤10"):  {2,4,5,6,9}

filters(list0,"5≤x and x≤15"):  {5,6,9,10,11,13,14,15}


sumfilt(list0,"x≤10"):  36

sumfilt(list0,"5≤x and x≤15"):  83


avgfilt(list0,"x≤10"):  6

avgfilt(list0,"5≤x and x≤15"):  83/8


prdfilt(list0,"x≤10"):  21600

prdfilt(list0,"5≤x and x≤15"):  2700


dimfilt(list0,"x≤10"):  6

dimfilt(list0,"5≤x and x≤15"):  8


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, August 9, 2020

HP 12C: Last X: Sums and Products

HP 12C:   Last X:   Sums and Products

Introduction

It is possible to use the LST X feature on the HP 12C calculators assist us in quickly calculate sums or products  of a terms, especially when the list of terms are in a series. 

For today's blog, we are starting with a base amount, a, and then adding 1 to each term.   You can use a similar algorithm for a sequence where each term is doubled, tripled, 1 is subtracted from the previous term, and so on.  The key is to complete the adjustment, use storage arithmetic, and then use LST X.

Accessing LST X:

HP 12C (Classic):  [ g ] [ ENTER ]

HP 12C Platinum:  [ g ] [ + ]

These algorithms can be used in program. 


Sum:  a + (a+1) + (a+2)  + (a+3) + ....

Let n represent the storage register to be used.  On the HP 12C, only storage registers R0 through R4 (classic HP 12C).

Algorithm:


STO n

Loop:  
LST X 
1     [ or 2, x  to double each term,  1, - to subtract 1, etc.]
+  
STO+ n    [stores what is in the X display to the Last X register]

Finish:  
RCL n


Example:  7 + 8 + 9 +10 = 34.   Use register 0 to store the sum.

7
STO 0

LST X
1
+
STO+ 0

LST X
1
+
STO+ 0

LST X
1
+
STO+ 0

RCL 0


Sum:  1/a + 1/(a+1) + 1/(a+2) + 1/(a+3) + ....

Algorithm:


1/x
STO n

Loop:  
LST X 
1     
+  
1/x
STO+ n    

Finish:  
RCL n

Example:  1/7 + 1/8 + 1/9 + 1/10 ≈ 0.47897

7
1/x
STO 0

LST X
1
+
1/x
STO+ 0

LST X
1
+
1/x
STO+ 0

LST X
1
+
1/x
STO+ 0

RCL 0

Sum:  √a + √(a+1) + √(a+2) + √(a+3) + ...

Algorithm:



STO n

Loop:  
LST X 
1     
+  

STO+ n    

Finish:  
RCL n

Try the algorithm on this example:  √7 + √8 + √9 + √10 ≈ 11.63646

Sum:  a^2 + (a+1)^2 + (a+2)^2 + (a+3)^2 + ...

Hint:  Use ENTER, x instead of 2, y^x

Algorithm:


ENTER 
*
STO n

Loop:  
LST X 
1     
+  
ENTER
*
STO+ n    

Finish:  
RCL n

Try the algorithm on this example:  7^2 + 8^2 + 9^2 + 10^2 = 294

Let's move on to products.

Product:  a * (a+1) * (a+2) * (a+3) * ....


STO n

Loop:  
LST X 
1     
+  
STOx n    

Finish:  
RCL n


Example:  7 * 8 * 9 * 10 = 5040.   Use register 0 to store the product.

7
STO 0

LST X
1
+
STOx 0

LST X
1
+
STOx 0

LST X
1
+
STOx 0

RCL 0

Product:  1/a * 1/(a+1) * 1/(a+2) * 1/(a+3) * ....


1/x
STO n

Loop:  
LST X 
1     
+  
1/x
STOx n    

Finish:  
RCL n


Try the algorithm on this example 1/7 * 1/8 * 1/9 * 1/10 ≈ 0.0020

Product:  √a * √(a+1) * √(a+2) * √(a+3) * .......



STO n

Loop:  
LST X 
1     
+  

STOx n    

Finish:  
RCL n


Try the algorithm on this example √7 * √8 * √9 * √10 ≈ 70.99296

Hopefully this will help your calculations on your RPN calculators faster and more effective,

Eddie

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

Wednesday, January 30, 2019

HP 71B: Product of f(x), Nested Radicals, How Much Can I Afford?, Cardiac Analysis

HP 71B:  Product of f(x), Nested Radicals, How Much Can I Afford?, Cardiac Analysis

Product of a Function

∏ f(x)

Edit f(x) at line 10

PROGRAM PRODFX
At least 90 bytes, 1/23/2019

10 DEF FNF(X)=[ insert f(X) here ]
20 INPUT "Lower=";L
30 INPUT "Upper=";U
40 P=1
50 FOR X=L TO U @ P=P*FNF(X) @ NEXT X
60 DISP 'P=';P

Example:  f(X) = FNF(X) = 1/X
Lower:  1
Upper:  5
Result:  6.61375661376E-6

Trigonometric Simplification

Original blog entry (11/15/2018):  http://edspi31415.blogspot.com/2018/11/ti-84-and-casio-fx-cg-50-micropython.html

Source: Dugopolski, Mark  Trigonometry Addison Wesley: Boston 2003 pp 211-212  ISBN 0-201-70338-6

Simply the expression:

a sin x + b cos x = r * sin( θ + x )
where r = √(a^2 + b^2), θ = angle(a,b) = arg(a+bi)

PROGRAM SCTOSIN
114 bytes, 1/23/2019

10 DESTROY A,B,R,T
20 RADIANS
30 DISP "A*SIN(X)+B*COS(X)" @ PAUSE
40 INPUT "A=";A
50 INPUT "B=";B
60 R=SQR(A^2+B^2) @ T=ANGLE(A,B)
70 DISP R;"*SIN(";T;"+X)"

Line 70 can use PRINT
SQR is √

Example: 
A = 2.25,  B = 1.76
Result:
R = 2.85658887486  (scroll left)
θ = .663806440909
Output:
2.85658887486  *SIN( .663806440909 +X)

How Much Car Can You Afford?

Original blog entry (3/13/2018):  https://edspi31415.blogspot.com/2018/03/hp-prime-car-payment-and-affordability.html

Calculate how much the buyer can afford, considering sales tax, discounts, and down payment.  All amounts are entered as positive.

PROGRAM AFFORD
221 bytes, 1/24/2019

10 DESTROY N,I,S,X,W,D,P
20 INPUT "# MONTHS:";N
30 INPUT "RATE %:";I @ I=I/1200
40 INPUT "PAYMENT $";X
50 INPUT "SALES TAX %:";S
60 INPUT "DISCOUNT %:";D
70 INPUT "DOWN PMT $";W
80 P=1/I*(1-(1+I)^(-N))
85 P=P*X
90 P=(P+W)/((1+.01*S)*(1-.01*D))
95 PRINT USING "'AMT: $'7D.DD";P

Example:
Term: N = 60 months
Interest Rate:  I = 4.8%
Desired Payment: X = $295
Sales Tax: S = 9.5%
Discount: D = 10%
Down Payment: W=$1500

Result:
AMT: $17657.09

HP 71B: Cardiac Programs

Source:  Hewlett Packard.  "HP-65 Medical Pac 1" 1974.

Valve Area

Variables:

Input:
P = pressure gradient data (mmHg), enter an average or data points
C = cardiac output (CO) (l/min)
R = R-R interval (seconds)
T = the time the valve is open (seconds)

The program offers a choice between calculating an  area of a regular valve or a mitral valve.

Program VALVE
433 bytes, 1/28/2019

10 DESTROY K,P,N,D,P1,C,R,T,F,V
20 P1=0 @ N=0 @ P=0
30 PRINT "PRESSURE (mmHg)" @ WAIT .5
35 INPUT "P: 1=AVG 2=DATA ";K
38 IF K=1 THEN 50 ELSE 40 
40 INPUT "P DATA: ";D
42 P=P+D @ N=N+1 @ P1=P/N
44 INPUT "DONE? 1=YES 2=NO ";K
46 IF K=2 THEN 40 ELSE 60
50 INPUT "P AVG. :";P1
60 INPUT "CO (l/min): ";C
62 INPUT "R-R (sec): ";R
64 INPUT "OPEN TIME (sec/min):";T
66 F=C*R/(60*T) @ V=F/(.0445*SQR(P1))
68 INPUT "MITRAL 1=YES 2=NO ";K
70 IF K=1 THEN LET V=V/.7
72 PRINT "MEAN FLOW (l/sec) :";F @ PAUSE
74 PRINT "AREA (cm^2) :";V

Anatomic Shunts

The program SHUNTS calculates the bi-directional shunts as a percentage.  The shunts are R-L (right-left) shunt and the L-R (left-right) shunts.

Variables:

Input:
R1:  right pulmonary artery
R2:  right atrium
L1:  left pulmonary artery
L2:  left ventricle

Program SHUNT
230 bytes, 1/27/2019

10 DESTROY L1,L2,R1,R2,L3,R3
20 INPUT "R-PULMONARY%:";R1
30 INPUT "R.ATRIUM%:";R2
40 INPUT "L-PULMONARY%:";L1
50 INPUT "L.ATRIUM%";L2
60 R3=(L1-L2)/(L1-R2)*100
65 L3=(R1-R2)/(L1-R2)*100
70 PRINT USING ' "R-L SHUNT:"4D.DD"%" ';R3 @ PAUSE
75 PRINT USING ' "L-R SHUNT:"4D.DD"%" ';L3 
90 END

Stroke Work

The program STRKWORK calculates stroke work and stroke work index based on pressure, cardiac output (CO), R-R interval (seconds), and body surface area (BSA).  The BSA is optional but is needed to calculate stroke work index. 

Program STRKWORK
404 bytes, 1/28/2019

10 DESTROY S,S1,P,P1,R,C,N,K,D,B
14 DISP "P=PRESSURE mmHg" @ WAIT .5
20 N=0 @ P=0
25 INPUT "P 1:AVG 2:DATA ";K
30 IF K=1 THEN 50
40 INPUT "P. DATA PT: ";D
42 P=P+D @ N=N+1 @ P1=P/N
44 INPUT "DONE? 1=YES 2=NO ";K
46 IF K=2 THEN 40 ELSE 60
50 INPUT "AVG P: ";P1 
60 INPUT "R-R INTERVAL (sec):";R
62 INPUT "CO (L/MIN): ";C
70 S=13.6*P1*C*R/60
72 PRINT "SW =";S;"(gm m)" @ PAUSE
80 INPUT "BSA? (m^2) (0=NONE): ";B
82 IF B=0 THEN 90
84 S1=S/B
86 PRINT "SWI: ";S1;"gm m/m^2"
90 END

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.

Saturday, October 22, 2016

HP Prime: Fun with Primes

HP Prime:  Fun with Primes

Prime Numbers

A positive integer is a prime number if there the only integers that can divide that number evenly (without remainder) is 1 and itself.

Fun facts:

*  1 is not a prime number.
*  2 is the only even prime number.
*  5 is the only prime number that ends in 5. 
*  No prime number has a 0, 4, 6, or 8 as the last digit.

Sum of the Fist n Primes

Let p be a prime number.  That is, p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, …}

The sum of the first prime numbers is:  Σ p_k from k = 1 to n

HP Prime Program SPRIMES:  Sum of the First n Primes
EXPORT SPRIMES(n)
BEGIN
// 2016-10-22 EWS
// Sum of the first n primes

LOCAL t,p,k;

IF n≤1 THEN
RETURN 2;
ELSE
t:=2;
p:=2;

FOR k FROM 2 TO n DO
p:=CAS.nextprime(p);
t:=p+t;
END;

RETURN t;
END;
END;




Sum of the First n Prime Reciprocals

Σ 1/(p_k) from k = 1 to n


HP Prime Program ISPRIMES:  Sum of first n Prime Reciprocals
EXPORT ISPRIMES(n)
BEGIN
// 2016-10-22
// Sum of reciprocal of primes

LOCAL t,p,k;
n:=IP(n);

IF n≤1 THEN
RETURN 2;
ELSE
t:=2¯¹;
p:=2;

FOR k FROM 2 TO n DO
p:=CAS.nextprime(p);
t:=p¯¹+t;
END;

RETURN t;
END;


END;

It does not appear that there series of sums do not converge as n approaches ∞ (infinity).

ISPRIMES(25) returns 1.80281720104
ISPRIMES(50) returns 1.96702981491
ISPRIMES(100) returns 2.10634212145
ISPRIMES(10000) returns 2.70925824876



Product of the First n Prime Reciprocals

Π 1/(p_k) from k = 1 to n

HP PRIME Program IPPRIMES
EXPORT IPPRIMES(n)
BEGIN
// 2016-10-22
// Product of reciprocal of primes

LOCAL t,p,k;
n:=IP(n);

IF n≤1 THEN
RETURN 2;
ELSE
t:=2¯¹;
p:=2;

FOR k FROM 2 TO n DO
p:=CAS.nextprime(p);
t:=p¯¹*t;
END;

RETURN t;
END;
END;

Unlike ISPRIMES, IPPRIMES approaches 0 as n approaches ∞.

IPPRIMES(25) returns 4.33732605429E-37
IPPRIMES(50) returns 5.24156625851E-92
IPPRIMES(100) returns 2.12227225409E-220
IPPRIMES(10000) returns 0



This blog is property of Edward Shore, 2016.



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