dz =(−sinx + 2xy^2)dx +(2x^2 y)dy

Integrate the differential to find the function z.

Would I say that z was equal to two separate differentials and integrate the first part of the function with respect to x and the second part with respect to y?
z = cosx + x^2 y^2 + x^2 y^2 + C
z = cosx + 2(x^2 y^2) + C

Is this right or have I gone wrong?

you can check..

If z=cosx + 2x^2y^2 + C
then dz/dx= -sinx + 4xy^2 + 4x^2y dy/dx
which is not exactly what you started with.
check my thinking.

To integrate the given differential dz, you should integrate each term separately according to the variables associated with them. In this case, you need to integrate the first part with respect to x and the second part with respect to y.

Integrating the first term (-sinx + 2xy^2)dx with respect to x gives:
∫(-sinx + 2xy^2)dx = -cosx + x^2y^2 + g(y), where g(y) is a function of y that represents the constant of integration.

Integrating the second term (2x^2y)dy with respect to y gives:
∫(2x^2y)dy = x^2y^2 + h(x), where h(x) is a function of x that represents the constant of integration.

So, the function z can be written as:
z = -cosx + x^2y^2 + g(y) + h(x).

Note that in your explanation, you incorrectly duplicated the term x^2y^2. The correct form is:
z = -cosx + x^2y^2 + g(y) + h(x) + C, where C represents the constant of integration.

Overall, you have the right idea, but you missed including the separate functions g(y) and h(x), as well as the constant of integration, in your final expression for z.