Page 1 of 1

Maths - Square Root

Posted: Tue Jul 11, 2017 8:22 pm
by Simon Knight
Hi,
I'm just trying to write my first library widget using LCB and need to calculate the square root of several numbers. I can find no direct command so should I be using raise to the power or have I missed something?

best wishes

Simon

Re: Maths - Square Root

Posted: Wed Jul 12, 2017 10:49 am
by [-hh]
There is no "sqrt(x)" in LCB. Instead use

x^0.5 or exp(0.5*ln(x)) for 0<=x.

[The case a=0 is included in the definition of a^b := exp(b*ln(a)).]

Re: Maths - Square Root

Posted: Wed Jul 12, 2017 12:37 pm
by Simon Knight
[The case a=0 is included in the definition of a^b := exp(b*ln(a)).]
I'll take your word on that!

Thanks.

Re: Maths - Square Root

Posted: Wed Jul 12, 2017 1:16 pm
by Thierry
Simon Knight wrote: I'll take your word on that!
You can :)

[-hh] has a serious computer and maths background!

Regards,

Thierry

Re: Maths - Square Root

Posted: Thu Jul 13, 2017 9:53 am
by Simon Knight
I guessed he had.

My school boy maths just does not cut it. :?

Re: Maths - Square Root

Posted: Thu Jul 13, 2017 11:37 am
by [-hh]
The case a=0 is included in the definition of a^b := exp(b*ln(a)).
To make it simple I meant with that LC computes as needed: exp(0.5*ln(0))=0
[what is the limit of exp(0.5*ln(x)) for 0 < x -> 0]

The equality (extended by the limit above for x=0)
sqrt(x)=exp(0.5*ln(x)) if 0<=x
is very important for the case that the "^" key on a keyboard becomes ever defunct by frequent GPS computings ;-)

Re: Maths - Square Root

Posted: Wed Jul 19, 2017 3:54 pm
by LCMark
This has been added to 'develop' now: http://quality.livecode.com/show_bug.cgi?id=20079

It will be in DP9.