[Jprogramming] Tinkering with Taylor (from v8.x)

57 views
Skip to first unread message

Martin Kreuzer

unread,
Aug 25, 2024, 7:12:48 AMAug 25
to fo...@jsoftware.com
Dear all -

Have consulted the relevant sections of the Dictionary, and
in my old v8.07 console, I've started to go through the examples.

While exploring Taylor/ MacLaurin (t. t: T.)   I've wondered whether I'd be able to use it from my current v9.6.0 console as well.

This has been my initial (admittedly crude) workaround
(some excerpt from my startup script):

-----
spwnd=: v8x=: 1 : 0
 load '~system/main/task.ijs'
 NB. path is specifically tailored to the situation at station XXX
 rst=. u spawn_jtask_ 'D:\Program Files (non-sys)\j64-807-nonavx\jconsole.cmd'     NB. result from old console
 NB. echo <rst
 ccv=. {{ 0 ". _5}. 3}. y }}     NB. literal to executable conversion (result is first cleaned from surrounding blanks '3,res,5' ??)
 ccv rst
)

NB. Example use:
NB.
NB.    '5*%:225' spwnd
NB. +----------+        NB. echo <rst
NB. ¦   75     ¦
NB. +----------+
NB. 75
NB.    'fib i.13' spwnd
NB. 0 1 1 2 3 5 8 13 21 34 55 89 144
NB.    '0 0 1&p. T. 13 i.7' spwnd
NB. 0 1 4 9 16 25 36
NB.
NB.    '^ t. i.7' v8x                                      NB. Taylor Coefficients
NB. 1 1 0.5 0.166667 0.0416667 0.00833333 0.00138889
NB.    '^ t: i.7' v8x                                      NB. Weighted Taylor
NB. 1 1 1 1 1 1 1
NB.    '^ T. 23 i.7' v8x                                   NB. Taylor Approximation
NB. 1 2.71828 7.38906 20.0855 54.5982 148.413 403.429
-----

The adverb  spwnd  alias  v8x  seems to work; however I've had no success on anything involving more than one line, like in the first example from the Dictionary:

-----
   f=: 1 2 1&p. 
   g=: 1 3 3 1&p. 
   x=: 10%~i=: i.8
   ]c=: (f*g) t. i
1 5 10 10 5 1 0 0
-----

Might be a problem with namespace or something worse. ---

My understanding is that it was part of JE code, and I'm pretty sure that I won't be the person to port that stuff.

Means, for the time being, I'd be content if I'll be able to get a workaround going.

Btw, could somebody kindly point me to some nice description on  t. t: T.  (besides the Dictionary) which will work for my level?

Thanks.

-Martin

Raul Miller

unread,
Aug 25, 2024, 5:11:24 PMAug 25
to fo...@jsoftware.com
Taylor support was removed from the engine in j9, the primitive tokens
were repurposed for threading.

Apparently, we were going to implement library support to replace the
engine support. This was supposed to be easy.

That said, it's not done, yet.

--
Raul
> To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.

Raul Miller

unread,
Aug 25, 2024, 5:17:25 PMAug 25
to fo...@jsoftware.com
p.s. if you want to look at the implementation in c, go to
https://github.com/jsoftware/jsource/tree/j807-release and look in
jsrc/ct.c

FYI,

--
Raul

Henry Rich

unread,
Aug 25, 2024, 5:42:34 PMAug 25
to fo...@jsoftware.com
Yes, I did scripts for d. D. D: but overlooked t. (Taylor series).

Is this a start:

   tco_jcalculus_  =: {{ (u. deriv_jcalculus_ y) 0 }}"0
   tdot_jcalculus_ =: {{ (u. tco_jcalculus_ y) % !y }}"0
   ^ tdot_jcalculus_ i. 6
1 1 0.5 0.166667 0.0416667 0.00833333

?

Henry Rich

Raul Miller

unread,
Aug 25, 2024, 7:04:24 PMAug 25
to fo...@jsoftware.com
That looks promising, but i guess I'd have to run it through the
taylor test suite to see.

--
Raul

R.E. Boss

unread,
Oct 2, 2024, 5:04:19 AM (13 days ago) Oct 2
to fo...@jsoftware.com
A. 1 3 12
47992620

(>:@i.@-@x:@# #. (+/@:< {.)\.) @: (C.^:(1 = L.)) 1 3 12
0

47992620 A. i.13
0 2 4 5 6 7 8 9 10 11 1 3 12

The least I can conclude is that the model of A. is not correct.

Is A. 1 3 12 a bug or a feature?

JVERSION
Engine: j9.6.0-beta19/j64avx2/windows
Build: commercial/2024-09-23T21:54:13/clang-18-1-8/SLEEF=1
Library: 9.6.8
Qt IDE: 2.5.6/6.5.3(6.5.3)
OS Ver: Windows 10 Version 22H2 10.0.19045
Platform: Win 64
Installer: j9.6 install
InstallPath: c:/program files/j9.6
Contact: www.jsoftware.com

R.E. Boss

Henry Rich

unread,
Oct 2, 2024, 9:29:28 AM (13 days ago) Oct 2
to fo...@jsoftware.com
    load'math/calculus'

    ^ taylor i. 5

1 1 0.5 0.166667 0.0416667


taylor and wtaylor have been in for a few betas.  They are very simple, using the book definition.


Henry Rich




On 8/25/2024 5:10 PM, Raul Miller wrote:

Henry Rich

unread,
Oct 2, 2024, 12:10:24 PM (13 days ago) Oct 2
to fo...@jsoftware.com
The model was wrong.  I have corrected it to

   (>:@i.@-@x:@# #. (+/@:< {.)\.) @: (C.^:(2 1 {~ L.)) 1 3 12
47992620

Your incomplete permutation is completed by prepending the missing
values before the anagram index is computed.

Henry Rich

LdBeth

unread,
Oct 2, 2024, 12:29:25 PM (13 days ago) Oct 2
to fo...@jsoftware.com
>>>>> In <AM9P192MB1109F22BB6...@AM9P192MB1109.EURP192.PROD.OUTLOOK.COM>
>>>>> "R.E. Boss" <r.e....@outlook.com> wrote:
> A. 1 3 12
> 47992620

1 3 12 is not a permutation in the typical mathematical sense: i.e. it
has gaps in between the sorted numbers.

Although A. does not signal domain error, and the definition given on jwiki
does not explicitly say it must be a permutation of i.#a or something,
in the old j dictionary it does specify the argument needs to be
"cycle or direct permutation".

https://www.jsoftware.com/help/dictionary/dacapdot.htm

LdBeth

unread,
Oct 2, 2024, 12:57:02 PM (13 days ago) Oct 2
to fo...@jsoftware.com
> A. 1 3 12
> 47992620

I think I figured out, the source code of A. says

// the order of the permutation w: max element of w (could be negative)

Which has inspired me to try where I can insert the missing numbers
to retain the result of monadic A. and I succeeds in a few examples:

A. 1 2 3
0
A. 0 1 2 3
0
A. 1 2 4
12
A. 0 3 1 2 4
12
A. 4 5 1 3 6
180
A. 0 2 4 5 1 3 6
180


Thus A. treats 1 3 12 as abbrev of

0 2 4 5 6 7 8 9 10 11 1 3 2

and

A. 0 2 4 5 6 7 8 9 10 11 1 3 12
47992620


So it is indeed a feature.

---
LdBeth

Cameron Chandoke

unread,
Oct 2, 2024, 6:17:56 PM (12 days ago) Oct 2
to forum, LdBeth
This behavior is listed under point (3.) of More Information in the (C. y) NuVoc page:

3. A completely-described permutation of length n includes each value of  i. n exactly once. If some of those values are omitted, default values are assumed.

  • for permutations y in direct form, omitted values are prepended to the beginning of y before the conversion to cycle form.
  • for permutations y in cycle form, omitted values are assumed to represent cycles of length 1, in other words, positions that are unaffected by the permutation.

To see the complete form of an incomplete permutation, apply C. y twice, which will convert the permutation to canonical form in its original representation:

   C. C. 4 2 6    NB. incomplete direct form: omitted values move to front
0 1 3 5 4 2 6
   C. C. 1 3;2 5  NB. incomplete cycle form: omitted values do not move
+-+---+-+---+
|0|3 1|4|5 2|
+-+---+-+---+

--Cameron
Reply all
Reply to author
Forward
0 new messages