Operations with the $\mathcal O$ notation I'm quite new to the big $\mathcal O$ notation, so my question might sound ridiculous. I was told we wouldn't learn almost anything about $\mathcal  O$ and $\mathcal o$ notations during our bachelor studies, only very little in the structures of data and algorithms lessons, so any reference is welcome. These are the definitions in my notebook:


*

*We say a function $f(x)=\mathcal O(x^k),x\to 0,k\in\Bbb N$ if $\left|\frac{f(x)}{x^k}\right|\le C,$ for some $C>0$.

*We say a function $f(x)=\mathcal o(x^k),x\to 0,k\in\Bbb N$ if $\frac{f(x)}{x^k}\to 0.$

Before I ask my question, let me mention an example that motivated me: $$\lim_{(x,y)\to(0,0)}\frac{\cos(x+y)+\cos(x-y)-2}{x^2+y^2}.$$
Since $x^2+y^2=\frac{(x+y)^2+(x-y)^2}2,$ it is more elegant to work with $$\begin{aligned}\cos(x+y)&=1-\frac12(x+y)^2+\frac1{24}(x+y)^4 + \cdots=1-\frac12(x+y)+\mathcal O((x+y)^4))\\\cos(x-y)&=1-\frac12(x-y)^2+\frac1{24}(x-y)^4 + \cdots=1-\frac12(x+y)^2+\mathcal O((x-y)^4)\end{aligned}$$
In this case, we could, by the definition, conclude, $|\mathcal O((x+y)^4)|\le C_1(x-y)^4$ and $|\mathcal O((x-y)^4)|\le C_2(x-y)^4$ and then proceed with the triangle inequality  to bound $$|\mathcal O((x+y)^4+\mathcal O((x-y)^4)|\le \max\{C_1,C_2\}((x+y)^4+(x-y)^4))$$ and so on...
Now, to my question,what operations are meaningful with the $\mathcal O$ notation?
If I understood this answer by Stella Biderman correctly, $\mathcal O((x+y)^4)$ and $\mathcal O((x-y)^4)$ are sets of functions with the property $\left|\frac{f(x)}{(x\pm y)^4}\right|\le C,$ when $x-y\to 0,$ which is broader than $(x,y)\to(0,0).$
Do supstitutions $t_{1,2}=x\pm y$ make any sense and is there any way to handle expressions such as $\mathcal O(x^k)+\mathcal O(x^k+y^m)$? I know it is legitimate to write $\mathcal O(x^2)+\mathcal O(x^3)+\ldots +\mathcal O(x^k)=\mathcal O(x^2),$ but, aside from that, I don't have any further insight.
 A: With the definitions of $O$ notation from your notebook, writing $O(x + y)$ (etc.) is anomalous, because applying the definition literally entails division by zero in a way the definition for one variable doesn't. The first issue is therefore to give a definition of $O$ notation that applies in your situation.
Let $U$ be a non-empty open set in some Cartesian space, and let $f$ and $g$ be real-valued functions on $U$. We might say $f = O(g)$ in $U$ if there exists a real number $C$ such that $|f(x)| \leq C |g(x)|$ for all $x$ in $U$. (Naively applying your notebook definition would have us say $|f/g| \leq C$; this is equivalent to $|f| \leq C|g|$ if $g$ is non-vanishing in $U$, but otherwise is not.)
We could then declare that $f = O((x + y)^{k})$ as $x + y \to 0$ if there exists a $\delta > 0$ such that $f = O((x + y)^{k})$ on the non-empty open set $|x + y|^{k} < \delta$. (Particularly, this would impose that $f$ is defined in such an open set.)
With this understanding, your inequality demonstrates that
$$
O((x + y)^{4}) + O((x - y)^{4}) = O((x + y)^{4} + (x - y)^{4})\quad
\text{as $(x, y) \to (0, 0)$,}
$$
in the sense that "If $f = O((x + y)^{4})$ as $(x, y) \to (0, 0)$ and $g = O((x - y)^{4})$ as $(x, y) \to (0, 0)$, then $f + g = O((x + y)^{4} + (x - y)^{4})$ as $(x, y) \to (0, 0)$."
