Show that \(( \sec x + \cos x ) ^ { 2 }\) can be expressed as \(\sec ^ { 2 } x + a + b \cos 2 x\), where \(a\) and \(b\) are constants to be determined.
Hence find the exact value of \(\int _ { 0 } ^ { \frac { 1 } { 4 } \pi } ( \sec x + \cos x ) ^ { 2 } \mathrm {~d} x\).