## 4 Experiments
```
0: A vector \(d\in\mathbb{R}^{n}\) whose entries are in ascendant order, a vector \(v\in\mathbb{R}^{n}\) with \(\left\|v\right\|_{2}=1\), the index \(i\in\mathbb{Z}^{+}\) of the root to be found, the machine precision \(\epsilon\in\mathbb{R}\)
0: The \(i\)-th root of the secular equation \(\lambda_{i}\in\mathbb{R}\), the vector \(dmlambda=[d_{1}-\lambda_{i}\), \(d_{2}-\lambda_{i},\ldots,d_{n}-\lambda_{i}]^{T}\in\mathbb{R}^{n}\)
1:\(di\gets d_{i}\)
2:\(\eta\gets 1\)
3:\(g(\mu_{i})\gets 1\)
4:if\(i<n\)then
5:\(dip1\gets d_{i+1}\)
6:\(\lambda_{i}\leftarrow(di+dip1)/2\)
7:\(f(\lambda_{i})\gets 1+\phi(\lambda_{i})+\psi(\lambda_{i})\)
8:if\(f(\lambda_{i})>0\)then\(\triangleright\) Zero is on the left half of the interval
9:for\(j=1\)to\(n\)do\(\triangleright\) Move origin to \(d_{i}\)
10:\(\delta_{j}\gets d_{j}-di\)
11:endfor
12:\(\mu_{i}\leftarrow\lambda_{i}-di\)
13:\(dip1\gets dip1-di\)
14:while\(|g(\mu_{i})|>\epsilon\)and\(\left|\frac{\eta}{\mu_{i}}\right|>8\epsilon\)do\(\triangleright\) Find zero
15:\(g(\mu_{i})\gets 1+\phi(\mu_{i})+\psi(\mu_{i})\)
16:\(\Delta_{i}\leftarrow-\mu_{i}\)\(\triangleright\)\(\delta_{i}-\mu_{i}\), but \(\delta_{i}=d_{i}-d_{i}=0\)
17:\(\Delta_{i+1}\gets dip1-\mu_{i}\)\(\triangleright\)\(\delta_{i+1}-\mu_{i}\)
18:\(a\leftarrow(\Delta_{i}+\Delta_{i+1})g(\mu_{i})-\Delta_{i}\Delta_{i+1}(\psi^{ \prime}(\mu_{i})+\phi^{\prime}(\mu_{i}))\)
19:\(b\leftarrow\Delta_{i}\Delta_{i+1}g(\mu_{i})\)
20:\(c\gets g(\mu_{i})-\Delta_{i}\psi^{\prime}(\mu_{i})-\Delta_{i+1}\phi^{ \prime}(\mu_{i})\)
21:if\(a>0\)then
22:\(\eta\leftarrow\frac{2b}{a+\sqrt{a^{2}-4 bc}}\)
23:else
24:\(\eta\leftarrow\frac{a-\sqrt{a^{2}-4 bc}}{2c}\)
25:endif
26:\(\mu_{i}\leftarrow\mu_{i}+\eta\)
27:if\(\mu_{i}=0\)then\(\triangleright\) Avoid division by zero
28:\(\mu_{i}\leftarrow\epsilon\)
29:endif
30:endwhile
31:\(\lambda_{i}\leftarrow\mu_{i}+di\)\(\triangleright\) Return origin to zero
```  
**Algorithm 3** Find \(i\)-th root of the secular equation
```
32 else\(\triangleright\) Zero is on the right half of the interval
33 for\(j=1\)to\(n\)do\(\triangleright\) Move origin to \(d_{i+1}\)
34\(\delta_{j}\gets d_{j}-dip1\)
35 endfor
36\(\mu_{i}\leftarrow\lambda_{i}-dip1\)
37\(di\gets di-dip1\)
38 while\(|g(\mu_{i})|>\epsilon\)and\(\left|\frac{\eta}{\mu_{i}}\right|>8\epsilon\)do\(\triangleright\) Find zero
39\(g(\mu_{i})\gets 1+\phi(\mu_{i})+\psi(\mu_{i})\)
40\(\Delta_{i}\gets di-\mu_{i}\)\(\triangleright\)\(\delta_{i+1}-\mu_{i}\), but \(\delta_{i+1}=d_{i+1}-d_{i+1}=0\)
41\(a\leftarrow(\Delta_{i}+\Delta_{i+1})g(\mu_{i})-\Delta_{i}\Delta_{i+1}(\psi^{ \prime}(\mu_{i})+\phi^{\prime}(\mu_{i}))\)
42\(b\gets\Delta_{i}\Delta_{i+1}g(\mu_{i})\)
43\(c\gets g(\mu_{i})-\Delta_{i}\psi^{\prime}(\mu_{i})-\Delta_{i+1}\phi^{ \prime}(\mu_{i})\)
44 if\(a>0\)then
45\(\eta\leftarrow\dfrac{2b}{a+\sqrt{a^{2}-4 bc}}\)
46 else
47\(\eta\leftarrow\dfrac{a-\sqrt{a^{2}-4 bc}}{2c}\)
48 endif
49\(\mu_{i}\leftarrow\mu_{i}+\eta\)
50\(\triangleright\) Avoid division by zero
51\(\mu_{i}\leftarrow-\epsilon\)
52 endif
53
54 endwhile
55\(\lambda_{i}\leftarrow\mu_{i}+dip1\)\(\triangleright\) Return origin to zero
56 endif
57 else\(\triangleright\)\(i=n\)
58\(dip1\gets d_{n}+1\)\(\triangleright\)\(d_{n}+\left\|\psi\right\|_{2}\)
59\(\lambda_{i}\gets d_{n}+0.5\)\(\triangleright\)\((d_{n}+d_{n+1})/2=(d_{n}+d_{n}+\left\|\psi\right\|_{2})/2\)
60\(f(\lambda_{i})\gets 1+\phi(\lambda_{i})+\psi(\lambda_{i})\)
61 if\(f(\lambda_{i})>0\)then\(\triangleright\) Zero is on the left half of the interval
62 for\(j=1\)to\(n\)do\(\triangleright\) Move origin to \(d_{n}\)
63\(\delta_{j}\gets d_{j}-di\)
64 endfor
65\(\mu_{i}\leftarrow\lambda_{i}-di\)
66 while\(|g(\mu_{i})|>\epsilon\)and\(\left|\frac{\eta}{\mu_{i}}\right|>8\epsilon\)do\(\triangleright\) Find zero
67\(g(\mu_{i})\gets 1+\phi(\mu_{i})+\psi(\mu_{i})\)
68\(\Delta_{i}\leftarrow-\mu_{i}\)\(\triangleright\)\(\delta_{n}-\mu_{i}\), but \(\delta_{n}=d_{n}-d_{n}=0\)
69\(\Delta_{i-1}\leftarrow\delta_{i-1}-\mu_{i}\)\(\triangleright\)\(d_{n-1}-\lambda_{i}=(d_{n-1}-d_{n})-(\lambda_{i}-d_{n})\)
70\(a\leftarrow(\Delta_{i-1}+\Delta_{i})g(\mu_{i})-\Delta_{i-1}\Delta_{i}(\psi^{ \prime}(\mu_{i})+\phi^{\prime}(\mu_{i}))\)
71\(b\leftarrow\Delta_{i-1}\Delta_{i}g(\mu_{i})\)
72\(c\gets g(\mu_{i})-\Delta_{i-1}\psi^{\prime}(\mu_{i})-\Delta_{i}\phi^{ \prime}(\mu_{i})\)
73 if\(a<0\)then\(\triangleright\) Notice that relational operator changes
74\(\eta\leftarrow\dfrac{2b}{a-\sqrt{a^{2}-4 bc}}\)\(\triangleright\) Notice that square's sign changes
75 else\(\eta\leftarrow\dfrac{a+\sqrt{a^{2}-4 bc}}{2c}\)\(\triangleright\) Notice that square's sign changes
76 endif
77\(\mu_{i}\leftarrow\mu_{i}+\eta\)
```  
**Algorithm 3**_Cont._```
79:if\(\mu_{i}=0\)then\(\triangleright\) Avoid division by zero
80:\(\mu_{i}\gets e\)
81:endif
82:endwhile
83:\(\lambda_{i}\leftarrow\mu_{i}+di\)\(\triangleright\) Return origin to zero
84:else\(\triangleright\) Zero is on the right half of the interval
85:for\(j=1\)to\(n\)do\(\triangleright\) Move origin to \(d_{n+1}=d_{n}+\left\lVert v\right\rVert_{2}\)
86:\(\delta_{j}\gets d_{j}-dip1\)
87:endfor
88:\(\mu_{i}\leftarrow\lambda_{i}-dip1\)
89:while\(\left|g(\mu_{i})\right|>e\)and\(\left|\frac{\eta}{\mu_{i}}\right|>8e\)do\(\triangleright\) Find zero
90:\(g(\mu_{i})\gets 1+\phi(\mu_{i})+\psi(\mu_{i})\)
91:\(\Delta_{i}\leftarrow\delta_{i}-\mu_{i}\)
92:\(\Delta_{i-1}\leftarrow\delta_{i-1}-\mu_{i}\)
93:\(a\leftarrow(\Delta_{i-1}+\Delta_{i})g(\mu_{i})-\Delta_{i-1}\Delta_{i}(\psi^{ \prime}(\mu_{i})+\psi^{\prime}(\mu_{i}))\)
94:\(b\leftarrow\Delta_{i-1}\Delta_{i}g(\mu_{i})\)
95:\(c\gets g(\mu_{i})-\Delta_{i-1}\psi^{\prime}(\mu_{i})-\Delta_{i}\psi^{ \prime}(\mu_{i})\)
96:if\(a<0\)then\(\triangleright\) Notice that relational operator changes
97:\(\eta\leftarrow\frac{2b}{a-\sqrt{a^{2}-4 bc}}\)\(\triangleright\) Notice that square's sign changes
98:else
99:\(\eta\leftarrow\frac{a+\sqrt{a^{2}-4 bc}}{2c}\)\(\triangleright\) Notice that square's sign changes
100:endif
101:\(\mu_{i}\leftarrow\mu_{i}+\eta\)
102:if\(\mu_{i}=0\)then\(\triangleright\) Avoid division by zero
103:\(\mu_{i}\leftarrow-e\)
104:endif
105:endwhile
106:\(\lambda_{i}\leftarrow\mu_{i}+dip1\)\(\triangleright\) Return origin to zero
107:endif
108:endif
109:for\(j=1\)to\(n\)do
110:\(dlambda_{j}\leftarrow\delta_{j}-\mu_{i}\)\(\triangleright\)\(d_{j}-\lambda_{i}=(d_{j}-d_{l})-(\lambda_{i}-d_{l})\), \(I=i\) or \(i+1\)
11:endfor
```

**Algorithm 3**_Cont_.