Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize fast sum of powers for any length, not just power-of-two #62

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

oleganza
Copy link
Collaborator

No description provided.

@oleganza oleganza requested a review from cathieyun April 26, 2018 18:19
@oleganza oleganza force-pushed the oleg/fast-exp-sum branch 2 times, most recently from 5a3892a to 106ca9d Compare April 26, 2018 18:44
@cathieyun
Copy link
Member

very cool - LGTM.
I am curious about actual speedup, do you happen to have any benchmark numbers comparing the two? In theory the O(log(n)) one is faster, but we don't know what the constant is...

@hdevalence
Copy link
Contributor

hdevalence commented Apr 26, 2018

Is there a reason to do this instead of using the identity 1 + ... + x^{n-1} = (1 - x^n) / (1 - x)?

It costs one inversion, but it's simple, and for the case that n is a power of 2 the x^n computation will just be repeated squarings.

@oleganza
Copy link
Collaborator Author

Doesn't one inversion cost ≈200 multiplications? This implementation does (2..3)*lg n multiplications (2*lg(n) when n is power of two).

@oleganza
Copy link
Collaborator Author

But i did not know about 1 + ... + x^{n-1} = (1 - x^n) / (1 - x), thanks for pointing it out!

@hdevalence
Copy link
Contributor

Cool, I'm convinced this works but I'm not sure I understand why yet, so I'm working on some notes right now.

@hdevalence
Copy link
Contributor

The power-of-two recurrence is really nicely explained and it makes sense, but I don't understand why the recurrence for general n works. Is it possible to prove it?

@oleganza
Copy link
Collaborator Author

oleganza commented Oct 15, 2018

I just rebased this on main, for good hygiene, not with an expectation to merge this soon.

In fact, only RP code requires this helper, and in RP the input is always a power-of-two. For circuits, the delta is defined as an inner product of powers of a challenge with circuit-specific weights, so this whole function is not relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants