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

Todo list #1

Open
12 of 14 tasks
winderica opened this issue Dec 19, 2023 · 2 comments
Open
12 of 14 tasks

Todo list #1

winderica opened this issue Dec 19, 2023 · 2 comments

Comments

@winderica
Copy link
Collaborator

winderica commented Dec 19, 2023

  • Check the number of constraints
  • Investigate how to use Gnark's logUp
  • Lookup table for $2^x$
  • Documentation & comments
  • Merge fp into feat/math, or create a main branch by combining both?

Feel free to edit the list if you want to add a task or have completed one.

ToDo's added by Jens:

  • Migrate F64 to math function implementation by Luca (branch feat/math)
  • Generate test files similar to F64 testing for math functions
    • It seems that Berkeley TestFloat doesn't support generating test cases for complex functions. Are there any other libraries?
  • Sanity Check correctness of math function implementation & Clean up current simple migration (NOTE - Testing now checks that ULP <1 - currently this is not the case for all ranges of float values. Better approximation needed, increasing the degree of polynomial in atan or number of round for taylore series in sin is insufficient as it adds too many constraints)
  • Check Optimization sqrt - Currently Newton Rhapson, nth Root might be better (shifting/add instead of division) - @winderica will integrate his implementation with supercedes the Newton Rhapson one
  • Revise Sin implementation with Taylor approximation -> Add F32 support @Luca1011
  • Replace Sin with Spline approach --> lookup range of value, have low degree polynomial approximate the small range
  • Migrate F64 implementation & new Math to zkLocation circuit
  • Modularize float implementation to also support F32
    • Add Exponent Bitwidth / Precision in F64 / F32 struct as a constant?
@tumberger
Copy link
Owner

Quick Note:

Have to double-check if the implementation of calculateR in the zkLocation circuit is correct.
Currently, the comment reads that $\arccos(x) = \arctan(\frac{\sqrt{(1-x)^2}}{x})$, however the correct relation is $\arccos(x) = \arctan(\frac{\sqrt{1-x^2}}{x})$.

I added the correct derivation in the paper, note the reasoning here:

$\arccos(x) = \arctan(\frac{\sqrt{1-x^2}}{x})$

$\arccos(1 - \frac{d^2}{2}) = \arctan(\frac{\sqrt{1-(1 - \frac{d^2}{2})^2}}{1 - \frac{d^2}{2}})$

$\tan(r) = \tan(\arctan(\frac{\sqrt{1-(1 - \frac{d^2}{2})^2}}{1 - \frac{d^2}{2}}))$

where

$1 - \left(1 - \frac{x^2}{2}\right)^2 = x^2 - \frac{x^4}{4}$

such that

$\tan(r) = \frac{\sqrt{x^2 - \frac{x^4}{4}}}{1 - \frac{x^2}{2}}$

@Luca1011
Copy link
Collaborator

There is a mistake in the comments, but the final part after the equal sign is correct in the comments (https://www.wolframalpha.com/input?i=tan%28acos%281-x%2F2%29%29 second alternate form)
Square distance should be displayed as $d$ and not $d^{2}$

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

No branches or pull requests

3 participants