## Having trouble with error propagation

I'm measuring the error of a measurement of the magnetic field in r and theta. I'd like to find the error in the x and y directions.
Let the value of the magnetic field in x be X
Let the value of the magnetic field in y be Y
Let the value of the magnetic field in theta be D
Let the value of the magnetic field in r be R

cos(D) = X / R
sin(D) = Y / R

R ^ 2 = X ^ 2 + Y ^ 2

Thus,

X2 = R2 * cos2(D)
Y2 = R2 * sin2(D)

X = R * cos(D)
Y = R * sin(D)

I use the following equations for error propagation:

Ex2 = $\frac{dX}{dr}$2Er2 + $\frac{dX}{dtheta}$2ED2

Ey2 = $\frac{dY}{dr}$2Er2 + $\frac{dY}{dtheta}$2ED2

$\frac{dX}{dr}$ = cos(D)
$\frac{dX}{dtheta}$ = - R sin (D)
$\frac{dY}{dr}$ = sin(D)
$\frac{dY}{dtheta}$ = R cos (D)
thus,
Ex2 = cos2(D)*Er2 + R2sin2*ED2 (1)

Ey2 = sin2(D)*Er2 + R2cos2*ED2 (2)

Which is fine and dandy and matches my physical expectation.

The problem I'm having is if I do this in reverse I get a contradictory result.

Suppose I know Ex and Ey and need Er and ED.

Er2 = $\frac{dR}{dx}$2Ex2 + $\frac{dR}{dy}$2Ey2

and

ED2 = $\frac{dD}{dx}$2Ex2 + $\frac{dD}{dy}$2ED2

$\frac{dR}{dx}$ = X / R
$\frac{dR}{dy}$ = Y / R

$\frac{dD}{dx}$ = $\frac{-y}{R2}$
$\frac{dD}{dy}$ = $\frac{x}{R2}$

giving:

ER2 = (X/R)2 * Ex2 + (Y/R)2* Ey2 (3)

E[SUB]D[/SUB2 = (Y/R2)2 Ex2 + (X/R2) * Ey2 (4)

Then solve these equations for Ey and Ex I find that the Ex and Ey in these equations end up disagreeing with the ones in the previous set.

For EX
Multiply equation (3) through by R2
In equation (3) subtract the Ex term from both sides.
Multiply equation (3) by (R/Y)2
Substitute the resulting expression of Ey into equation (4)

Then solving for Ex2 yielding:

Ex2 = $\frac{R2sin2(D)*ED2 - cos2(D) * Er2}{sin2(D) - cos2(D)}$

Which is off from equation (1) for the addition of two negative signs. (one in the numerator and one in the denominator, I don't believe it to be equal to equation 1 but perhaps I am wrong somehow. Additionally this equation allows for negative values of Ex2! I'm not sure where I went wrong. Is there some reason I can't do what I've done?