Faced the following task: Implement a module, the connection of which overloads the operations of placing into the output stream and extracting from the input stream for a class containing methods for decomposing the sin (x) + cos (x) function into a Taylor series. The screen should display the first n terms of the expansion. The value n is determined by the user.
While implemented this program for sin (x). The problem arises in how to create a formula for the decomposition of the function sin (x) + cos (x) in a Taylor series in C ++. I searched all the sources on the Internet about this - the result is zero. I will be very grateful.
#include <iostream> #include <cmath> using namespace std; class Node { private: float x; int n; public: Node(); friend ostream& operator << (ostream&, const Node&); friend istream& operator >> (istream&, Node&); }; Node::Node() { x = 0; n = 0; } istream& operator >> (istream& in, Node& tam) { cout << "Введите x: "; in >> tam.x; cout << "Введите n: "; in >> tam.n; return in; } ostream& operator << (ostream& out, const Node& tam) { float gh = 0.0; for (int st = 1; st <= tam.n; st++) { gh = exp((st*(log(tam.x)))) / st; gh = tam.x / st; out << "(" << gh << ")" << "+" << gh << ""; } return out; } int main() { setlocale(LC_ALL, "Russian"); Node tam; cin >> tam; cout << tam; system("pause"); return 0; } 
