Sunday, October 30, 2016

(Maybe Not So Well Known?) Mathematical Curves

(Maybe Not So Well Known?) Mathematical Curves

Here are some mathematical curves graphed on the Desmos website (https://www.desmos.com/calculator ).   Enjoy!

For the following curves, the angle mode is radians.

The equations shown on this blog entry can be plotted on any graphing calculator that has function, polar, and parametric modes.  I will post the links to the pages on Desmos with each curve.  For parametric curves, I set the range to -4*π ≤ t ≤ 4*π.  The variables a, b, c, and n can be changed in the links for you to explore the graphs. 

Without further ado:

Arachnida

Polar Curve:
r = 2 * a * sin(n*θ)/sin((n-1)*θ)
a > 0, n N  (N:  natural numbers (1, 2, 3, …))



Example:  a = 3, n = 6
 

Conchoid of Dürer
(Dürer’s Shell Curve)

Parametric Curve:
x = (a * cos(t))/(cos(t) – sin(t)) + b * sin(t)
y = b * sin(t)
a > 0, b > 0



Example:  a = 6.1, b = 8.84

Cornoid

Parametric Curve:
x = a * cos(t) * (1 – 2 * (sin(t))^2)
y = a * sin(t) * (1 + 2 * (cos(t))^2)
a > 0



Example:  a = 5.89 

Nodal Curve

Polar Curve:
r = a * cot(n * θ)
or  r = a/(tan(n*θ))
a > 0, n N



Example:  a = 2.67, n = 8


Right Trifolium

Polar Curve:
r = a * cos(θ) * cos(2*θ)
a > 0



Example:  a = 3.79

Sand Glass Curve

Parametric Curve:
x = a * cos(2*t)/cos(t)
y = b * tan(t)
a > 0, b > 0



Example:  a = 6.6, b = 3.9

Scarabaeus

Polar Curve:
r = a * cos(2*θ) – c * cos(θ)
a > 0, c R  (real numbers)



Example:  a = 3.64, c = 1.11


Deltoid Curve
(Three-Cuspid Hypocycloid)

Parametric Curve:
x = a * (2 * cos(t) + cos(2*t))
y = a * (2 * sin(t) – sin(2*t))
a > 0



Example:  a = 3.14


Windmill

Polar Curve:
r = a * cot(2*θ)
or r = a/tan(2*θ)

a > 0



Example:  a = 3

Trichoidal Rose

Polar Curve:
r = 2 * a * (q + 1) * sin(θ/(2*q + 1))
a > 0
q = m/n where m Z, n Z, and GCD(m,n) = 1, but q ≠ 1 nor q ≠ 1/2



Example: a = 2.14, q = 2/5  (n = 2, m = 5).

My favorites are the Arachnida, Sand Glass, and Scarbaeus.  Feel to free to play with the curves and see what you get. 

Eddie

Source:

Shinkin, Eugene V.  Handbook and Atlas of Curves  CRC Press:  Boca Raton.  1995  ISBN 0-8493-8963-1

This blog is property of Edward Shore, 2016




Saturday, October 29, 2016

HP Prime and HP 49G/50G: Tridiagonal Matrices

HP Prime and HP 49G/50G:  Tridiagonal Matrices

The program TRIDIAG will build a tridiagonal matrix of the form:

D1
R1
0
0
0
0
0
L1
D2
R2
0
0
0
0
0
L2
D3
R3
0
0
0
...
0
0
0
0
L(n-2)
D(n-1)
R(n-1)
0
0
0
0
0
L(n-1)
D(n)


Where

D represents the list/vector of diagonal elements, and D has the length n,
L represents the list/vector of elements to the left of the diagonal, and L has the length n-1, and
R represents the list/vector of elements to the right of the diagonal, and R has the length of n-1.

HP Prime Program tridiag

Input:   tridiag(ll, ld, lr) where the arguments are lists.

Program:
EXPORT tridiag(ll, ld, lr)
BEGIN
LOCAL m,s,j,t;
ssize(ld);
mdiag(ld);
FOR j FROM 1 to s-1 DO
tj+1;
m(t,j)ll(j);
m(j,t)lr(j);
END;
RETURN m;
END;

HP 49G/50g Program TRIDIAG

This is the first program I made on a HP 49G, but it should work on the 50g just fine.

Input:
3:  vector of left elements
2:  vector of diagonals
1:  vector of right elements

Program:
→ L D R
D SIZE OBJ→
DROP DUP D
SWAP DIAG→ →
S M
M 1 S 1 –
FOR J
J 1 + J 2 →LIST
L J GET PUT
J J 1 + 2 →LIST
R J GET PUT
NEXT ‘J’ PURGE

Example:
Left elements:  4, -3, 8
Diagonals: 1, 2, 3, 4
Right elements: -2, 5, 1

There are 4 diagonal elements, therefore the matrix will be 4 x 4.

Inputs:

HP Prime:  tridiag({4,-3,8},{1,2,3,4},{-2,5,1})

HP 49G/50g (RPN Mode):
3:  [4, -3, 8]
2:  [1, 2, 3, 4]
1:  [-2, 5, 1]

Result:

1
-2
0
0
4
2
5
0
0
-3
3
1
0
0
8
4


I hope you like my new style for matrices. 

Happy Halloween!

This blog is property of Edward Shore, 2016.




Sunday, October 23, 2016

Fun with Primes: Sum of Primes

Fun with Primes:  Sum of Primes

Primes Composed of a Sum of Primes

Separated by 2

5 = 2 + 3
7 = 2 + 5
13 = 2 + 11
19 = 2 + 17
43 = 2 + 41
61 = 2 + 59
151 = 2 + 149
193 = 2 + 191

Other Sums

23 = 2 + 3 + 5 + 13
31 = 7 + 11 + 13
47 = 5 + 19 + 23
59 = 7 + 23 +29
71 = 3 + 31 +37
79 = 13 + 19 +47
79 = 5 + 31 +43
83 = 11 + 31+ 41
101 = 3 + 31 + 67
107 = 19 + 29 +59
109 = 3 + 47+ 59
113 = 11 + 41 +61
127 = 17 + 43 + 67
127 = 2 + 29 + 37 + 59
131 = 41 + 43 + 47
151 = 11 + 67 + 73
157 = 13 + 47 + 97
173 = 43 + 59 + 71
199 = 43 + 47 + 109
223 = 71 + 73 + 79
233 = 59 + 67 + 107
311 = 29 + 47 + 59 + 67 + 109

Primes Composed of a Sum and Product of Primes

31 = 2 * 5 + 7 * 3
43 = 17 + 2 * 13
47 = 2 * 7 + 3 * 11
61 = 2 * 11 + 3 *13
79 = 2 * 7 + 5 * 13
83 = 47 + 2 * (5 + 13)
89 = 7 + 2 * 41
149 = 2 * 17 + 5 * 23
149 = 2 * 59 + 31
163 = 2 + 7 * 23

What other combinations you find? 

Eddie

This blog is property of Edward Shore, 2016.



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.



Friday, October 21, 2016

Mathematical Art

Alien:  TI-84 Plus CE

Doppler Bullseye: TI-84 Plus CE

Golden Fan: HP Prime

It's Blue Being Normal: HP Prime

Desert Overshot: HP Prime



This blog is property of Edward Shore, 2016

Sunday, October 16, 2016

HP Prime and Casio Prizm: Computation of “As-Built” Circular Alignments

HP Prime and Casio Prizm:  Computation of “As-Built” Circular Alignments

Special thanks to Jason Foose for bringing the topic to my attention.

The program ASBUILT determines radius and center point of an approximate circular curve.  The program uses the least squares method using the following matrices:

A = [ [ 2*x1, 2*y1, -1] [ 2*x2, 2*y2, -1 ] [ 2*x3, 2*y3, - 1] [ 2*x4, 2*y4, -1 ] ]
X = [ [ x0 ] [ y0 ] [ f ] ]
L = [ [ x1^2 + y1^2 ] [ x2^2 + y2^2 ] [ x3^2 + y3^2 ] [ x4^2 + y4^2 ] ]

The matrix X is solved by:  X = ( det(A) * A)¯¹  * det(A) * L

The input for ASBUILT is a 4 x 2 matrix, consisting of each of the four points. 

The example:
(x1, y1) = (6975.82, 6947.93)
(x2, y2) = (7577.11, 6572.6)
(x3, y3) = (8084.03, 6071.29)
(x4, y4) = (8431.38, 5542)

The input matrix is:
[ [ 6975.82, 6947.93 ] [ 7577.11, 6572.6 ] [ 8084.03, 6071.29 ] [ 8431.38, 5542 ] ]



ASBUILT is an approximation program.

HP Prime Program:  ASBUILT
EXPORT ASBUILT(ma)
BEGIN
LOCAL ml,mx,n,r,l{};
// build L
FOR n FROM 1 TO 4 DO
l(n)ABS(ma(n))^2;
END;
mllist2mat(l,1);
// build A
ma2*ma;
ADDCOL(ma,[-1,-1,-1,-1],3);
// compute X
mxCAS.LSQ(ma,ml);
// compute radius
r√(mx(1,1)^2+mx(2,1)^2-mx(3,1));
// results
RETURN {mx,r};
END;

Example Output:  { [ [x0][y0][f]], radius}

{ [ [ 5587.37457087 ] [ 4053.99226137 ] [ 37351007.6568 ] ] , 3209.76637679 }

Casio Prizm Program:  ASBUILT
“4 × 2 Mat [X,Y]”? → Mat A
{4 , 1} → Dim Mat B
For 1 → N To 4
Mat A[N,1]² + Mat A[N,2]² → Mat B[N,1]
Next
2 × Mat A → Mat A
Augment(Mat A, [[-1][-1][-1][-1]]) → Mat A
(Trn Mat A × Mat A)¯¹ × Trn Mat A × Mat B → Mat C
√( Mat C[1,1]² + Mat C[2,1]² - Mat C[3,1] ) → R
“RADIUS”
R
Mat C

Example Output: 
[ [ 5587.3745555 ] [ 4053.992245 ] [ 37351007.55 ] ]
Radius, R = 3209.766346

Source:  Ghilani, Charles D. “Elementary Surveying:  An Introduction to Geomatics” 14th Edition.  Pearson.  2014



This blog is property of Edward Shore, 2016





TI-84 Plus CE: Possible Matrix Bug? (Update 11/6/2016)

TI-84 Plus CE: Possible Matrix Bug?

Calculator:  TI-84 Plus CE
OS Version:  5.1.5.0019  (2016)

While creating a program to determine the radius of “as-built” circular alignments, I ran into a possible bug for the TI-84 Plus CE.  The program would call for the inverse of a matrix, and the 84 returned an error when I think it shouldn’t.  This blog entry will focus on the possible bug.

Determinant of a 3 x 3 Matrix

As we know, if the determinant of a matrix is 0, it is singular and an inverse for the matrix cannot be calculated. For a 3 x 3 matrix A, the determinant is calculated as:

|A| = S – U + V

Where:

S = A(1,1) * ( A(2,2) * A(3,3) – A(3,2) * A(2,3) )
U = A(1,2) * ( A(2,1) * A(3,3) – A(3,1) * A(2,3) )
V = A(1,3) * ( A(2,1) * A(3,2) – A(3,1) * A(2,2) )

Designation:  A(row, column)

The test program DET3TEST will calculate the determinant both was: first by the det function and the long calculation.

TI-84 Plus CE Program DET3TEST
Input [D]
det([D])→T
Disp "DET FUNCTION:"
Pause T
[D](1,1)*([D](2,2)*[D](3,3)-[D](2,3)*[D](3,2))→S
[D](1,2)*([D](2,1)*[D](3,3)-[D](3,1)*[D](2,3))→U
[D](1,3)*([D](2,1)*[D](3,2)-[D](2,2)*[D](3,1))→V
Disp "LONG WAY:",S-U+V

Test Results:

As expected most calculations will generate the same determinant using both methods.



Matrix:

4
6
3
0
1
-5
-3
-2
2

Determinant Function:  67
Long Way:  67

Matrix:

105
-262
360
435
415
360
676
330
360

Determinant Function:  -68834520
Long Way:  -68834520

Matrix:

108
76
-2
38
45
-5
-2
-5
6

Determinant Function:  10092
Long Way:  10092

Matrix:

2100
7584
2525
-1666
1724
-1826
5200
8
7543

Determinant Function:  2.796336659E10
Long Way:  2.796336659E10

Matrix:

114875.56
4173818
-127000.5
-46154
82755.275
57400
27604516
-3.12E7
304898400

Determinant Function:  1.40693245E20
Long Way:  1.40693245E20

-123456789
10.54
48275.05
112466708
48275.05
-417758
10.554
-42700.889
37200958.69

Determinant Function:  -2.19786983E20
Long Way:  -2.19786983E20


-123456789
10.54
48275.05
112466708
48275.05
-417758
10.554
-42700.889
37200958.69

Determinant Function:  -2.19786983E20
Long Way:  -2.19786983E20


So far, so good, as we expect.  Here is one matrix where it went wrong:



970057481.4792
776304082.7892
-62136.68
776304082.7892
636188513.236
-50267.64
-62136.68
-50267.64
4

Determinant Function:  0
Long Way:  3.043565238E12

Update (11/6/2016):  I recently updated the OS for the TI-84 Plus CE to version 5.2.1.0042 (2016) and tested the determinant function on this matrix again, and still got 0.  

Also, in an email from Rich Grubbs, "I have verified that the following TI calculators get the result '0' when given the same matrix: TI-nspire (3.9.0.463), TI-84 keypad in the TI-nspire (2.56MP), TI-86(1.6), TI-92+ (2.05), and TI-36X Pro (Serial K-0514B)."  Thank you Rich for information!  Much appreciated! 

I tested this matrix on Wolfram Alpha, HP Prime, and Casio Prizm and all got the latter answer (3.043565238E12).

I have not found any other matrices with mismatching answers.


This blog is property of Edward Shore, 2016.



Casio fx-9750GIII and fx-CG 50: Playing Games with the Probability Simulation Mode

Casio fx-9750GIII and fx-CG 50: Playing Games with the Probability Simulation Mode The Probability Simulation add-in has six type...