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

Looking for square roots, or roots in general #37

Open
WolfIcefang opened this issue Sep 28, 2021 · 2 comments
Open

Looking for square roots, or roots in general #37

WolfIcefang opened this issue Sep 28, 2021 · 2 comments

Comments

@WolfIcefang
Copy link

I've tried sqrt(16)
sqrt16
root(16)
root16
root 16
square root 16
etc... etc... etc...
nothing seems to work. Are there roots in this program, and if so how do I use them?

@bbodi
Copy link
Owner

bbodi commented Sep 29, 2021

Hi,

Unfortunately no, currently there is no sqrt function.

We have pow (e.g. 16^2), but it accepts only integers, so 16^0.5 would not work either.

This hack would work for finding n's square root: 2^(0.5*lg(n)), e.g. for 16 is 2^(0.5*lg(16))

This is surely an inconvenience and must be fixed as soon as I can work on the project again.

(btw these are the available functions and their names: https://github.com/bbodi/notecalc3/blob/develop/notecalc-lib/src/functions.rs#L43)

@DiegoTheWolf
Copy link

You can do a pretty good estimation with only some lines:

    e = 100 (estimate)
    s = number to get the square root from
    sqrt=(((((e+s/e)/2)+s/((e+s/e)/2))/2)+s/((((e+s/e)/2)+s/((e+s/e)/2))/2))/2

You calculate avg = (e + s/e) / 2. This new value is your new estimate e = avg and you do this calculation again.
The "formula" above does this 4 times and is a very good aproximation (and fits in one line easily)

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