notecalc3 icon indicating copy to clipboard operation
notecalc3 copied to clipboard

Looking for square roots, or roots in general

Open WolfIcefang opened this issue 4 years ago • 2 comments

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?

WolfIcefang avatar Sep 28 '21 23:09 WolfIcefang

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)

bbodi avatar Sep 29 '21 05:09 bbodi

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)

DiegoTheWolf avatar Oct 26 '21 07:10 DiegoTheWolf