Addition-chain exponentiation: Difference between revisions

fixed error in 2↑15; Also: changed M, initial choice was a mistake, particularly as det M!=1, new M has det of 1
(fixed error in 2↑15; Also: changed M, initial choice was a mistake, particularly as det M!=1, new M has det of 1)
Line 8:
:<math>a^{15} = a \times (a \times [a \times a^2]^2)^2 \!</math> (binary, 6 multiplications)
:<math>a^{15} = a^3 \times ([a^3]^2)^2 \!</math> (shortest addition chain, 5 multiplications)
On the other hand, the addition-chain method is much more complicated, since the determination of a shortest addition chain seems quite difficult: no efficient optimal methods are currently known for arbitrary exponents, and the related problem of finding a shortest addition chain for a given set of exponents has been proven [[wp:NP-complete|NP-complete]].
{|class=wikitable
|+Table demonstrating how to do ''Exponentiation'' using ''Addition Chains''
|-
!#Number of<br>Multiplications || Actual<br>Exponentiation || Specific implementation of <br>''Addition Chains'' to do Exponentiation
|-
|0 || a<sup>1</sup> || a
|-
|1 || a<sup>2</sup> || a × a
|-
|2 || a<sup>3</sup> || a × a × a
|-
|2 || a<sup>4</sup> || (b←aa × a a→b) × b
|-
|3 || a<sup>5</sup> || (b←aa × a a→b) × b × a
|-
|3 || a<sup>6</sup> || (b←aa × a a→b) × b × b
|-
|4 || a<sup>7</sup> || (b←aa × a a→b) × b × b × a
|-
|3 || a<sup>8</sup> || (d←(b←aa × a a→b) × b b→d) × d
|-
|4 || a<sup>9</sup> || (c←aa × a × a a→c) × c × c
|-
|4 || a<sup>10</sup> || (d←(b←aa × a a→b) × b b→d) × d × b
|-
|5 || a<sup>11</sup> || (d←(b←aa × a a→b) × b b→d) × d × b × a
|-
|4 || a<sup>12</sup> || (d←(b←aa × a a→b) × b b→d) × d × d
|-
|5 || a<sup>13</sup> || (d←(b←aa × a a→b) × b b→d) × d × d × a
|-
|5 || a<sup>14</sup> || (d←(b←aa × a a→b) × b b→d) × d × d × b
|-
|5 || a<sup>15</sup> || (d←(b←aa × a a→b) × b ) × da→e) × de × ae
|-
|4 || a<sup>16</sup> || (h←(d←(b←aa × a a→b) × b b→d) × d d→h) × h
|}
 
The number of multiplications required follows this sequence:
0, 1, 2, 2, 3, 3, 4, 3, 4, 4, 5, 4, 5, 5, 5, 4, 5, 5, 6, 5,
Line 56:
 
'''Task requirements:'''
 
Using the following values:
:<math>A=\begin{bmatrix}
\sqrt{\frac{1}{2}} & 0 4 & -3 &\sqrt{\frac{1}{2}} & 0 4/3& 0 -1/4& 0 &\\
0 &\sqrt{\frac{1}{2}} & 0 &\sqrt{\frac{1}{2}} & 0 & 0 &\\
-13/3& 19/4& -7/3& 11/24\\
0 3/ &\sqrt{\frac{1}{2}} & -20 & 7/6& -1/4 &-\sqrt{\frac{1}{2}} & 0 & 0 &\\
-\sqrt{\frac{1}{2}} & 0 &\sqrt{\frac{1}{2}} & 0 & 0 & 0 &\\
-1/6& 1/4& -1/6& 1/24\\
0 & 0 & 0 & 0 & 0 & 1 &\\
0 & 0 & 0 & 0 & 1 & 0 &\\
\end{bmatrix}</math> <math>m=31415</math> and <math>n=27182</math>
 
Repeat task [[Matrix-exponentiation operator]], except use '''addition-chain exponentiation''' to better calculate:
:<math> A ^ {m}</math>, <math>A ^ {n}</math> and <math>A ^ {n \times m}</math>.
 
As an easier alternative to doing the matrix manipulation above, generate the ''addition-chains'' for 31415 and 27182 and use ''addition-chain exponentiation'' to calculate these two equations:
* 1.00002206445416<sup>31415</sup>
* 1.00002550055251<sup>27182</sup>
 
Also: Display a count of how many multiplications were done in each case.