Magn. Reson., 2, 175–186, 2021 Open Access https://doi.org/10.5194/mr-2-175-2021 © Author(s) 2021. This work is distributed under the Creative Commons Attribution 4.0 License.

Approximate representations of shaped pulses using the analysis method

Timothy Crawley and Arthur G. Palmer III Department of Biochemistry and Molecular Biophysics, Columbia University, 630 West 168th Street, New York, NY 10032, United States Correspondence: Arthur G. Palmer III ([email protected])

Received: 11 January 2021 – Discussion started: 15 January 2021 Revised: 19 March 2021 – Accepted: 23 March 2021 – Published: 16 April 2021

Abstract. The evolution of nuclear spin magnetization during a radiofrequency pulse in the absence of relax- ation or coupling interactions can be described by three Euler angles. The Euler angles, in turn, can be obtained from the solution of a Riccati ; however, analytic solutions exist only for rectangular and hyperbolic-secant pulses. The is used to obtain new approximate solutions to the Riccati equation for shaped radiofrequency pulses in nuclear magnetic resonance (NMR) spectroscopy. The re- sults of even relatively low orders of approximation are highly accurate and can be calculated very efficiently. The results are extended in a second application of the homotopy analysis method to represent relaxation as a perturbation of the magnetization trajectory calculated in the absence of relaxation. The homotopy analysis method is powerful and flexible and is likely to have other applications in magnetic resonance.

1 Introduction ical calculation in which the shaped pulse is represented by a of K short rectangular pulses with appropriate am- Numerous aspects of nuclear magnetic resonance (NMR) plitudes and phases. Thus, the propagator for a shaped pulse spectroscopy are formulated in terms of differential equa- expressed in the Cartesian basis is given by the following tions, few of which have closed-form analytical solutions. (Siminovitch, 1995): In an era characterized by ever-increasing computational ca- − − − pabilities, numerical solutions to such differential equations U = e iγ (τp)Iz e iβ(τp)Ix e iα(τp)Iz are always possible and are frequently the preferred approach " + β(τ ) − β(τ ) # −iχ (τp) p − iχ (τp) p e cos( 2 ) ie sin( 2 ) for applications such as data analysis. However, approximate = − β(τ ) + β(τ ) − −iχ (τp) p iχ (τp) p solutions can provide useful formulas and insights that are ie sin( 2 ) e cos( 2 ) difficult to discern from purely numerical results. K Y As one example, the net evolution of the magnetization = Uk, (1) of an isolated spin during a radiofrequency pulse, i.e. in the k=1 absence of relaxation and scalar or other coupling interac- in which χ ±(τ ) is given as follows: tions, can be described by three rotations with Euler an- p gles α(τ ), β(τ ), and γ (τ ), in which τ is the pulse length ± p p p p χ (τ ) = [α(τ ) ± γ (τ )]/2, (2) (Zhou et al., 1994; Siminovitch, 1997a,b). Shaped pulses, p p p in which the amplitude (Rabi frequency), phase, or radiofre- Ik are the Cartesian spin operators, and the product is time- quency are time dependent, are widely applied in modern ordered from right to left. The propagator for the kth rectan- NMR spectroscopy and other magnetic resonance techniques gular pulse segment is given as follows: (Geen and Freeman, 1991; Emsley and Bodenhausen, 1992;  ∗ ∗  Kupce˘ et al., 1995; Cavanagh et al., 2007). The Euler angles κ (τp) −iη (τp) Uk = , (3) for an arbitrary shaped pulse can be extracted from a numer- −iη(τp) κ(τp)

Published by Copernicus Publications on behalf of the Groupement AMPERE. 176 T. Crawley and A. G. Palmer III: HAM for shaped pulses in which κ(τp) and η(τp) are given by the following: (Silver et al., 1985; Zhou et al., 1994; Rourke, 2002). Ap- proximate solutions for arbitrary shaped pulses have been de- κ(τp) = cos(ωek1tk/2) + i cosθk sin(ωek1tk/2) rived by the for the limits of small, using iφk Eq. (11), and large, using Eq. (5), resonance offsets (Li et al., η(τp) = e sinθk sin(ωek1tk/2). (4) 2014); however, perturbation theory is unwieldy to apply to In Eq. (4), ω1k, φk, and 1tk are the radiofrequency field a high order and, obviously, depends on the perturbation pa- strength, phase angle, and duration of the kth pulse segment; rameters being small in some respects. k is the resonance offset in the rotating frame of refer- The homotopy analysis method (HAM) is a fairly recent ence during the kth pulse segment (and is constant if the off- development, first reported in 1992 (Liao, 1992), for ap- = 2 + 2 1/2 proximating solutions to differential equations, particularly set is fixed); ωek (ω1k k) is the effective field; and −1 θk = tan (ω1k/k) is the tilt angle. Values of α(τp), β(τp), nonlinear ones. HAM does not depend on small parame- and γ (τp) are then obtained from the matrix elements of U. ters, unlike perturbation theory, and has proven powerful in a Alternatively, the Euler angles can be determined from the number of applications outside of NMR spectroscopy (Liao, solution of the following Riccati equation (Zhou et al., 1994): 2012). The present paper illustrates HAM by application to the solutions of Eqs. (5) and (11) and, subsequently, by ex- df (t) 1 1 = ω+(t)f 2(t) + i(t)f (t) + ω−(t), (5) tension to the Bloch equations, including relaxation. dt 2 2 in which the following applies: 2 Theory

β(t) f (t) = tan eiγ (t), (6) In , a pair of functions defining different topologi- 2 cal spaces are said to be homotopic if the shape defined by

± one function can be continuously transformed (deformed in where ω (t) = ωx(t) ± iωy(t) and ωx(t) and ωy(t) are the the lexicon of topology) into the shape defined by the other. Cartesian amplitude components of the radiofrequency field Analogously, the essence of HAM is to map a function of in- in the rotating frame of reference. After solution of the Ric- terest, here y(t), to a second function, 8(t;q), which has a cati equation, β(τp) and γ (τp) are obtained from the mag- known solution and is a function of both t and an embedding nitude and argument of f (τp), and the value of α(τp) is ob- parameter q ∈ [0,1]. tained by integration as follows: This relationship is established by constructing the homo-

τp topy as follows (Liao, 2012): Z α(τp) = dt{ωx(t)sin[γ (t)] − ωy(t)cos[γ (t)]}/sin[β(t)]. (7)     H 8(t;q) : q = (1 − q)L 8(t;q) − y0(t) 0   − qc0H(t)N 8(t;q) , (12) The Riccati equation can be transformed into a second-order differential equation as follows: in which L[] is a linear (differential) operator, and N [] is an (nonlinear differential) operator satisfying the following: " # d2y(t) dlnω−(t) dy(t) 1 − + i(t) + |ω(t)|2y(t) = 0, (8) dt2 dt dt 4 L[0] = 0 (13) N y(t) = 0, (14) by using the following definition:   where y0(t) is an initial approximation for the desired so- dln y(t) 1 − 6= = − ω (t)f (t). (9) lution y(t), c0 0 is a convergence control parameter, and dt 2 H (t) 6= 0 is an auxiliary function (vide infra). When q = 0, A more compact form is obtained by defining the following: the homotopy becomes as follows:    t  H[8(t;0) : 0] = L 8(t;0) − y (t) . (15) Z 0 ωˆ −(t) = exp i (t0)dt0 ω−(t), (10)   Therefore, when H[8(t;0) : 0] = 0, Eq. (13) requires 0 8(t,0) = y0(t). Similarly, when q = 1, the homotopy be- to yield the following: comes as follows:

 −  d2y(t) dln ωˆ (t) dy(t) 1 H[8(t;1) : 1] = −c0H(t)N [8(t;1)]. (16) − + |ω ˆ (t)|2y(t) = 0. (11) dt2 dt dt 4 Therefore, when H[8(t;1) : 1] = 0, Eq. (14) requires The Riccati differential equation only can be solved ana- 8(t,1) = y(t). Stated more succinctly, as q increases from lytically for a single rectangular or hyperbolic-secant pulse 0 → 1, 8(t;q) deforms from the initial approximation y0(t)

Magn. Reson., 2, 175–186, 2021 https://doi.org/10.5194/mr-2-175-2021 T. Crawley and A. G. Palmer III: HAM for shaped pulses 177 to the exact solution y(t). To proceed, the Maclaurin series the following: for 8(t;q) is assumed to exist as follows: d2y (t) dlnωˆ −(t) dy (t) ∞ 1 − 1 X n 2 8(t;q) = yn(t)q , (17) dt dt dt  −  ! n=0 d2y (t) dln ωˆ (t) dy (t) 1 = c 0 − 0 + |ω ˆ t |2y t 0 2 ( ) 0( ) in which yn(t) is given by the following: dt dt dt 4 c 1 dn8(t;q) = 0 |ω ˆ (t)|2, (25) y (t) = . (18) 4 n ! n n dq q=0 in which the final line is obtained using dy0(t)/dt = 0. This Conditions concerning convergence of the series are dis- differential equation does not contain a term proportional to cussed by Liao(2012). Equation (17) has the desired prop- y1(t). Hence, the homogenous equation (setting the right- erty 8(t;0) = y0(t) and yields the following: hand side to 0) can be solved by two successive integrations, ∞ and the inhomogeneous solution is obtained by the technique X 8(t;1) = y(t) = yn(t). (19) of variation of parameters (Arfken et al., 2013). The solution n=0 is as follows:

HAM then consists of successively determining yn(t), begin- t t0 Z Z ning with the initial approximation y0(t), until y(t) is approx- c0 − 0 + 00 00 0 y1(t) = ωˆ (t ) ωˆ (t )dt dt . (26) imated to the desired accuracy. The choices of L[], y0(t), c0, 4 and H(t) provide considerable flexibility in finding approxi- 0 0 mate solutions to differential equations. For simplicity in the The higher-order approximations yn(t) are obtained in a following, the auxiliary function is H(t) = 1. similar fashion. The nth derivative, with respect to q of The iterative algorithm in HAM is illustrated by applica- Eq. (22), yields the following (for n > 1): tion to the second-order differential form of the Riccati equa- tion. In the first example, the nonlinear operator is obtained dn−18(t;q) dn8(t;q) − nL + (1 − q)L from Eq. (11) as follows: dqn−1 dqn 2  ˆ −  n−1 n   d g(t) dln ω (t) dg(t) 1 2 d   d   N g(t) = − + |ω ˆ (t)| , (20) = nc0 N 8(t;q) + qc0 N 8(t;q) . (27) dt2 dt dt 4 dqn−1 dqn in which g(t) is an arbitrary function. The linear operator is Executing the derivatives, taking the limit q → 0, and divid- chosen to be the following: ing both sides of the equation by n! gives the following: 2  ˆ −    d g(t) dln ω (t) dg(t) 2  −  L g(t) = − , (21) d yn(t) dln ωˆ (t) dyn(t) dt2 dt dt − dt2 dt dt and the initial approximation is y0(t) = 1. 2  −  nd yn−1(t) dln ωˆ (t) dyn−1(t)o From the relationships of Eqs. (13) and (14) embedded in = (c + 1) − 0 dt2 dt dt the initial homotopy, Eq. (12), the zeroth-order deformation 1 2 equation is defined as follows (Liao, 2012): + c |ω ˆ (t)| yn− (t), (28) 4 0 1 (1 − q)L8(t;q) − y (t) = qc N 8(t;q). (22) 0 0 with the solution obtained by the same approach as for The derivative of Eq. (22), with respect to q, yields the Eq. (26), as follows: first-order deformation equation as follows: yn(t) = (c0+1)yn−1(t) d8(t;q) −  ; −  + − t t0 L 8(t q) y0(t) (1 q)L Z Z dq c0 − 0 + 00 00 00 0 + ωˆ (t ) ωˆ (t )yn−1(t )dt dt . (29)   d   4 = c N 8(t;q) + qc N 8(t;q) . (23) 0 0 0 0 dq The limit q → 0 gives the following: Successive use of Eqs. (26) and (29) allows y(t) and, hence, f (t) to be determined to arbitrary accuracy, as follows: d8(t;q)    −L 8(t;0) − y0(t) + L = c0N [8(t;0)]       PN dym(t) dq q=0 −2 dln y(t) −2 = f (t) = = m 0 dt , (30)     ω−(t) dt ω−(t) PN L y1(t) = c0N y0(t) , (24) n=0yn(t) in which the second line is obtained using 8(t;0) = y0(t) in which N is the order of approximation. For complete- and Eq. (18). Substituting for N [], L[], and y0(t) yields ness, the derivatives of Eqs. (26) and (29) are, respectively, https://doi.org/10.5194/mr-2-175-2021 Magn. Reson., 2, 175–186, 2021 178 T. Crawley and A. G. Palmer III: HAM for shaped pulses as follows: The nth-order deformation equation for n > 1 is as fol- t lows: Z dy1(t) c0 − + 0 0 = ωˆ (t) ωˆ (t )dt (31) 2   dt 4 d yn(t) dln[ω(t)] dyn(t) 1 2 − + i + ω (t)yn(t) 0 dt2 dt dt 4 dyn(t) dyn−1(t) 2 = (c + 1) d y − (t) dln[ω(t)] dy − (t) 0 = + c { n 1 − n 1 dt dt (1 0) 2 t dt dt dt Z c0 − + 0 0 0 1 2 dyn−1(t) + ωˆ (t) ωˆ (t )yn− (t )dt . (32) + ω (t)yn−1(t)} − ic0 , (40) 4 1 4 dt 0 with the following solution: Results obtained using y0(t) = 1, together with Eqs. (26), (29), and (30), will be called method 1 in the following dis- yn(t) =(1 + c0)yn−1(t) cussion. The iterated form of the above expressions for yn(t) t 0 0 have similarities to the Fourier integrals obtained from aver- Z 2 δ(t) δ(t ) dy − (t ) −ic  sin − n 1 dt0. (41) age Hamiltonian theory by Warren(1984). 0 ω(t0) 2 2 dt0 The above choices of L[] and y0(t) are not unique. Dif- 0 ferent choices lead to different series approximations and, Each y (t) is proportional to n, and these results yield the hence, to different qualitative and quantitative results. As a n following power series in  for y(t): second example, (t) =  is assumed to be fixed and only amplitude-modulated pulses ω(t) with x phase are consid- N X ered (these assumptions can be relaxed as needed). Returning y(t) = y0(t) + (2 + c0)yn(t), (42) to Eq. (8), the homotopy is defined as follows: n=1 d2g(t) dln[ω(t)]  dg(t) N g(t) = − + i which is substituted into Eq. (30) to obtain f (t). Results us- dt2 dt dt ing Eqs. (39), (41), and (42) will be called method 2 in the 1 following discussion. For completeness, the derivatives of + ω2(t)g(t) (33) 4 Eqs. (39) and (41) are as follows: 2   d g(t) dln[ω(t)] dg(t) 1 2 t L g(t) = − + ω (t)g(t) (34) Z  0   0  dt2 dt dt 4 dy1(t) ω(t) δ(t) δ(t ) δ(t ) 0 = −ic0 cos − sin dt (43) 1  dt 2 2 2 2 y0(t) = cos δ(t) , (35) 0 2 t t dyn(t) dyn−1(t) ω(t) Z 2 Z = (1+c0) − ic0 δ(t) = ω(t0)dt0. (36) dt dt 2 ω(t0) 0 0 0 0 δ(t) δ(t ) dy − (t ) × cos − n 1 dt0. (44) This choice of y0(t) satisfies the following: 2 2 dt0 d2y (t) dln[ω(t)] dy (t) 1 0 − 0 + ω2(t)y (t) = 0, (37) dt2 dt dt 4 0 2.1 Methods and is the exact on-resonance solution for y(t). Con- Numerical integration was performed using the trapezoid sequently, the first-order deformation equation leads to method implemented in Python 3.6. Pulse shapes were dis- the following: cretized in 1000 increments. Rectangular pulses were simu- 2 lated using ω /(2π) = 25000 Hz and an on-resonance 90◦ d y1(t) dln[ω(t)] dy1(t) 1 2 1 − + ω (t)y1(t) = dt2 dt dt 4 pulse length of 10.0 µs or ω1/(2π) 250 Hz and an on- resonance 90◦ pulse length of 1 ms. EBURP-2 (Geen and dy0(t) = −ic  . (38) Freeman, 1991) and Q5 (Emsley and Bodenhausen, 1992) 0 dt pulses were simulated using a maximum ω1/(2π) = 9000 Hz The solutions to the homogeneous equation (setting the right- and 90◦ pulse lengths of 455.2 and 504.9 µs, respectively. ± = ±iδ(t)/2 hand side to 0) are y (t) e . The method of variation REBURP (Geen and Freeman, 1991) pulses were simu- of parameters then gives the inhomogeneous solution as fol- ◦ lated using a maximum ω1/(2π) = 10000 Hz and a 180 lows: pulse length of 626.5 µs. WURST-20 (Kupce˘ and Freeman, t 1995) pulses were simulated using a maximum ω /(2π) = Z δ(t) δ(t0) δ(t0) 1 y (t) = −ic  sin − sin dt0. (39) 9512 Hz, a frequency sweep of 50 000 Hz, and a pulse length 1 0 2 2 2 0 of 440.0 µs.

Magn. Reson., 2, 175–186, 2021 https://doi.org/10.5194/mr-2-175-2021 T. Crawley and A. G. Palmer III: HAM for shaped pulses 179

Equation (7) can be recast as follows: In contrast to the results of method 1, the power series for y(t) obtained, using method 2 with c0 = −1, even to the τp i Z third order in , is accurate for β(τp) only to slightly more α(τ ) = dtω+(t)f ∗(t) − ω−(t)f (t) than /ω = 1. When c = −0.925, the third-order power p 4 1 0 0 series has improved accuracy for resonance offsets up to nearly /ω = 2. However, further increases in accuracy at × {1 + |f (t)|2}/|f (t)|2, (45) 1 larger resonance offsets require very large orders of approx- imation N in Eq. (42). For example, extending the accuracy for numerical calculations. Alternatively, α(τ ) can be ob- p of the power series for β(τ ) to offsets /ω = 3.5 requires tained from the argument of f (τ ) calculated for the time- p 1 p N = 50. The differences between the results of method 1 and reversed pulse (Li et al., 2014). The latter is more compu- method 2 reflect the inevitable shortcomings of power series tationally demanding, but more numerically stable, and was and perturbation approaches when the expansion parameter used for the results presented herein. is not small. A more challenging example is given by the 90◦ EBURP- 2.2 Results and discussion 2 pulse (Geen and Freeman, 1991). In principle, the integrals In the present applications, HAM converts the second-order in Eqs. (26) and (29) can be performed analytically because Riccati differential equation, Eq. (8), which cannot be solved the pulse shape is expressed as a Fourier series (as are other directly, into a series of second-order differential equations pulses in the BURP (Geen and Freeman, 1991) and SNOB (Kupce˘ et al., 1995) families). In practice, the number of that have convenient solutions. The choice of y0(t) = 1 in method 1 leads to obtaining simple iterative solutions that terms that must be calculated becomes very large, and nu- can be calculated very efficiently. The form of y (t) given in merical integration is much more efficient. Calculations us- 0 = − Eq. (36) could also be used in Eq. (24) to obtain an alternative ing method 1 are shown in Fig.2. With c0 1, the fifth- order approximation is extremely accurate compared with expression for y1(t) to be substituted into Eqs. (29) and (30). The resulting first-order expressions for y(t) are usually more numerical calculations using Eqs. (1)–(3) (Fig.2a–c). With c0 = −0.925 (Fig.2d–f), even the small deviations observed accurate than the first-order results obtained using y0(t) = 1, but this advantage becomes less pronounced at higher orders for the fifth-order HAM approximation are eliminated, and of approximation and comes at increased computational cost. the third-order result is accurate, except at the edge of the Thus, Eqs. (26), (29), and (30) are most suitable in practice. excitation band. In contrast, perturbation theory or power- A first example of the results of the above analysis is series expansions (method 2) are extremely poor at repro- given for a rectangular 90◦ pulse in Fig.1. The integrals in ducing β(τp), essentially failing as soon as  is non-zero (not Eqs. (26) and (29) can be performed analytically for a rectan- shown). The accuracy of the method 1 approximations over the full range of resonance offsets shows that HAM, with an gular pulse with amplitude ω1. For example, using Eq. (26) yields the following: appropriate choice of linear operator and starting functions, can provide approximate solutions valid far beyond the range c ω2 c ω2t of perturbation theory. 0 1  it  0 1 ◦ y1(t) = 1 − e + i ; (46) The Gaussian Q5 90 pulse (Emsley and Bodenhausen, 42 4 1992) has a more complicated amplitude modulation pro- however, analytic calculations of higher order yn(t) do not file than the EBURP-2 pulse and requires higher orders of have advantages over numerical integration. As shown in approximation to obtain accurate results. Results obtained Fig.1a, b, the second- and third-order results obtained with for method 1 with fifth- and seventh-order approximations method 1 and c0 = −1 are nearly indistinguishable from the are shown in Fig.3. The seventh-order results are highly exact result of Eq. (3) (using τp = 1τk) over the range of accurate for both c0 = −1 and c0 = −0.925. The choice of 1/2 resonance offsets from 0 to /ω1 = 15 . The first-order c0 = −0.925 has a remarkable effect in terms of increasing result provides a highly accurate estimate of γ (τp) but over- the accuracy the fifth-order approximation to nearly that of estimates β(τp). The role of the convergence control parame- the seventh-order result. ◦ ter c0 is illustrated in Fig.1c, d. A value of c0 = −0.925 was The application of HAM is not limited to 90 pulses or chosen, using Eqs. (46) and (30), to scale the first-order result to amplitude-modulated pulses. Figure4 shows the perfor- ◦ for β(τp) to be equal to π/2 at  = 0. As shown, the result- mance of method 1 for the 180 REBURP (Geen and Free- ing first-order result, using method 1, is now nearly exact at man, 1991) and WURST-20 inversion (Kupce˘ and Freeman, all resonance offsets. In the present application, adjusting the 1995) pulses. As for the EBURP-2 pulse, the fifth-order ap- convergence control parameter provides accuracy equivalent proximation for the REBURP pulse is highly accurate for to 1 or 2 additional higher orders of approximation. Remark- both c0 = −1 and c0 = −0.925. The third-order approxima- ◦ ably, this same value of c0 works well for a rectangular 180 tion also is highly accurate when c0 = −0.925. The WURST- pulse (not shown) and 90◦ EBURP-2, 90◦ Q5, and 180◦ RE- 20 pulse uses a linear frequency shift, generated by apply- BURP and WURST inversion pulses (vide infra). ing a quadratic phase shift during the pulse, and is an exam- https://doi.org/10.5194/mr-2-175-2021 Magn. Reson., 2, 175–186, 2021 180 T. Crawley and A. G. Palmer III: HAM for shaped pulses

◦ Figure 1. HAM approximations for on-resonance 90 rectangular pulse with ω1/(2π) = 25000 Hz. Exact calculation of Euler angles β(τp) and γ (τp) (black line). For a rectangular pulse, α(τp) = γ (τp). First-order (blue dotted line), second-order (reddish-purple dashed line), and third-order (orange dash–dot–dotted line) HAM results using method 1. The third-order result is found using the power series of method 2 (green dash-dotted line). Results are shown for (a, b) c0 = −1 and (c, d) c0 = −0.925. The exact, second-order HAM and third-order HAM curves for method 1 are virtually indistinguishable. ple of a phase-modulated or complex waveform. Again, the The argument of the first-order approximation of f (t) is a more complicated waveform requires higher order approx- good estimate of the phase γ (τp) of the transverse magneti- imation, but 11th-order, with c0 = −1, or ninth-order, with zation following the pulse. As noted above, the phase α(t) is c0 = −0.925, results are highly accurate. obtained by repeating the calculation with the time-reversed Method 2 yields a power series for y(t). If c0 = −1, pulse. Therefore, as concluded from the perturbation theory, the resulting series is identical to the power series expan- an amplitude-modulated shaped pulse acts as an ideal rota- sion obtained from perturbation theory (Li et al., 2014), tion of the angle β(τp) preceded and followed by time delays while c0 = −0.925 provides additional accuracy. However, τα and τγ over the frequency range for which the first-order as noted above, the power series requires very high or- approximation holds (Lescop et al., 2010; Li et al., 2014), as ders N to obtain accuracy comparable to results from mod- in the following: est orders using method 1. Thus, method 1 is much more τp Z powerful for general calculations; however, the power se- 1  0  0 τα =   sin δ(τp − t ) dt (48) ries leads to a convenient expression for the near-resonance sin δ(τp) phase shift γ (τp). The first-order power series for y(t), 0 τp assuming c0 = −1, yields the following: Z 1  0  0 τγ =   sin δ(t ) dt . (49) sin δ(τp) 0 h i t h 0 i h 0 i δ(t) + R δ(t) − δ(t ) δ(t ) 0 ◦ sin 2 i cos 2 2 sin 2 dt For a 90 pulse, the above equations can be written com- f (t) = 0 t pactly as follows: h i h 0 0 i h 0 i δ(t) − R δ(t ) − δ(t ) δ(t ) 0 τ cos 2 i sin 2 2 sin 2 dt p 0 Z 0 τ + iτ = eiδ(t ) t0.  t  α γ d (50)   Z δ(t)   0  0 ≈ tan 1 + i sin δ(t ) dt , (47) 0 2 sin[δ(t)] 0 The ratios τα/τp and τγ /τp are the average projections of a unit vector onto the z axis and −y axis, respectively, over the in which the second equality is the expansion to first order in duration of the pulse (for a vector is oriented along the z axis , and the resulting trigonometric functions have been sim- at time 0). plified. This result is identical to the previously reported re- The above explications have focused on solutions to the sult from the first-order perturbation theory (Li et al., 2014). transformed Riccati equation in Eq. (8). However, HAM also

Magn. Reson., 2, 175–186, 2021 https://doi.org/10.5194/mr-2-175-2021 T. Crawley and A. G. Palmer III: HAM for shaped pulses 181

◦ Figure 2. HAM approximations for 90 EBURP-2 pulse. Numerical calculation of Euler angles α(τp), β(τp), and γ (τp) using Eqs. (1)– (3) (black line). First-order (blue dotted line), second-order (reddish-purple dashed line), third-order (green dash-dotted line), and fifth-order (orange dash–dot–dotted line) HAM results, using method 1. Results are shown for (a, b, c) c0 = −1 and (d, e, f) c0 = −0.925. The numerical calculation and fifth-order HAM curves are nearly indistinguishable. could be applied directly to the original Riccati equation of The result obtained from the first-order deformation equation Eq. (5). For example, by analogy to method 2, choosing the is as follows: following: df (t) 1 − if (t) = −ic f (t) dt 1 0 0 t 0 dg(t) 1 2 1 Z δ(t ) N [g(t)] = − ω(t)g (t) − ig(t) − ω(t) (51) f (t) = −ic eit e−it tan dt0. (55) dt 2 2 1 0 2 dg(t) 0 L[g(t)] = − ig(t) (52) dt δ(t) f0(t) = tan , (53) However, additional terms in the series lack the simple iter- 2 ative structure shown in Eqs. (29) and (41) because of the increasing complexity of the higher derivatives of 82(t;q) that must be calculated for the nth order deformation equa- tion. For example, the differential equations for the next two in which f (t) is the exact solution for  = 0, yields the fol- 0 terms in the series for f (t) become the following: lowing series solution:

df (t) 2 − if (t) dt 2   N   δ(t) X df1(t) f (t) = tan + fn(t). (54) = − − 2 c0 if1(t) ω(t)f0(t)f1(t) . (56) n=1 dt https://doi.org/10.5194/mr-2-175-2021 Magn. Reson., 2, 175–186, 2021 182 T. Crawley and A. G. Palmer III: HAM for shaped pulses

◦ Figure 3. HAM approximations for 90 Q5 pulse. Numerical calculation of Euler angles α(τp), β(τp), and γ (τp) using Eqs. (1)–(3) (black line). Fifth-order (blue dotted line) and seventh-order (orange dash–dot–dotted line) HAM results, using method 1. Results are shown for (a, b, c) c0 = −1 and (d, e, f) c0 = −0.925. The numerical calculation and seventh-order HAM curves are nearly indistinguishable.

diofrequency pulses in which many iterations of a search or optimization routine are necessary (Gershenzon et al., 2008; df3(t) − if3(t) Li et al., 2011; Nimbalkar et al., 2013; Asami et al., 2018). dt The Euler angle representation is particularly convenient   df2(t) 2 = c0 − if2(t) − 2ω(t)f0(t)f2(t) − ω(t)f1 (t) . (57) because, once calculated, the Euler angles can be used to dt determine the outcome of a shaped pulse applied to arbi- In addition, results obtained using Eq. (30) to obtain f (t) trary initial magnetization. The Riccati equation can be ex- from y(t) generally are more accurate than results obtained tended to incorporate radiation damping, but not relaxation, by direct calculation of f (t) at the same order of approxima- as discussed by Rourke(2002). However, the Euler angles tion. Thus, in this particular application, use of HAM with can serve to generate the initial approximations for a second the transformed Riccati equation, Eq. (8), yields more con- application of HAM to obtain approximate solutions to the venient expressions. Nonetheless, this example demonstrates Bloch equations for particular initial conditions, including the particular power of HAM in directly converting the solu- relaxation. In the following, (t) =  is assumed to be fixed, tion of a nonlinear differential equation into a series of linear and only amplitude-modulated pulses ω(t) with x phase are first-order differential equations, which always can be solved considered (these assumptions can be relaxed as needed). by integration (Liao, 2012). The Bloch equations for a pulse applied with x phase can For many applications, the Euler angles for a shaped pulse be written in the following form: are easily obtained from Eqs. (1)–(3). However, calculations for method 1 using Eqs. (26), (29), and (30) are extremely ef- ficient. In Python 3.6, the seventh-order HAM approximation for the Q5 pulse is approximately 20 times faster than direct  0  d ˆ ˆ calculations using Eqs. (1)–(3). Thus, these approximations M(t) = −0(t)M(t) +  0 , (58) dt R t may be particularly useful for the computational design of ra- e 2 R1M0

Magn. Reson., 2, 175–186, 2021 https://doi.org/10.5194/mr-2-175-2021 T. Crawley and A. G. Palmer III: HAM for shaped pulses 183

Figure 4. HAM approximations for (a, b) REBURP and (c, d) WURST-20 inversion pulses. Numerical calculation of Euler angle β(τp) using Eqs. (1)–(3) (black line). (a, b) First-order (blue dotted line), second-order (reddish-purple dashed line), third-order (green dash-dotted line), and fifth-order (orange dash–dot–dotted line) HAM results, using method 1. (c, d) Fifth-order (blue dotted line), seventh-order (reddish- purple dashed line), ninth-order (green dash-dotted line), and 11th-order (orange dash–dot–dotted line) HAM results, using method 1. Results are shown for (a, c) c0 = −1 and (b, d) c0 = −0.925. The numerical calculation and (a, b) fifth-order and (c, d) 11th-order HAM curves are nearly indistinguishable.

T magnetization [0,0,M0] . The initial approximations are calculated by using the Euler angles determined from method  ˆ  Mx(t) 1 described above. Thus, in the following: ˆ ˆ M(t) = My(t), (59) ˆ Mz(t) d Mˆ (t) + 0(t)Mˆ = 0, (62) dt 0 0  0  0  and the system of first-order deformation equations yield the 0(t) = − 0 ω (t) , (60)  x  following: 0 −ωx(t) −(R2 − R1)   −R2t ˆ 0 in which Mk(t) = e Mk(t) are the Cartesian components d ˆ = − 0 of the magnetization, and M0 is the equilibrium magneti- M1(t) c0  . (63) dt ˆ R t zation. The use of transformed variables Mˆ (t) rather than (R2 − R1)Mz0(t) + e 2 R1M0 M(t) simplifies the following discussion. The linear op- erator is chosen as L[g(t)] = dg(t)/dt, in which g(t) = ˆ ˆ The solution to this equation yields Mx1(t) = My1(t) = 0, [g (t),g (t),g (t)]T is an arbitrary vector function. The non- x y z and Mˆ (t) is given by the following: linear operator is as follows: z1

 0  ˆ dg(t) Mz1(t) N [g(t)] = + 0(t)g(t) −  0 . (61)  t  dt R2t Z R e R1M0 ˆ 0 0 1 R2t = −c0 (R2 − R1) Mz0(t )dt + (e − 1)M0 R2 The initial zeroth-order approximations for HAM are 0 Mˆ (t) = M (t) and are given by the solutions to the Bloch  R  0 0 ˆ 1 R2t = −c0 (R2 − R1)t < Mz0(t) > + (e − 1)M0 . (64) equations in the absence of exchange for initial equilibrium R2 https://doi.org/10.5194/mr-2-175-2021 Magn. Reson., 2, 175–186, 2021 184 T. Crawley and A. G. Palmer III: HAM for shaped pulses

The first-order approximation of magnetization during the show the effect of relaxation as a perturbation of the evo- pulse is given by the following: lution of magnetization in the absence of relaxation. Figure5 shows the magnetization components for rectan-   Mx0(t) gular 90◦, 180◦, 270◦, and 360◦ nominal on-resonance pulses −R t M(t) = e 2  My0(t) . (65) in the absence and presence of relaxation. Calculations were ˆ Mz0(t) + Mz1(t) performed in the absence of relaxation using Eq. (68) and in the presence of relaxation using the HAM approxima- At this level of approximation, relaxation of transverse mag- tions, i.e., Eqs. (69) and (70). The first-order HAM approx- netization depends simply on R2, while relaxation of Mz(t) imation is surprisingly accurate for moderate values of R2, depends on the average z magnetization during the pulse (cal- ˆ except for cases in which < Mz0(t) >= 0, such as the on- culated in the absence of relaxation). For macromolecules, resonance 360◦ pulse. The above expressions display the fun-  R2 R1 typically, and the term proportional to R1/R2 is damental dependence of relaxation during a pulse applied to small. equilibrium magnetization on the time-average z magnetiza- The nth-order deformation equation leads to the following tion. expression for n > 1:

t Z 3 Conclusion ˆ ˆ 0 ˆ 0 0 Mn(t) = (1 + c0)M(n−1)(t) − c0 0(t )M(n−1)(t )dt . (66) Fast, accurate methods for solving differential equations have 0 widespread application in NMR spectroscopy. The present

If c0 = −1, the above recursive expressions can be written work has illustrated the homotopy analysis method (Liao, compactly as follows: 2012) for approximating solutions for differential equations by application to the Riccati differential equation for the Eu- t t − Z Zn 1 ler angle representation of radiofrequency pulse shapes and ˆ n−1 Mn(t) = (−1) 0(tn−1)dtn−1 0(tn−2)dtn−2... to solutions of the Bloch equations incorporating relaxation. The freedom to select the linear operator, lowest-order ap- 0 0 proximate solution, convergence control parameter, and aux- t2 Z iliary function is powerful in obtaining series solutions that × ˆ 0(t1)M1(t1)dt1. (67) are highly accurate for low orders of approximation and ef- 0 ficient to calculate or that provide qualitatively convenient series allowing physical insight. It can be expected that ho- For a rectangular pulse applied to equilibrium magnetiza- motopy analysis method will find other applications in NMR tion (with magnitude set to unity for convenience), the initial spectroscopy. approximations are as follows:   [1 − cos(ωet)]cosθ sinθ Code and data availability. RMarkdown and bibtex files are pro- M (t) = −sin(ω t)sinθ , (68) 0  e  vided in the Supplement. The RMarkdown file contains the Python 2 + 2 cos(ωet)sin θ cos θ code for all calculations described in the paper.

  ˆ 1 2 2 Mz1(t) = −c0(R2 − R1) sin(ωet)sin θ + tcos θ Supplement. The supplement related to this article is available ωe online at: https://doi.org/10.5194/mr-2-175-2021-supplement. R 1 R2t − c0 (e − 1). (69) R2 Author contributions. AGP conceived the project. The theoret- In this case, 0(t) = 0 and the series of approximations given ical derivations, numerical calculations, and writing of the paper in Eq. (67) can be summed to give the following: were performed by TC and AGP.

t  Z 0 −R2t 0(t−t ) M(t) = e M0(t) + e Competing interests. The authors declare that they have no con- 0 flict of interest. " 0 #  × 0 dt0 , (70) 0 R t0 (R2 − R1)Mz0(t ) + e 2 R1M0 and this yields identical results as a direct integration of the Bloch equations. Equations (65), (67), and (70) explicitly

Magn. Reson., 2, 175–186, 2021 https://doi.org/10.5194/mr-2-175-2021 T. Crawley and A. G. Palmer III: HAM for shaped pulses 185

Figure 5. HAM approximations for rectangular (a, b, c) 90◦, (d, e, f) 180◦, (g, h, i) 270◦, and (j, k, l) 360◦ pulses applied to initial z magnetization. Values of (a, d, g, j) Mx(), (b, e, h, k) My(), and (c, f, i, l) Mz() are shown as functions of resonance offset . Magnetization components in the absence of exchange, using Eq. (68) (black dotted line), first-order HAM approximation of the Bloch equations using Eq. (69) (reddish-purple dashed line), and exact HAM solution of the Bloch equations using Eq. (70) (blue solid line). −1 −1 Calculations used ω1/(2π) = 250 Hz, R1 = 2 s , R2 = 100 s , and c0 = −1.

Special issue statement. This article is part of the special issue Review statement. This paper was edited by Malcolm Levitt and “Robert Kaptein Festschrift”. It is not associated with a conference. reviewed by Fabien Ferrage and one anonymous referee.

Acknowledgements. Some of the work presented here was con- References ducted at the Center on Macromolecular Dynamics by NMR Spec- troscopy located at the New York Structural Biology Center. Arthur Arfken, G. B., Weber, H. J., and Harris, F. E.: Mathematical Meth- G. Palmer is a member of the New York Structural Biology Center. ods for Physicists, Academic Press, Boston, MA, 7th edn., 2013. This paper is dedicated to Robert Kaptein on the occasion of his Asami, S., Kallies, W., Günther, J. C., Stavropoulou, M., Glaser, 80th birthday. S. J., and Sattler, M.: Ultrashort broadband cooperative pulses for multidimensional biomolecular NMR experiments, Angew. Chem. Int. Ed., 57, 14498–14502, 2018. Financial support. This research has been supported by the Na- Cavanagh, J., Fairbrother, W. J., Palmer, A. G., Rance, M., and Skel- tional Institutes of Health (NIH; grant nos. R35GM130398 and ton, N. J.: Protein NMR Spectroscopy: Principles and Practice, P41GM118302). Academic Press, San Diego, CA, 2nd edn., 2007. Emsley, L. and Bodenhausen, G.: Optimization of shaped selective pulses for NMR using a quaternion description of their overall propagators, J. Magn. Reson., 97, 135–148, 1992. https://doi.org/10.5194/mr-2-175-2021 Magn. Reson., 2, 175–186, 2021 186 T. Crawley and A. G. Palmer III: HAM for shaped pulses

Geen, H. and Freeman, R.: Band-selective radiofrequency pulses, J. Nimbalkar, M., Luy, B., Skinner, T. E., Neves, J. L., Gershenzon, Magn. Reson., 93, 93–141, 1991. N. I., Kobzar, K., Bermel, W., and Glaser, S. J.: The Fantastic Gershenzon, N. I., Skinner, T. E., Brutscher, B., Khaneja, N., Nim- Four: A plug ’n’ play set of optimal control pulses for enhancing balkar, M., Luy, B., and Glaser, S. J.: Linear phase slope in pulse NMR spectroscopy, J. Magn. Reson., 228, 16–31, 2013. design: Application to coherence transfer, J. Magn. Reson., 192, Rourke, D. E.: Solutions and linearization of the nonlinear dynam- 235–243, 2008. ics of radiation damping, Concepts Magn. Reson., 14, 112–129, Kupce,˘ E. and Freeman, R.: Adiabatic pulses for wideband inver- 2002. sion and broadband decoupling, J. Magn. Reson., Ser. A, 115, Silver, M. S., Joseph, R. I., and Hoult, D. I.: Selective spin inversion 273–276, 1995. in nuclear magnetic resonance and coherent optics through an Kupce,˘ E., Boyd, J., and Campbell, I.: Short selective pulses for exact solution of the Bloch-Riccati equation, Phys. Rev. A, 31, biochemical applications, J. Magn. Reson., Ser. B, 106, 300–303, 2753–2755, 1985. 1995. Siminovitch, D. J.: Comment on “Rotation operator approach to Lescop, E., Kern, T., and Brutscher, B.: Guidelines for the use spin dynamics and the Euler geometric equations” [J. Chem. of band-selective radiofrequency pulses in hetero-nuclear NMR: Phys. 101, 6424 (1994)], J. Chem. Phys., 103, 2766–2768, 1995. Example of longitudinal-relaxation-enhanced BEST-type 1H- Siminovitch, D. J.: Rotations in NMR: Part I. Euler-Rodrigues pa- 15N correlation experiments, J. Magn. Reson., 203, 190–198, rameters and quaternions, Concepts Magn. Reson., 9, 149–171, 2010. 1997a. Li, J. S., Ruths, J., Yu, T.-Y., Arthanari, H., and Wagner, G.: Op- Siminovitch, D. J.: Rotations in NMR: Part II. Applications of the timal pulse design in quantum control: A unified computational Euler-Rodrigues parameters, Concepts Magn. Reson., 9, 211– method, P. Natl. Acad. Sci. USA, 108, 1879–1884, 2011. 225, 1997b. Li, Y., Rance, M., and Palmer, A. G.: Rotation operator propagators Warren, W. S.: Effects of arbitrary laser or NMR pulse shapes on for time-varying radiofrequency pulses in NMR spectroscopy: population-inversion and coherence, J. Chem. Phys., 81, 5437– applications to shaped pulses and pulse trains, J. Magn. Reson., 5448, 1984. 248, 105–114, 2014. Zhou, J., Ye, C., and Sanctuary, B. C.: Rotation operator approach Liao, S.: The proposed homotopy analysis technique for the solution to spin dynamics and the Euler geometric equations, J. Chem. of nonlinear problems, PhD thesis, Shanghai Jiao Tong Univer- Phys., 101, 6424–6429, 1994. sity, Shanghai, China, 1992. Liao, S.: Homotopy Analysis Method in Nonlinear Differential Equations, Springer, Berlin, Heidelberg, 2012.

Magn. Reson., 2, 175–186, 2021 https://doi.org/10.5194/mr-2-175-2021