## 5 Attosecond Pulse Shaping with an Arbitrary Number \(N\) of Phase-Locked Harmonics  
In the previous sections, attosecond waveform synthesis with three and four harmonics was presented. A generalized scheme to produce attosecond waveforms with a harmonic comb containing \(N\) phase-locked harmonics is described in this section. The results from the phase scan in the four-harmonic case confirm the action of the phase shifter on the radiation. Significantly, phase shifters only alter the radiation that is generated in the undulators downstream of themselves. Consider an undulator chain consisting of \(N\) undulators and a phase shifter in between each pair of consecutive undulators. The arrangement will have \(N-1\) phase shifters, each affecting the phase of the radiation generated in the undulators downstream, if each undulator (U\({}_{i}\)) is used to generate a harmonic (H\({}_{i}\)) of the seed laser. A phase shifter PS\({}_{k}\), placed after the undulator U\({}_{k}\), will affect the phases of all the harmonics H\({}_{k+1}\) to H\({}_{N}\). The phase of each harmonic and the phase difference \(\Delta\varphi_{k,k+1,k+2}\) are given by:  
\[ \begin{split}\varphi_{k}&=\varphi_{k}^{(0)}-\sum_{ i=1,k>1}^{k-1}\tau_{i}\omega_{k}\\ \Delta\varphi_{k,k+1,k+2}&=\varphi_{k+2}^{(0)}+ \varphi_{k}^{(0)}-2\varphi_{k+1}^{(0)}+\tau_{k}\omega_{k}-\tau_{k+1}\omega_{k +2},\end{split}  \tag{7}\]  
where \(\tau_{k}\) is the delay introduced by the phase shifter PS\({}_{k}\). The phase difference \(\Delta\varphi_{k,k+1,k+2}\) is only affected by the phase shifters PS\({}_{k}\) and PS\({}_{k+1}\). In the general case of \(N\) harmon  
Figure 8: Reconstructed attosecond pulses for a phase scan using the phase shifter PS\({}_{3}\). **(a–g)** Evolution of the intensity profile of the attosecond pulses in the attosecond pulse train generated with the harmonic comb containing the harmonics H\({}_{7}\), H\({}_{8}\), H\({}_{9}\), and H\({}_{10}\) of the seed laser, for different values of the phase shifter (PS\({}_{3}\)), corresponding to Figure 7a,h (a), Figure 7b,i (b), Figure 7c,j (c), Figure 7d,k (d), Figure 7e,l (e), Figure 7f,m (t), and Figure 7g,n (g). The error in the reconstruction is indicated as a shaded region in each panel. ics, the reconstruction of the attosecond pulse train requires the \(N-2\) phase difference terms (\(\Delta\varphi_{i,i+1,i+2},\,i=1\) to \((N-2)\)) and amplitudes of \(N\) harmonics. The difference between Equations (5) and (7) showing an opposite effect of the delays introduced by the phase shifters is due to the choice of the sequence of harmonics generated in the undulator chain. In the present discussion of a harmonic comb containing \"\(N\)\" harmonics, the first undulator generates the lowest harmonic, and the subsequent undulators downstream generate harmonics with increasing order with the last undulator generating the highest harmonic. In the four-harmonic case presented in Section 4, the highest harmonic was generated in the first undulator, and the subsequent undulators downstream generated harmonics with decreasing harmonic order. In order to generate a waveform of interest, let us say the shortest attosecond waveform, the phase scans must be performed to obtain the correlation distribution close to a straight line with a positive slope for all the \((N-2)\) pairs of oscillating components. Once a set of three harmonics H\({}_{k}\), H\({}_{k+1}\), and H\({}_{k+2}\) is optimized to obtain the desired correlation distribution of the oscillating components (\(P_{k,k+1},\,P_{k+1,k+2}\)) using PS\({}_{k}\) or PS\({}_{k+1}\), neither of the two phase shifters should be used for the optimization of another set of three harmonics.