mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Miscellaneous Math

Reply
 
Thread Tools
Old 2019-03-04, 22:05   #23
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

3×547 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
I recall this method... for example: N=(1001111011)_2 can be written as (10[10000-1][100-1])_2. The former takes 9S + 6M and the latter takes 9S + 2M +2D (where S=squaring, M=mult by base and D=div by base). I don't think I have it quite right
No.

Say you are using k=3 in the method (k depends on length of the exponent),
then precompute x^3,x^5,x^7 mod n

See your N=(1001111011)_2 exponent

with 5 squaring get x^32, at this point you have processed the 100000_2 part in the exponent.
Now multiple this by x^(111_2)=x^7 to get x^39.
With 3 more squaring you get x^312.
Multiple this by x^(101_2)=x^5 to get x^317
With one more squaring you get x^634,
multiple this by x^(1_2)=x^1 to get x^635=x^N mod n. (all above computations are done in mod n).

If the length of the exponent is L, then with random exponent you need L squaring and only approx L/4 multiplication,
what is a good gain over the extra cost's standard L/2 multiplication (because half of the digits is 1).

Ofcourse there is an optimal k value for L, but the size of memory could also limit this k value (you need to store x^3 mod n,.. in the array). Also notice that you need 2^(k-1) multiplications to build up the precomputed array.

Last fiddled with by R. Gerbicz on 2019-03-04 at 22:07
R. Gerbicz is offline   Reply With Quote
Reply



All times are UTC. The time now is 15:41.


Fri Jul 7 15:41:32 UTC 2023 up 323 days, 13:10, 0 users, load averages: 1.55, 1.32, 1.17

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔