You need std::setprecision
from the <iomanip>
header:
cout << setprecision( 8 ) << taylorSeriesToCalculateCosine(.3,3) << endl;
If you want the result to always have a certain width, use
cout << setfill('0') << left << setw(10) << setprecision(8)
<< taylorSeriesToCalculateCosine(.3,3) << endl;