Error propagation when using modulus operator

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 2K views
TheCanadian
Messages
361
Reaction score
13
Sorry if the answer is very simple, but I just had a question regarding error propagation when using a modulo operator in intermediate steps. For example, I have ## \theta = arctan(\frac {A}{B}) ## and then I do ## \theta ## % ##2\pi## (modulo ##2\pi##). This gives me an answer between ## [0,2\pi] ## instead of ##[-\pi,\pi]##. This new answer in this new range is the answer I want. Now, when I calculate ## \sigma_{\theta} ##, I get:

## \sigma_{\theta} = \frac{A/B * \sqrt{ (\sigma_{A}/A)^2 + (\sigma_{B}/B)^2}}{1 + (A/B)^2} ##

Firstly, I just want to confirm: is there anything wrong with my equation for ## \sigma_{\theta} ##?

Secondly, since I change theta itself from ##[-\pi,\pi]## to ## [0,2\pi] ##by arithmetic operations, is there any modifications to ## \sigma_{\theta} ## in this case?

Thirdly, this is just a general error propagation question (sorry, I'm a novice), but if you have constant noise (i.e. a constant error), in the computation of A/B such that ## \sigma_A = \sigma_B = 2 ##, then you have ## \sigma_{A/B} = \frac{A}{B}\sqrt{ (2/A)^2 + (2/B)^2}##, but if A = 0, then A/B = 0, but in that case, the denominator in the square root for error goes to infinity but the numerator still has 0...so how does one approach computing the error in such as case? Is ## \sigma_{A/B} = \frac{1}{B}\sqrt{ (2)^2}## valid in such a case (I just multiplied by A/A)?

Please let me know if I have any mistakes. Any advice is appreciated!
 
Last edited:
Physics news on Phys.org
TheCanadian said:
Sorry if the answer is very simple, but I just had a question regarding error propagation when using a modulo operator in intermediate steps. For example, I have ## \theta = arctan(\frac {A}{B}) ## and then I do ## \theta % 2\pi ##. This gives me an answer between ## [0,2\pi] ## instead of ##[-\pi,\pi]##. This new answer in this new range is the answer I want. Now, when I calculate ## \sigma_{\theta} ##, I get:

## \sigma_{\theta} = \frac{A/B * \sqrt{ (\sigma_{A}/A)^2 + (\sigma_{B}/B)^2}}{1 + (A/B)^2} ##

Firstly, I just want to confirm: is there anything wrong with my equation for ## \sigma_{\theta} ##?

Secondly, since I change theta itself from ##[-\pi,\pi]## to ## [0,2\pi] ##by arithmetic operations, is there any modifications to ## \sigma_{\theta} ## in this case?

Thirdly, this is just a general error propagation question (sorry, I'm a novice), but if you have constant noise (i.e. a constant error), in the computation of A/B such that ## \sigma_A = \sigma_B = 2 ##, then you have ## \sigma_{A/B} = \frac{A}{B}\sqrt{ (2/A)^2 + (2/B)^2}##, but if A = 0, then A/B = 0, but in that case, the denominator goes to infinity but the numerator still has 0...so how does one approach computing the error in such as case?

Please let me know if I have any mistaken. Any advice is appreciated!
Part of your LaTeX is broken, and I can't figure out how to correct it. In the next-to-last paragraph you have this: \frac{A/B * \sqrt{ (2/A)^2 + (2/B)^2}, which is malformed, due to missing several braces. What is it supposed to be? Should it agree with what you have in the 2nd paragraph?
 
Mark44 said:
Part of your LaTeX is broken, and I can't figure out how to correct it. In the next-to-last paragraph you have this: \frac{A/B * \sqrt{ (2/A)^2 + (2/B)^2}, which is malformed, due to missing several braces. What is it supposed to be? Should it agree with what you have in the 2nd paragraph?
I believe I fixed it. Is the error still appearing?
 
Mark44 said:
Part of your LaTeX is broken, and I can't figure out how to correct it. In the next-to-last paragraph you have this: \frac{A/B * \sqrt{ (2/A)^2 + (2/B)^2}, which is malformed, due to missing several braces. What is it supposed to be? Should it agree with what you have in the 2nd paragraph?

Also, if A < 0, then wouldn't ##σ_{A/B}## be negative, too? How exactly does that make sense (if I didn't mess up the formula).
 
TheCanadian said:
I believe I fixed it. Is the error still appearing?
It looks OK now.

TheCanadian said:
Sorry if the answer is very simple, but I just had a question regarding error propagation when using a modulo operator in intermediate steps. For example, I have ## \theta = arctan(\frac {A}{B})## and then I do ##\theta % 2\pi## (modulo 2πi). This gives me an answer between [0,2π] instead of [−π,π] . This new answer in this new range is the answer I want.
I'm not sure if this is valid. Since ##\theta = arctan(A/B)##, ##\theta## will naturally be an angle in the interval (−π/2, π/2), as that is the principal domain for the tangent function, to make it one-to-one, and thus invertible. Also, because you're taking the arctan of A/B, B can't be zero (implying that ##\theta## is −π/2 or π/2.
TheCanadian said:
Now, when I calculate ## \sigma_{\theta} ##, I get:

## \sigma_{\theta} = \frac{A/B * \sqrt{ (\sigma_{A}/A)^2 + (\sigma_{B}/B)^2}}{1 + (A/B)^2} ##

Firstly, I just want to confirm: is there anything wrong with my equation for ##\sigma_{\theta}## ?
 
Mark44 said:
It looks OK now.

I'm not sure if this is valid. Since ##\theta = arctan(A/B)##, ##\theta## will naturally be an angle in the interval (−π/2, π/2), as that is the principal domain for the tangent function, to make it one-to-one, and thus invertible. Also, because you're taking the arctan of A/B, B can't be zero (implying that ##\theta## is −π/2 or π/2.

Ahh yes. Sorry, this was done using a software package. Essentially, based on the sign of A and B, it will compute the angle for the proper quadrant in the interval [-##\pi##,##\pi##] and if B == 0, then there is an extra statement saying it is simply equal to −π/2 (or π/2). It is a simple arithmetic operation (e.g. +- 2##\pi##) depending on the sign of A and B. Based on this additional information, is there anything I should be looking into in my procedure? Errors in the functions themselves should be considered since they're based on series expansions, but is it wrong to assume these errors are also negligible for errors on A or B being approximately 2 (i.e. ##\sigma_{A (or B)} ≈ 2##, so much higher than the errors on the series expansions)?
 
Last edited: