Re: sqrt and Buf question

2020-05-16 Thread ToddAndMargo via perl6-users
On 2020-05-16 14:48, William Michels via perl6-users wrote: Yes, ** stands for exponentiation Thank you!

Re: sqrt and Buf question

2020-05-16 Thread William Michels via perl6-users
Hi Todd, Yes, ** stands for exponentiation. And exponentiation has higher precedence than multiplication. See below (I dropped a few zeros to help clarify): > put 2 * 10 ** 20 2 > put (2 * 10) ** 20 1048576 > put 2 * (10 ** 20) 2 > 20 **

Re: sqrt and Buf question

2020-05-16 Thread ToddAndMargo via perl6-users
On 2020-05-14 22:26, Peter Pentchev wrote: And what is `2 * 100 ** 2000 `? Is that `(2 x 100)^ 2000` ((2 times 100) to the 2000 power? Point 1: exponentiation has a higher priority than multiplication. Point 2:https://rosettacode.org/wiki/Integer_roots Any chance of you answering the questio

Re: sqrt and Buf question

2020-05-15 Thread ToddAndMargo via perl6-users
On 2020-05-15 12:09, Bruce Gray wrote: On May 14, 2020, at 4:36 PM, ToddAndMargo via perl6-users wrote: On 2020-05-14 08:13, Bruce Gray wrote: On May 14, 2020, at 7:27 AM, ToddAndMargo via perl6-users wrote: Hi All, 1) how do I get 40 or more digits out of sqrt? —snip— Use an Integer

Re: sqrt and Buf question

2020-05-15 Thread Bruce Gray
> On May 14, 2020, at 4:36 PM, ToddAndMargo via perl6-users > wrote: > > On 2020-05-14 08:13, Bruce Gray wrote: >>> On May 14, 2020, at 7:27 AM, ToddAndMargo via perl6-users >>> wrote: >>> >>> Hi All, >>> >>> 1) how do I g

Re: sqrt and Buf question

2020-05-14 Thread Peter Pentchev
On Thu, May 14, 2020 at 02:36:30PM -0700, ToddAndMargo via perl6-users wrote: > On 2020-05-14 08:13, Bruce Gray wrote: > > > > > > > On May 14, 2020, at 7:27 AM, ToddAndMargo via perl6-users > > > wrote: > > > > > > Hi All, > &g

Re: sqrt and Buf question

2020-05-14 Thread ToddAndMargo via perl6-users
On 2020-05-14 05:51, Tobias Boege wrote: On Thu, 14 May 2020, ToddAndMargo via perl6-users wrote: Hi All, 1) how do I get 40 or more digits out of sqrt? Meaningful digits? Not possible as sqrt uses limited precision. I think the IEEE 754 doubles that I would suspect to be used internally

Re: sqrt and Buf question

2020-05-14 Thread ToddAndMargo via perl6-users
On 2020-05-14 08:13, Bruce Gray wrote: On May 14, 2020, at 7:27 AM, ToddAndMargo via perl6-users wrote: Hi All, 1) how do I get 40 or more digits out of sqrt? —snip— Use an Integer Root algorithm on ($number-you-want-the-root-of * 100 ** $number-of-digits-you-want), then shift the

Re: sqrt and Buf question

2020-05-14 Thread Bruce Gray
> On May 14, 2020, at 7:27 AM, ToddAndMargo via perl6-users > wrote: > > Hi All, > > 1) how do I get 40 or more digits out of sqrt? —snip— Use an Integer Root algorithm on ($number-you-want-the-root-of * 100 ** $number-of-digits-you-want), then shift the decimal p

Re: sqrt and Buf question

2020-05-14 Thread ToddAndMargo via perl6-users
On 2020-05-14 05:51, Tobias Boege wrote: On Thu, 14 May 2020, ToddAndMargo via perl6-users wrote: Hi All, 1) how do I get 40 or more digits out of sqrt? Meaningful digits? In this instance, I do not care about meaningful. I only care about the noise. Just has to be repeatable. I may

Re: sqrt and Buf question

2020-05-14 Thread Tobias Boege
On Thu, 14 May 2020, ToddAndMargo via perl6-users wrote: > Hi All, > > 1) how do I get 40 or more digits out of sqrt? > Meaningful digits? Not possible as sqrt uses limited precision. I think the IEEE 754 doubles that I would suspect to be used internally are capped way below 40

sqrt and Buf question

2020-05-14 Thread ToddAndMargo via perl6-users
Hi All, 1) how do I get 40 or more digits out of sqrt? 2) how to I assist those bytes to a 40 (or more) byte long Buf? This obviously does not work: my Num $x = 3.sqrt; my Buf $y = Buf.new($x) Type check failed in initializing element #0 to Buf; expected uint8 but got Num

[perl #127126] [PATCH] Decent sqrt() - makes sqrt(-1+0i) == i

2016-01-09 Thread Christian Bartolomaeus via RT
67 . > > > > > > > > I am glad perl6 supports complex numbers natively. What I am not glad > > is that its definition of i does not agree with mathematics: > > > > % perl6 > > > >> sqrt(-1+0i) > > 6.12323399573677e-17+1i > > &g

Re: [perl #127125] Decent sqrt() - makes sqrt(-1+0i) == i

2016-01-02 Thread Elizabeth Mattijsen
> > > I am glad perl6 supports complex numbers natively. What I am not glad is that > its definition of i does not agree with mathematics: > > % perl6 > >> sqrt(-1+0i) > 6.12323399573677e-17+1i > > Though (-1+0i)**0.5 != 1i for most other platforms, they

Re: [perl #127126] [PATCH] Decent sqrt() - makes sqrt(-1+0i) == i

2016-01-02 Thread Elizabeth Mattijsen
t; its definition of i does not agree with mathematics: > > % perl6 > >> sqrt(-1+0i) > 6.12323399573677e-17+1i > > Though (-1+0i)**0.5 != 1i for most other platforms, they still get > sqrt(-1+0i) right: > > % python > > Python 2.7.10 (default, Oct 23 2015,

[perl #127126] [PATCH] Decent sqrt() - makes sqrt(-1+0i) == i

2016-01-02 Thread via RT
the patch below or just pull https://github.com/rakudo/rakudo/pull/667 . I am glad perl6 supports complex numbers natively. What I am not glad is that its definition of i does not agree with mathematics: % perl6 > sqrt(-1+0i) 6.12323399573677e-17+1i Though (-1+0i)**0.5 != 1i for most

[perl #127125] Decent sqrt() - makes sqrt(-1+0i) == i

2016-01-02 Thread via RT
its definition of i does not agree with mathematics: % perl6 > sqrt(-1+0i) 6.12323399573677e-17+1i Though (-1+0i)**0.5 != 1i for most other platforms, they still get sqrt(-1+0i) right: % python Python 2.7.10 (default, Oct 23 2015, 18:05:06) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.

Re: sqrt

2004-04-28 Thread Dan Sugalski
At 10:29 PM -0400 4/27/04, Matt Fowles wrote: All~ Perhaps it is just the mathematician in me speaking, but I think that a sqrt op might be superfluous and could be replaced with exp as sqrt(x) == exp(x,0.5). I cannot say anything about numerical stability of precision, though, so feel free to

Re: sqrt

2004-04-28 Thread Uri Guttman
>>>>> "MF" == Matt Fowles <[EMAIL PROTECTED]> writes: MF> Perhaps it is just the mathematician in me speaking, but I think that MF> a sqrt op might be superfluous and could be replaced with exp as MF> sqrt(x) == exp(x,0.5). I cannot say anything abou

Re: sqrt

2004-04-27 Thread Peter Behroozi
On Tue, 2004-04-27 at 22:29, Matt Fowles wrote: > All~ > > Perhaps it is just the mathematician in me speaking, but I think that a > sqrt op might be superfluous and could be replaced with exp as sqrt(x) > == exp(x,0.5). I cannot say anything about numerical stability of >

Re: sqrt

2004-04-27 Thread Matt Fowles
All~ Perhaps it is just the mathematician in me speaking, but I think that a sqrt op might be superfluous and could be replaced with exp as sqrt(x) == exp(x,0.5). I cannot say anything about numerical stability of precision, though, so feel free to shoot me down. Matt Dan Sugalski wrote: At 4

Re: sqrt

2004-04-27 Thread Dan Sugalski
At 4:50 PM +0200 4/27/04, Stefan Lidman wrote: >Everything is right, except... you forgot either the -c or -u switch for the diff. (And no, I don't know why the default output from diffs is mostly useless. Just one of those things, I expect) ok resend with -u switch. And it's in. Thanks! --

Re: sqrt

2004-04-27 Thread Stefan Lidman
@ goto NEXT(); } + + +=item B(out NUM, in INT) + +=item B(out NUM, in NUM) + +Set $1 to the square root of $2. + +=cut + +inline op sqrt(out NUM, in INT) :base_core { + $1 = sqrt((FLOATVAL)$2); + goto NEXT(); +} + +inline op sqrt(out NUM, in NUM) :base_core { + $1 = sqrt((FLOATVAL)$2)

Re: sqrt

2004-04-27 Thread Dan Sugalski
At 3:29 AM +0200 4/27/04, Stefan Lidman wrote: This adds a square root op and fixes a typo. It is also my first patch so I might have missed something, please tell me what I did wrong. Everything is right, except... you forgot either the -c or -u switch for the diff. (And no, I don't know why the

sqrt

2004-04-27 Thread Stefan Lidman
/math.ops,v retrieving revision 1.17 diff -r1.17 math.ops 853a854,873 > > > =item B(out NUM, in INT) > > =item B(out NUM, in NUM) > > Set $1 to the square root of $2. > > =cut > > inline op sqrt(out NUM, in INT) :base_