I'm trying to solve exercises about primary decomposition of ideals. I'm always working with the polynomial rings $K[x,y]$ and $K[x,y,z]$ and everything is ok except everytime I split the ideal into an intersection of two ideals I have to verify equalities of ideals, for instance $$ (x(x-1),y)=(x,y)\cap(x-1,y)\\ (xy^2,z-xy)=(x,z-xy)\cap(y^2,z-xy)\\ (x(x-1),(x-1)y)=(x,(x-1)y)\cap(x-1). $$ It's annoying to check the double inclusion everytime, so I try to figure it out with some simple rules. For example, I know that in UFDs, if $f,g$ are coprime, then $(fg)=(f)\cap(g)$. I know also that for monomial ideals it holds $$(fg,m_1,\dots,m_k)=(f,m_1,\dots,m_k)\cap(g,m_1,\dots,m_k)$$ But like in the cases I wrote above, it seems to me we can apply this rule despite the ideals aren't generated by monomials.
I'd like to extend those rules to something like $$ "\text{let } f,g,h_1,\dots,h_k\in K[x_1,\dots,x_n] \text{ with } \gcd(f,g)=1,\text{ then}\\ (fg,h_1\dots,h_k)=(f,h_1\dots,h_k)\cap(g,h_1\dots,h_k)" $$
Is this possible? Or, is it possible if both $f$ and $g$ are coprime to each $h_i$? The third example I wrote holds even if this stronger hypothesis isn't true. I tried to prove something like that but without success.
Thank you in advance to those who can answer me.
Let $R$ be a commutative ring, and let $f,g\in R$ be coprime. Then given $h_1,\cdots,h_k\in R$ we have:$$(fg,h_1,\cdots,h_k)=(f,h_1,\cdots,h_k)\cap(g,h_1,\cdots,h_k)$$
Proof: The inclusion of the left hand ideal in the right is clear. Conversely given $\alpha\in (f,h_1,\cdots,h_k)\cap(g,h_1,\cdots,h_k)$ we have $$\alpha=\alpha1=\alpha(\lambda f+\mu g)=\alpha f \lambda+\alpha g\mu,$$ where $\mu,\lambda\in R$ are chosen to satisfy $\lambda f+\mu g=1$.
As $\alpha\in (g,h_1,\cdots,h_k)$ we know $\alpha f\lambda\in (fg,h_1,\cdots,h_k)$.
Similarly as $\alpha\in (f,h_1,\cdots,h_k)$ we know $\alpha g\mu\in (fg,h_1,\cdots,h_k)$.
Thus $\alpha=\alpha f \lambda+\alpha g\mu \in (fg,h_1,\cdots,h_k)$. $\qquad \Box$
You asked for the result under the weaker assumption that gcd$(f,g)=1$, but I replaced this hypothesis with the assumption that $f,g$ are coprime, as you mentioned this condition earlier.
Note of your three examples, the above result resolves the first and third, but not the second as $x,y^2$ are not coprime.
An easy way to resolve the second case is to consider the quotient map $$K[x,y,z]\to K[x,y],$$ which maps $x\mapsto x$, $y\mapsto y$, $z\mapsto xy$. Using the result you mention for monomial ideals, we then have $$(xy^2)=(x)\cap(y^2),$$ so your two original ideals both map to the same ideal $I=(xy^2)$ in $K[x,y]$. As they both contain $z-xy$, they are both the preimage of $I$, hence they are equal.
Here is a counterexample to your conjecture:
Let $K$ be a field. In the ring $K[x,y]$ we have $$y^2\in (x-1,x^2+y^2-1)\cap (y, x^2+y^2-1)$$ as $$y\cdot y=y^2\qquad\qquad {\rm and}\qquad\qquad x^2+y^2-1-(x-1)(x+1)=y^2.$$
However $$y^2 \notin (y(x-1), x^2+y^2-1),$$ even though gcd$(x-1,y)=1$.
To see this, consider the ring homomorphism $K[x,y]\to M_4(K)$ sending:$$x\mapsto \left(\begin{array}{cccc} 0&0&-1&0\\ 1&0&1&0\\ 0&1&1&0\\ 0&0&0&1 \end{array}\right)\qquad\qquad y\mapsto \left(\begin{array}{cccc} 0&0&0&1\\ 0&0&0&0\\ 0&0&0&-1\\ 1&1&1&0 \end{array}\right) $$
(Note these matrices commute, so the above is a well defined ring homomorphism).
Both $y(x-1)$ and $x^2+y^2-1$ get mapped to $0$, but $$y^2\mapsto \left(\begin{array}{cccc} 1&1&1&0\\ 0&0&0&0\\ -1&-1&-1&0\\ 0&0&0&0 \end{array}\right) $$
Thus $$y^2 \notin (y(x-1), x^2+y^2-1).$$
So your statement is not true in general. However my weaker statement is true for any ring and solves two of your three examples, whilst the other example is resolved by the method above, so in all three cases you do not have to do any elaborate calculations.
It is interesting to note that in the counterexample above, $$y^3\in (y(x-1), x^2+y^2-1).$$ This is an example of the following: If $f,g$ are any polynomials over a field, then $$\alpha\in (f,h_1,\cdots,h_k)\cap(g,h_1,\cdots,h_k)\implies \exists n\in \mathbb{N}| \alpha^n\in (fg,h_1,\cdots,h_k).$$ This is a consequence of Hilbert's Nullstellensatz.