I would be willing to help, but you have shown a bunch of code without explaining what it does and what you expect.  If you have something that is producing the wrong result, and you tell us what the proper result is, I will have a look.

Henry Rich

On 9/11/2021 6:56 AM, Hauke Rehr wrote:
maybe I found it
but then again, these results look too good to me
ps2 =: 0 -/@:(0,|.)@:((nxt2 ,^:(0~:[) ])^:_)~ ]
(ps2 - ^.@>:)"0 % 2^>:i.5
0 0 0 0 0

Am 11.09.21 um 12:37 schrieb Hauke Rehr:
Hello,

I just wanted to look at some power series,
here is code for ^.@>:
(quite literal translation from the maths)

nxt1 =: [ (^ % (* _1 ^ >:)@]) #@]
ps1 =: 0 +/@:((nxt1 ,^:(0~:[) ])^:_)~ ]

now executing
(ps1 - ^.@>:)"0 % 2^>:i.5
gives
_1.11022e_16 _5.55112e_17 _1.38778e_17 6.93889e_18 0
or
_1.11022e_16 0 2.77556e_17 6.93889e_18 0
depending on J version
not bad

I thought I made an improvement when I rewrote it thus:
nxt2 =: [ (^ % ]) #@]
ps2 =: 0 -/@:((nxt2 ,^:(0~:[) ])^:_)~ ]

but now I get
(ps2 - ^.@>:)"0 % 2^>:i.5
_0.81093 _0.446287 2.77556e_17 _0.121249 0
ouch!

… and now I’d have expected
+/@:(* 1 _1 $~ #)@:
instead of -/@:
not to help with that bad result but it did
_0.81093 _0.446287 _1.38778e_17 _0.121249 0

Okay, this will be representation/fp issues;
still the difference in accuracy puzzles me
when comparing ps1 and ps2 …

Does anyone have an explanation?




--
This email has been checked for viruses by AVG.
https://www.avg.com

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to