This site shows how the tables in Part IA through Part IVE for generating squares of squares were produced.
I will show only the equations and the conditional statements used for calculating the a2,
b2 and c2as well as
f from the middle group of tables. e and
g are also shown where
e is the difference between adjacent b1s and
g is the difference between adjacent c1s.
In addition, e is found by empirical means, viz., by plugging in the minimum value in equation
f below. The value of g
follows from the equation
Four methods are introduced where:
where k is any natural integer from 1 to ∞ and m is an integer derived from k which is used to calculate d = 2(2b1 − c1 − 1 ), the denominator in the equation:
m is also used in only two of the methods to generate nL which is derived from log (m).
Two functions in particular are used in the conditional statements to test whether a number is an integer or is odd-even, viz., isInteger(value) and isEven(value) shown below:
function isInteger(s)
{
return (s.toString().search(/^-?[0-9]+$/) == 0);
}
function isEven(value)
{
if (value%2 == 0) return true;
else return false;
}
switch(j)
{
case 1: e=d/16; g=2*e; break;
case 9: e=d/8; g=2*e; break;
case 17: e=d/8; g=2*e; break;
case 25: e=d/8; g=2*e; break;
case 33: e=d/16; g=2*e; break;
case 41: e=d/8; g=2*e; break;
case 49: e=d/8; g=2*e; break;
case 57: e=d/8; g=2*e; break;
default: e=d/4; g=2*e; break;
}
which means that certain numbers will have e = d/16, others to e = d/8
and the rest e = d/4.
To generate the requisite output to the screen since we know e and g we can use a for statement to generate the required tables in all four methods. The for statement includes
In Method II where initially a1 = 1, b1 = −k and c1 = 1 the following equations apply:
Method II uses both the isInteger() or isEven() function in the conditional statements to generate both
e and g.
It uses a log(m)/log(2) statement which when added to 1 produces an integer which may be either even or odd to produce
the requisite e and g values. Those where
nL ≠ an integer will produce a different value for e and g.
Conditional if-then-else statements are used to determine the values of e and
g as follows:
if (isInteger(nL))
{
x=(nL + nL%2)/2;
y=Math.pow(2,x);
if (isEven (nL)) /* n may be even or odd after doing the log calc. */
{e=-d/(2*y); g=2*e;} /* if nL is even */
else
{e=-d/y; g=2*e;} /* if nL is odd */
}
else {e= -d/4; g=2*e;} /* if nL is not an integer */
To output the table see the above section.
In Method III where initially a1 = 1, b1 = 1
and c1 = k the following equations apply:
Method III uses both the isInteger() or isEven() function in the conditional statements to generate both
e and g.
It uses conditional if-then-else statements to determine the values of
e and g as follows:
n1 = (k-1)/4;
n2 = (k-3)/4;
if (isEven(k)) {e= -d; g=2*e;}
else if (k%16==1 && isInteger(n1)) {e=-d/8;g=2*e;}
else if (isInteger(n2) && isInteger(Math.sqrt(-d))) {e=Math.sqrt(-d); g=2*e;}
else if (isInteger(n1)) {e=-d/4; g=2*e;}
else if (isInteger(n2)) {e=-d/2; g=2*e;}
These statements appear overwhelming but are easily explained.
To output the table see the above section.
In Method IV where initially a1 = 1, b1 = 1
and c1 = −k the following equations apply:
Method IV uses both the isInteger() or isEven() function in the conditional statements to generate both
e and g.
It uses conditional if-then-else statements to determine the values of
e and g as follows:
n1 = (k-1)/4;
n2 = (k-3)/4;
if (isInteger(nL))
{
x=(nL-nL%2)/2;
y=Math.pow(2,x);
e=(k+1)/y; g=2*e;
}
else if (isEven(k)) {e=d/2; g=2*e;}
else if (isInteger(Math.sqrt(d))) {e=Math.sqrt(d);g=2*e;}
else if (k%16==15 && isInteger(n2)) {e=d/8;g=2*e;}
else if (isInteger(n1)) {e=d/2;g=2*e;}
else if (isInteger(n2)) {e=d/4;g=2*e;}
These statements again appear overwhelming but are easily explained.
To output the table see the above section.
This concludes Part VA. To go back to Part IVC.
Go back to homepage.
Copyright © 2012 by Eddie N Gutierrez. E-Mail: Fiboguti89@Yahoo.com