Solve this inequality for B

60 Views Asked by At

I am working on a program that is supposed to qualify a value as "in range" and I have come up with the expression:

$$\lvert a-b\rvert \leq c$$

to determine the value. Plugging in test numbers shows that it should work.

First, I want to ask if someone can solve this expression for $b$, so I can check my formulas.

Second, if we assume I have all the values, where "$a$" is the user location, "$b$" is the event location and "$c$" is the user specified range (either $50$, $100$ or $200$ miles), would a value satisfy both expressions or just one?

I thought at first with some test data, both were coming up true, but logically I am starting to think that each evaluation would not be able to satisfy both. My brain is exhausted.

Let me provide some test data:

This will be latitude data.

User = A
Event = B
Range = C

This should be true because these locations are in fact in range.

User in Philadelphia PA Latitude = A = 39.952584
Event in King of Prussia, PA = B = 40.101286
Range = $50$ miles (I am dividing the miles by $69$, these ranges do not have to exact, I am just trying to get a ballpark range validation)

This should be false since these locations are NOT in range.

User in Sydney, AUS = A = -33.867487
Event in King of Prussia, PA = B = 40.101286
Range = $50$ miles (I am dividing the miles by $69$ to get degrees, these ranges do not have to exact, I am just trying to get a ballpark range validation)

If someone could at least verify my two inequalities solved for B, that would be a great start. I have used different approached based on my research on the web and it's uncanny, I am getting different results depending on the approach I use to remove the absolute values.

I have: $$-c \leq a-b \leq c$$ \begin{align*} -c & \leq a-b & a - b & \leq c\\ -c+b & \leq a & -b & \leq c - a\\ b & \leq a+c & b & \geq a -c \end{align*}

Do these look good?

So the second question would be, if I have all the values and can test $b$ to be either $\leq$ or $\geq$ the expressions above, would a number in range satisfy both expressions?

Thank you for your time on this...I have had some results come in good where bother are satisfied, but some items in range are not coming back true, making me think this may be a OR situation.

Sincerely,

Jamie