A contains some red and blue balls. There are four more red than blue balls. A ball is removed at random and replaced. A second ball is removed. The probability that the two balls are different colours is 21/50. How many balls are in the box.

Ans
Drawing a tree diag gives you that
2p(r)xp(b) = 21/50
p(r)^2 + p(b)^2 = 29/50

The ans is that there are 7 red and 3 blue but how do you get there?

To solve this problem, we'll use the given information to set up a system of equations and solve for the number of red and blue balls.

Let's assume there are r red balls and b blue balls in the box.

From the given information, we know that there are four more red balls than blue balls, so we can write one equation:

r = b + 4 (Equation 1)

Next, we need to use the probability information to set up the second equation:

The probability of selecting a different colored ball on the first draw is given as 21/50. The probability of selecting a red ball followed by a blue ball is:

(r/b + r) * (b/r + b) = (r(b + 4))/(b(r + 4)) = (r(r + 4))/(b(b + 4)) = 21/50

Simplifying this equation, we get:

(r^2 + 4r)/(b^2 + 4b) = 21/50 (Equation 2)

Now, substitute the value of r from Equation 1 into Equation 2:

((b + 4)^2 + 4(b + 4))/(b^2 + 4b) = 21/50

Simplify this equation further:

(b^2 + 8b + 16 + 4b + 16)/(b^2 + 4b) = 21/50

Combining like terms:

(b^2 + 12b + 32)/(b^2 + 4b) = 21/50

Cross-multiply and simplify:

50(b^2 + 12b + 32) = 21(b^2 + 4b)

50b^2 + 600b + 1600 = 21b^2 + 84b

Rearrange the equation to form a quadratic equation:

29b^2 - 516b + 1600 = 0

Now we can solve this quadratic equation for the value of b.

Using the quadratic formula (b = (-b ± √(b^2 - 4ac)) / 2a), we get:

b = (-(-516) ± √((-516)^2 - 4*29*1600)) / 2*29

Simplifying this equation, we get:

b ≈ (516 ± √(266256 - 185600)) / 58

b ≈ (516 ± √80656) / 58

Since the number of balls cannot be negative, we take the positive value:

b ≈ (516 + √80656) / 58

b ≈ 11

Now substitute the value of b back into Equation 1 to find r:

r = b + 4

r = 11 + 4

r ≈ 15

Therefore, there are approximately 15 red balls and 11 blue balls in the box.

To get to the answer, we need to solve the system of equations that represents the given information. Let's define the number of red balls as R and the number of blue balls as B.

1. From the given information, we know that there are four more red balls than blue balls: R = B + 4.

2. To calculate the probability of getting two different colored balls, we need to consider two scenarios: one with a red ball followed by a blue ball, and one with a blue ball followed by a red ball.

The probability of drawing a red ball followed by a blue ball can be calculated as follows:
- The probability of drawing a red ball in the first draw is (R / (R + B)).
- The probability of drawing a blue ball in the second draw (assuming the first ball was red and replaced) is (B / (R + B)).
- So the combined probability is (R / (R + B)) * (B / (R + B)) = RB / (R + B)^2.

Similarly, the probability of drawing a blue ball followed by a red ball is: BR / (R + B)^2.

According to the problem, these two probabilities combine to form a total probability of 21/50:
RB / (R + B)^2 + BR / (R + B)^2 = 21/50.

3. We also know that the total probability of getting two balls of different colors is:
P(two balls different colors) = P(red, blue) + P(blue, red) = 21/50.

Now, let's solve the system of equations:
RB / (R + B)^2 + BR / (R + B)^2 = 21/50.
R = B + 4.

Substituting R = B + 4 into the first equation, we get:
(B + 4)B / (B + B + 4)^2 + B(B + 4) / (B + B + 4)^2 = 21/50.

Simplifying the equation, we have:
(2B^2 + 8B) / (2B + 4)^2 = 21/50.
(2B^2 + 8B) / 4B^2 + 16B + 16 = 21/50.
Cross-multiplying, we get:
(2B^2 + 8B) * 50 = (4B^2 + 16B + 16) * 21.

Expanding and rearranging terms, we have:
100B^2 + 400B = 84B^2 + 336B + 336.

Combining like terms, we get:
16B^2 + 64B - 336 = 0.

Now, we can solve this quadratic equation. Factoring out 16, we have:
16(B^2 + 4B - 21) = 0.

Simplifying further, we get:
B^2 + 4B - 21 = 0.

Factoring this quadratic equation, we have:
(B - 3)(B + 7) = 0.

Setting each factor equal to zero, we have two possible values for B:
B - 3 = 0 -> B = 3.
B + 7 = 0 -> B = -7.

Since we are dealing with a number of balls, the number cannot be negative. Therefore, B = 3.

Substituting the value of B back into the equation R = B + 4, we get:
R = 3 + 4 = 7.

So, the number of red balls is 7 and the number of blue balls is 3. Thus, the box contains a total of 7 + 3 = 10 balls.

r = red , b = blue , t = total = r + b

r = b + 4 ... b = r - 4
... t = 2b + 4 = 2r - 4

4 possible outcomes
... r+r , b+b , r+b , b+r

p(r+b) = p(b+r) = (r*b) / t^2

2 [r(r-4)] / (2r - 4)^2 = 21/50

100 r^2 - 400r = 84 r^2 - 336r + 336

16 r^2 - 64r - 336 = 0 = r^2 - 4r - 21
... 0 = (r - 7)(r + 3) ... r = 7

t = 2r - 4 = 10

Ok the way you do that is to multiply the red times the blue balls. There are 4 red balls. 3 X 4 = 12.