Error propagation when using modulus operator

In summary, using a modulo operator in intermediate steps can result in an answer in a different range than expected, but this can be corrected by simple arithmetic operations. When calculating the error propagation for this process, the equation for ##\sigma_{\theta}## is correct as long as B is not equal to 0. However, if B is equal to 0, additional considerations must be made.
  • #1
TheCanadian
367
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:
Mathematics news on Phys.org
  • #2
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?
 
  • #3
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?
 
  • #4
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).
 
  • #5
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}## ?
 
  • #6
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:

1. What is the modulus operator and how does it work?

The modulus operator, denoted by %, is a mathematical operator used to find the remainder after dividing two numbers. For example, 10 % 3 would result in a remainder of 1. This operator works by dividing the first number by the second and returning the remainder.

2. How does error propagation occur when using the modulus operator?

Error propagation occurs when the modulus operator is used in a series of calculations. This is because the modulus operator can introduce additional errors into the final result due to its non-linear behavior.

3. How can error propagation be minimized when using the modulus operator?

The best way to minimize error propagation when using the modulus operator is to use smaller values for the second number in the operation. This will result in a smaller potential error in the final result.

4. Can error propagation be completely avoided when using the modulus operator?

No, error propagation cannot be completely avoided when using the modulus operator. However, it can be reduced by carefully choosing the values used in the operation and understanding the limitations of the modulus operator.

5. Are there any other factors that can affect error propagation when using the modulus operator?

Yes, other factors such as the precision of the numbers being used and the order of operations can also affect error propagation when using the modulus operator. It is important to consider all of these factors when using the modulus operator in scientific calculations.

Similar threads

  • General Math
Replies
5
Views
1K
Replies
3
Views
217
  • Other Physics Topics
Replies
1
Views
2K
  • General Math
Replies
1
Views
261
Replies
5
Views
2K
  • Precalculus Mathematics Homework Help
Replies
14
Views
267
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
Replies
8
Views
2K
Replies
11
Views
487
Replies
2
Views
1K
Back
Top