Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Roger Hui
Goodness! I don't know whether to be pleased that I wrote it (I mean, the code is pretty good), or sad that I forgot that I wrote it. On Tue, Dec 22, 2020 at 4:52 PM chris burke wrote: > See also Roger's essay: > > https://code.jsoftware.com/wiki/Essays/Chudnovsky_Algorithm > > On Tue, Dec 22

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread chris burke
See also Roger's essay: https://code.jsoftware.com/wiki/Essays/Chudnovsky_Algorithm On Tue, Dec 22, 2020 at 3:22 PM Hauke Rehr wrote: > > a worthy read, thanks > > I think I fell in love with J in part > due to its notationally pleasant guise > There are so many debates in notation. > I personal

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Roger Hui
> This personal taste notwithstanding, I do appreciate your > aesthetics-based plea for expressions like (x>0)-(x<0), > but I’d rather say x (> - <) 0 instead. (DRY principle) The two expressions are not really comparable as the former predates the latter by about 27 years: (x>0)-(x<0), [Iverson

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Hauke Rehr
a worthy read, thanks I think I fell in love with J in part due to its notationally pleasant guise There are so many debates in notation. I personally prefer τ over π but I’m okay with o.1 and 1p1 meaning πª (I’d like to have 1t1 at my disposal); and I’m unsure about the Triangle of Power but I th

Re: [Jprogramming] A small festive emacs extension

2020-12-22 Thread emacstheviking
Raul, like I said, it was naive and good enough for me for now. All points noted and I will attempt to factor them in as the needs arises. I also considered extending the regex to look for 'define' as well instead etc. Thanks, Sean. On Tue, 22 Dec 2020 at 21:25, Raul Miller wrote: > I don't u

Re: [Jprogramming] A small festive emacs extension

2020-12-22 Thread Raul Miller
I don't use emacs (RSI issues), however, I can see a couple things that I would change in this implementation. Instead of (re-search-backward ": 0$") I would use (re-search-backward ": *0 *$") Or, even better: (re-search-backward ": *0 *(NB\..*)?$") It's fine to use spaces here instead of \s (

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Raul Miller
You're taking a square root there, which cannot be represented rationally. If you want this to work, you'll need to decide on how much precision you need, and use an approximation which is adequate for that precision. You should probably also introduce some words to represent intermediate results

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Roger Hui
May I suggest that you read Conventions Governing Order of Evaluation [Iverson 1966]. On Tue, Dec 22, 2020 at 12:46 PM Hauke Rehr wrote: > IMO the value of right-to-left data flow is > that it reflects the way math notation works. > operatorD ope

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Hauke Rehr
IMO the value of right-to-left data flow is that it reflects the way math notation works. operatorD operatorC operatorB operatorA data is “evaluated” from right to left. -/ I used to consider merely a convenience. Having read Roger’s answers, I guess I might have been wrong. !warning: opinions/ran

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Roger Hui
> Exercise for the reader: What's a "use" of -\ ? (Published in June 1981.) Sorry, -\ in APL, equivalent to -/\ in J for vectors. On Tue, Dec 22, 2020 at 11:48 AM Roger Hui wrote: > There are simpler demonstrations of the use of -/ . See > https://code.jsoftware.com/wiki/Essays/Extended_Prec

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Roger Hui
What Adin Falkoff had to say about right-to-left, esp. regarding in reduction: The major trend that I see in the change from the book to the formal description was a unification of the treatment of scalar operators. There was also at that time a recognition of the value of dispensing completely wi

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Roger Hui
There are simpler demonstrations of the use of -/ . See https://code.jsoftware.com/wiki/Essays/Extended_Precision_Functions#Sine_and_Cosine Exercise for the reader: What's a "use" of -\ ? (Published in June 1981.) On Tue, Dec 22, 2020 at 10:44 AM Devon McCormick wrote: > Thanks everyone for

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Devon McCormick
Thanks everyone for the tips! Bob - your suggestions still stalls: 20j18":%12x*-/chudSeriesa i.2 3.141592653589788641 20j18":%12x*-/chudSeriesa i.3 3.141592653589788641 (Should be 3.14159265358979323846... as we all know :) ) Roger's suggestion will take me longer to translate. I got into

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Roger Hui
In the J source, file vx.c, function jtxpi(), you find an implementation of the Chudnovsky algorithm using extended precision arithmetic. It is in C but it should not be too hard to figure out the J equivalent. static XF1(jtxpi){A e;B p;I i,n,n1,sk;X a,b,c,d,*ev,k,f,m,q,s,s0,t; RZ(w); if(!XDIG(

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread 'robert therriault' via Programming
Hey Devon, Try replacing the ^ with (x:@^) chudSeries=: 13 : '((!6x*x: y)*13591409x+545140134x*x: y)%(!3x*x:y)*(3x^~!x: y)*640320x^3r2+3x*x: y' chudSeries 2 2.59929e_30 chudSeriesa=: 13 : '((!6x*x: y)*13591409x+545140134x*x: y)%(!3x*x:y)*(3x^~!x: y)*640320x(x:@^)3r2+3x*x: y' chudS

Re: [Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Henry Rich
   3!:0 ] 640320x^3r2 8 Henry Rich On 12/22/2020 12:29 PM, Devon McCormick wrote: The Chudnovsky algorithm - https://en.wikipedia.org/wiki/Chudnovsky_algorithm - is supposed to have the fastest convergence for pi (or 1/pi, to be exact). I had tried this one which is OK but only seems to add on

[Jprogramming] Chudnovsky algo for π (Pi) using extended arithmetic

2020-12-22 Thread Devon McCormick
The Chudnovsky algorithm - https://en.wikipedia.org/wiki/Chudnovsky_algorithm - is supposed to have the fastest convergence for pi (or 1/pi, to be exact). I had tried this one which is OK but only seems to add one digit for each power of 10: 6!:2 'pi=. 4*-/%>:+:i. 1e6' 0.0145579 20j18":pi 3.

Re: [Jprogramming] Jupyter Notebook Issue with Latest j 9.02

2020-12-22 Thread bill lam
there are incompatibility, eg u v x y in adverb and conjunction. Make sure the base library and addons have been updated. On Wed, Dec 23, 2020, 12:07 AM John Baker wrote: > This morning I noticed that the Jupyter notebook system I've been using > stopped working for the latest J 9.02. The kern

[Jprogramming] Jupyter Notebook Issue with Latest j 9.02

2020-12-22 Thread John Baker
This morning I noticed that the Jupyter notebook system I've been using stopped working for the latest J 9.02. The kernel ( https://github.com/martin-saurer/jkernel) worked fine for earlier J 9.02 beta releases and still works for J 9.01. The kernel uses the jdo interface. If anyone else is usi

[Jprogramming] A small festive emacs extension

2020-12-22 Thread emacstheviking
Morning. I wrote this quickly, it works for me, YMMV and its as simple as it needs to be, it mostly finds the start and end of the current verb definition. The j-mode I have has compile line compile region compile buffer I offer 'jselverb' which I have bound to C-c C-v as that fits the pattern, i