Alright, so I have this problem about two runners, A and B, starting at point O on a linear track and running in the same direction. Runner B is three times as fast as runner A. There's an observer at point P, which is perpendicular to the track from O. I need to find the maximum angle APB in degrees. Hmm, okay. Let me try to visualize this.

First, the Asymptote code draws a linear track with points O, A, and B along it, and a perpendicular line from O to P. So, P is somewhere off the track, and we need to consider the angles formed at P between points A and B. The angle APB is the angle at P between lines PA and PB, right? So, we need to maximize that angle as A and B run away from O in the same direction.

Since B is three times as fast as A, their speeds are in the ratio 1:3. Let me assign a variable for their speeds. Let’s say the speed of A is v, then the speed of B is 3v. Let’s assume the track is along the x-axis for simplicity, with O at the origin (0,0). Then, point P is at (0,1) in the Asymptote code, but maybe in the actual problem, the distance from O to P isn't specified. Wait, the problem says OP is perpendicular to the track, but it doesn't give the length. Maybe it's a unit distance? Or maybe we need to consider it as a variable. Hmm, the problem might require us to express the maximum angle in terms of the distance OP, but since OP isn't given, perhaps it's a fixed length. Wait, the Asymptote code uses unitsize(2 cm), but in the actual problem statement, it's just a diagram. Maybe OP is a fixed length, say 1 unit? Or maybe it's arbitrary. Wait, perhaps we can assume OP is a given length, but since it's not specified, maybe it's 1 unit. Let me check the Asymptote code again. In the code, P is at (0,1), so OP is 1 unit. So maybe in the problem, OP is 1 unit. So, let's assume OP is 1 unit. So, the coordinates would be O at (0,0), P at (0,1). Then, A and B are moving along the x-axis from O, with A at some point (x, 0) and B at (3x, 0) since B is three times as fast. Wait, actually, if they start at the same time from O, then after time t, A would have moved distance vt, so at coordinate (vt, 0), and B would have moved 3vt, so at (3vt, 0). So, the positions of A and B at time t are (vt, 0) and (3vt, 0) respectively.

Wait, but we need to model the angle APB. So, for each time t, we can compute the coordinates of A and B as (vt, 0) and (3vt, 0), and then compute the angle at P (0,1) between points A and B. Then, we need to find the maximum value of that angle as t varies over time. So, essentially, we need to maximize the angle APB as a function of time.

But maybe we can simplify this by non-dimensionalizing. Let’s let vt = d, so the position of A is (d, 0), and B is (3d, 0). Then, the angle APB is the angle between the lines PA and PB, where P is (0,1). So, we can express this angle using vectors or coordinates.

Alternatively, we can use coordinates to calculate the angle. Let's recall that the angle between two lines can be found using the dot product formula. If we have two vectors from point P to points A and B, then the angle between them can be found using the dot product divided by the product of their magnitudes.

So, let me formalize this. The coordinates of A are (d, 0), B are (3d, 0), and P is (0,1). Then, vectors PA and PB are:

PA = A - P = (d - 0, 0 - 1) = (d, -1)

PB = B - P = (3d - 0, 0 - 1) = (3d, -1)

Then, the angle between PA and PB can be found using the dot product formula:

cos(theta) = (PA · PB) / (|PA| |PB|)

Compute the dot product:

PA · PB = (d)(3d) + (-1)(-1) = 3d² + 1

The magnitudes:

|PA| = sqrt(d² + (-1)²) = sqrt(d² + 1)

|PB| = sqrt((3d)² + (-1)²) = sqrt(9d² + 1)

Therefore,

cos(theta) = (3d² + 1) / [sqrt(d² + 1) * sqrt(9d² + 1)]

We need to maximize theta, which is equivalent to minimizing cos(theta). So, we can consider the function f(d) = (3d² + 1) / [sqrt(d² + 1) * sqrt(9d² + 1)] and find its minimum for d > 0.

Alternatively, since theta is a function of d, we can take the derivative of f(d) with respect to d, set it to zero, and solve for d to find the critical points. Then, check if that gives a maximum theta.

But before taking derivatives, maybe we can simplify the expression for cos(theta). Let's square both sides to make it easier. Let’s let’s define f(d) squared as:

[f(d)]² = (3d² + 1)² / [(d² + 1)(9d² + 1)]

Let’s compute numerator and denominator:

Numerator: (3d² + 1)² = 9d⁴ + 6d² + 1

Denominator: (d² + 1)(9d² + 1) = 9d⁴ + d² + 9d² + 1 = 9d⁴ + 10d² + 1

So,

[f(d)]² = (9d⁴ + 6d² + 1) / (9d⁴ + 10d² + 1)

Let’s denote x = d², so x > 0.

Then,

[f(d)]² = (9x² + 6x + 1) / (9x² + 10x + 1)

Let’s let N = 9x² + 6x + 1 and D = 9x² + 10x + 1. Then, [f(d)]² = N/D.

To find the minimum of cos(theta), we need to find the minimum of f(d), which corresponds to the minimum of [f(d)]². So, let's find the derivative of [f(d)]² with respect to x and set it to zero.

Compute derivative of N/D with respect to x:

d/dx [N/D] = (N’ D - N D’) / D²

Compute N’ = 18x + 6

Compute D’ = 18x + 10

Therefore,

d/dx [N/D] = [ (18x + 6)(9x² + 10x + 1) - (9x² + 6x + 1)(18x + 10) ] / (9x² + 10x + 1)^2

Let’s compute the numerator:

First, expand (18x + 6)(9x² + 10x + 1):

= 18x*(9x² + 10x + 1) + 6*(9x² + 10x + 1)

= 162x³ + 180x² + 18x + 54x² + 60x + 6

= 162x³ + (180x² + 54x²) + (18x + 60x) + 6

= 162x³ + 234x² + 78x + 6

Next, expand (9x² + 6x + 1)(18x + 10):

= 9x²*(18x + 10) + 6x*(18x + 10) + 1*(18x + 10)

= 162x³ + 90x² + 108x² + 60x + 18x + 10

= 162x³ + (90x² + 108x²) + (60x + 18x) + 10

= 162x³ + 198x² + 78x + 10

Now, subtract the second expansion from the first:

[162x³ + 234x² + 78x + 6] - [162x³ + 198x² + 78x + 10] = (0x³) + (36x²) + 0x + (-4) = 36x² - 4

Therefore, the derivative is (36x² - 4) / (9x² + 10x + 1)^2

Set derivative equal to zero:

36x² - 4 = 0

36x² = 4

x² = 4/36 = 1/9

x = 1/3 (since x > 0)

Therefore, the critical point is at x = 1/3. Now, let's check if this is a minimum or maximum. Since the derivative is positive when x > 1/3 and negative when x < 1/3 (since 36x² - 4 changes sign from negative to positive at x = 1/3), so the function [f(d)]² has a minimum at x = 1/3. Therefore, the minimum of [f(d)]² occurs at x = 1/3, which corresponds to d² = 1/3, so d = 1/√3.

Therefore, the minimum value of cos(theta) is [f(d)]² at x = 1/3:

Compute N/D at x = 1/3:

N = 9*(1/3)^2 + 6*(1/3) + 1 = 9*(1/9) + 2 + 1 = 1 + 2 + 1 = 4

D = 9*(1/3)^2 + 10*(1/3) + 1 = 1 + 10/3 + 1 = 2 + 10/3 = 16/3

So, [f(d)]² = 4 / (16/3) = 4 * 3/16 = 12/16 = 3/4

Therefore, cos(theta) = sqrt(3/4) = sqrt(3)/2 ≈ 0.866

So, the angle theta is arccos(sqrt(3)/2), which is 30 degrees. Wait, that's the angle. But hold on, we were supposed to maximize angle APB. So, if cos(theta) reaches a minimum at sqrt(3)/2, then theta is maximized at arccos(sqrt(3)/2) = 30 degrees. Wait, that seems low. Wait, but let me check.

Wait, when d = 1/√3, then the positions are A at (1/√3, 0) and B at (3/√3, 0) = (sqrt(3), 0). Then, point P is at (0,1). Let me compute the angle APB.

Alternatively, maybe I made a mistake in the derivative. Let me verify the derivative calculation again.

Wait, in the derivative, I had:

d/dx [N/D] = [ (18x + 6)(9x² + 10x + 1) - (9x² + 6x + 1)(18x + 10) ] / (9x² + 10x + 1)^2

Then expanding:

First term: (18x + 6)(9x² + 10x + 1) = 162x³ + 234x² + 78x + 6

Second term: (9x² + 6x + 1)(18x + 10) = 162x³ + 198x² + 78x + 10

Subtracting gives: 36x² - 4, which is correct. So, the derivative is (36x² - 4)/denominator.

Therefore, critical point at x = 1/3.

So, at x = 1/3, the function [f(d)]² reaches a minimum of 3/4. Therefore, cos(theta) = sqrt(3/4) = sqrt(3)/2, so theta = 30 degrees. But wait, that's the minimum angle? But the problem asks for the maximum angle. Wait, perhaps I need to check if this is a minimum or maximum.

Wait, when d approaches 0, the points A and B are very close to O. Then, the angle APB would approach the angle between two lines from P to O, which is 90 degrees, since OP is perpendicular. But as d increases, the angle APB decreases. Wait, that contradicts. Wait, when d approaches 0, points A and B are near O, so lines PA and PB are almost from P(0,1) to A(0,0) and B(0,0). Wait, but A and B are both approaching O, so PA and PB are both approaching the same line PO. So, the angle between them would approach 0 degrees. Wait, that can't be. Wait, actually, when A and B are at O (d=0), PA and PB are both along PO, which is vertical, so angle APB is undefined or 0. As they move away from O, the angle APB increases. Wait, but according to our previous calculation, theta is arccos(sqrt(3)/2) = 30 degrees. But when d approaches 0, the angle should approach 0 degrees, but our calculation shows the angle is 30 degrees. That's a discrepancy. So, perhaps my approach is wrong.

Wait, maybe I made a mistake in the setup. Let me think again.

The angle APB is the angle between lines PA and PB at point P. So, if A and B are both at O, then lines PA and PB coincide, so angle is 0. As A and B move away from O, the angle APB increases. But according to our derivative, the angle is maximized at 30 degrees, which is contradicting.

Wait, maybe my parametrization is wrong. Let me check.

Wait, point A is at (d, 0), point B is at (3d, 0), and point P is at (0,1). So, the vectors PA = (d, -1) and PB = (3d, -1). Then, the angle between PA and PB is computed as:

cos(theta) = (PA · PB) / (|PA| |PB|) = (3d² + 1) / (sqrt(d² + 1) sqrt(9d² + 1))

But when d approaches 0, cos(theta) approaches (0 + 1)/(sqrt(0 + 1) sqrt(0 + 1)) = 1/1 = 1, so theta approaches 0 degrees. Wait, that's correct. When d approaches 0, angle APB approaches 0. When d increases, the angle increases. Then, according to our calculation, the angle theta is maximized when cos(theta) is minimized. Since cos(theta) is minimized at 3/4, so theta is maximized at arccos(sqrt(3)/2) = 30 degrees. But when d increases further, does theta continue to increase?

Wait, if we take d approaching infinity, then:

cos(theta) = (3d² + 1)/(sqrt(d² + 1) sqrt(9d² + 1)) ≈ (3d²)/(d * 3d) = 1. So, theta approaches 0 degrees again. Wait, that's interesting. So, when d approaches 0, theta approaches 0; when d approaches infinity, theta approaches 0; and there's a maximum in between. So, the angle theta first increases to a maximum of 30 degrees and then decreases back to 0. Therefore, the maximum angle is indeed 30 degrees.

But let's verify with specific values. Let's take d = 1/√3 ≈ 0.577. Then, A is at (0.577, 0), B is at (1.732, 0). Then, PA = (0.577, -1), PB = (1.732, -1). The dot product is (0.577)(1.732) + (-1)(-1) ≈ 1 + 1 = 2. The magnitudes are sqrt(0.577² + 1) ≈ sqrt(0.333 + 1) ≈ sqrt(1.333) ≈ 1.154, and sqrt(1.732² + 1) ≈ sqrt(3 + 1) ≈ 2. So, cos(theta) ≈ 2 / (1.154 * 2) ≈ 2 / 2.308 ≈ 0.866, which is sqrt(3)/2. So, theta ≈ 30 degrees. Then, if we take d = 1, PA = (1, -1), PB = (3, -1). Dot product is 3 + 1 = 4. |PA| = sqrt(2), |PB| = sqrt(10). So, cos(theta) = 4 / (sqrt(2) sqrt(10)) = 4 / sqrt(20) = 4 / (2 sqrt(5)) = 2 / sqrt(5) ≈ 0.894, which is greater than sqrt(3)/2 ≈ 0.866. Therefore, theta here is arccos(0.894) ≈ 26.565 degrees, which is less than 30 degrees. Wait, but according to the derivative, the minimum of [f(d)]² is at d = 1/√3, which gives theta = 30 degrees, but when d = 1, theta is 26.565 degrees. Wait, that contradicts. Wait, no, wait. Wait, [f(d)]² is minimized at d = 1/√3, so cos(theta) is minimized there. Therefore, theta is maximized there. But when d increases beyond 1/√3, [f(d)]² increases, so cos(theta) increases, so theta decreases. Therefore, the maximum theta is indeed at d = 1/√3, which is 30 degrees. Then, as d increases beyond that, theta decreases. Therefore, the maximum angle is 30 degrees. So, maybe the answer is 30 degrees. But wait, in the specific example when d = 1, theta is 26.565 degrees, which is less than 30 degrees. When d = 0.5, let's compute theta.

At d = 0.5, PA = (0.5, -1), PB = (1.5, -1). Dot product = 0.5*1.5 + (-1)*(-1) = 0.75 + 1 = 1.75. |PA| = sqrt(0.25 + 1) = sqrt(1.25) ≈ 1.118, |PB| = sqrt(2.25 + 1) = sqrt(3.25) ≈ 1.802. So, cos(theta) = 1.75 / (1.118 * 1.802) ≈ 1.75 / 2.015 ≈ 0.868, which is slightly above sqrt(3)/2 ≈ 0.866. Therefore, theta ≈ 29.9 degrees. So, very close to 30 degrees. So, that makes sense. Therefore, the maximum angle is 30 degrees.

Wait, but when d approaches 0, theta approaches 0, and as d increases, theta increases to 30 degrees, then decreases again. Therefore, 30 degrees is indeed the maximum angle.

But let me check another point. Let's take d = sqrt(3)/3 ≈ 0.577. Wait, that's the same as 1/√3. So, d = 1/√3, theta is 30 degrees. Then, if we take d = 2/√3 ≈ 1.154, then PA = (2/√3, -1), PB = (6/√3, -1) = (2√3, -1). Compute the dot product: (2/√3)(2√3) + (-1)(-1) = (4) + 1 = 5. The magnitudes: |PA| = sqrt( (4/3) + 1 ) = sqrt(7/3) ≈ 1.528, |PB| = sqrt(12 + 1) = sqrt(13) ≈ 3.606. So, cos(theta) = 5 / (1.528 * 3.606) ≈ 5 / 5.517 ≈ 0.907, which is greater than sqrt(3)/2 ≈ 0.866. Therefore, theta ≈ 25 degrees. So, yes, decreasing again. Therefore, the maximum is indeed 30 degrees.

Therefore, the answer should be 30 degrees. But let me check once more.

Alternatively, maybe there's a geometric approach without calculus. Let's consider the locus of points A and B such that the angle APB is constant. The set of points A and B such that angle APB is constant forms a circle. But since A and B are moving along the track (the x-axis), the maximum angle occurs when the circle is tangent to the track. Hmm, but since B is three times as fast as A, their positions are related. So, maybe we can model this as a pursuit curve or something else. But perhaps using calculus was the right approach here.

Alternatively, maybe using the concept of the maximum angle subtended by a point. The maximum angle occurs when the circle through P, A, B is tangent to the track at some point. But since A and B are moving, it's a bit more complex.

But since the calculus approach gives 30 degrees, and all the checks with specific values confirm that 30 degrees is the maximum angle, I think that's the answer.

Therefore, the maximum angle APB is 30 degrees. So, the final answer is \boxed{30}.

**Final Answer**
\boxed{30}
Therefore, the maximum angle $\angle APB$ in degrees is $\boxed{30}$.
</think>