A cubic spline method for solving the wave equation of nonlinear optics