## Attachment 'p128Code.txt'

```   1 NB. From page 128:
2 ip=. +/ .*                              NB. inner product
4 write=. 1!:2&2                          NB. write to screen
5 diag=. (<0 1)&|:                        NB. matrix diagonal
6 uf=. -:@-/@(pm{diag)                    NB. u function
7 rss=. %:@+/@*:                          NB. sq rt of sum of sqs
8 vf=. rss@(pv,uf)                        NB. v function
9 sign=. >:&0 - <&0                       NB. sign of the sine
10 cosf=. %:@((vf + |@uf) % +:@vf)         NB. cosine function
11 sinf=. sign@uf * -@pf % +: @(vf * cosf) NB. sine function
12
13 maxit=. 20
14 s0=. <'it=. 0 { I=. Q=. =/! i.#R=. y'
15 s0=. <'it=. 0 { I=. Q=. =/! i.#R=. y.'
16 s1=. <'loop) \$.=. >(end;\$.){~ x.<|p=. -pv R'
17 s2=. <'v=. %: +/*~p,u=. -: -/ (pm R){ diag R'
18 se=. <'sin=. (sign u)*p%+:v* cos=. %: (v+|u)%+:v'
19 s3=. <'sin=. (sign u)*p%+:v* cos=. %: (v+|u)%+:v'
20 s4=. <'\$.=. >(end;\$.){~ *./0~:-.-|sin,cos'
21 s5=. <'r=. ((cos,-sin),sin,cos) (ia R)} I'
22 s6=. <'Q=. Q ip |:r [ R=. r ip R ip |:r'
23 s7=. <'\$.=. >(loop;\$.){~ maxit<it=. it+1'
24 s8=. <'write ''Number of further iterations or 0?'''
25 s9=. <'\$.=. >(loop;end){~ maxit<it=. it-readkb 1'
26 s10=. <'end) R,:Q'
27 jacobi=. '' : (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10)
28
29 NB. Since the above attempt at function definition fails, here's what
30 NB. the code would look like (defined as an anonymous noun).
31
32 0 : 0
33 it=. 0 { I=. Q=. =/! i.#R=. y.
34 loop) \$.=. >(end;\$.){~ x.<|p=. -pv R
35 v=. %: +/*~p,u=. -: -/ (pm R){ diag R
36 sin=. (sign u)*p%+:v* cos=. %: (v+|u)%+:v
37 \$.=. >(end;\$.){~ *./0~:-.-|sin,cos
38 r=. ((cos,-sin),sin,cos) (ia R)} I
39 Q=. Q ip |:r [ R=. r ip R ip |:r
40 \$.=. >(loop;\$.){~ maxit<it=. it+1
41 write 'Number of further iterations or 0?'
42 \$.=. >(loop;end){~ maxit<it=. it-readkb 1
43 end) R,:Q
44 )
```

## Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
• [get | view] (2010-01-16 03:53:05, 347.1 KB) [[attachment:JacobiMethodEigenvaluesByMcIntyre125_Vec199301_66.jpg]]
• [get | view] (2010-01-16 04:04:51, 305.3 KB) [[attachment:JacobiMethodEigenvaluesByMcIntyre126_Vec199301_66.jpg]]
• [get | view] (2010-01-16 04:06:39, 136.9 KB) [[attachment:JacobiMethodEigenvaluesByMcIntyre127_Vec199301_66.jpg]]
• [get | view] (2010-01-16 04:12:17, 297.4 KB) [[attachment:JacobiMethodEigenvaluesByMcIntyre128_Vec199301_66.jpg]]
• [get | view] (2010-01-16 04:08:12, 229.9 KB) [[attachment:JacobiMethodEigenvaluesByMcIntyre129_Vec199301_66.jpg]]
• [get | view] (2010-01-16 04:08:42, 233.9 KB) [[attachment:JacobiMethodEigenvaluesByMcIntyre130_Vec199301_66.jpg]]
• [get | view] (2010-01-16 04:09:59, 228.2 KB) [[attachment:JacobiMethodEigenvaluesByMcIntyre131_Vec199301_66.jpg]]
• [get | view] (2010-01-16 04:10:50, 212.9 KB) [[attachment:JacobiMethodEigenvaluesByMcIntyre132_Vec199301_66.jpg]]
• [get | view] (2010-01-16 04:11:26, 281.3 KB) [[attachment:JacobiMethodEigenvaluesByMcIntyre133_Vec199301_66.jpg]]
• [get | view] (2010-01-16 19:22:16, 2.8 KB) [[attachment:jacobiMcIntyreSomeCode.txt]]
• [get | view] (2010-01-16 04:20:45, 0.8 KB) [[attachment:p127Code.txt]]
• [get | view] (2010-01-16 04:21:09, 1.8 KB) [[attachment:p128Code.txt]]