Sunday, March 13, 2011

yaw angle: probability for fixed wind speed

Last time I began the problem of predicting the probability distribution of yaw angle if wind speed (|v|) is fixed but if the rider's heading relative to the wind (Φ) is unnbiasedly random. I calculated the derivative of yaw with respect to heading. Rider speed is s.

The probability distribution of yaw is inversely proportional to the magnitude of the derivative at the given value of yaw.

P(yaw) ∝ | ( (|v|² + s²) + 2 s |v| cos Φ ) / [ |v| ( |v| + s cos Φ ) ] |

Special case: cos Φ = ‒1
P(yaw) ∝ | ( (|v|² + s²) ‒ 2 s |v|) / [ |v| ( |v| ‒ s ) ] |
= | (|v| ‒ s)² / [ |v| ( |v| ‒ s ) ] |
= | (|v| ‒ s) / |v| |
= | 1 ‒ s/|v| |
which goes to zero for s = |v|. But I'll look more at that case later.

But in general, for this to be useful, cos Φ needs to be eliminated from the equation:

tan yaw = |v| sin Φ / ( |v| cos Φ + s )

( |v| cos Φ + s ) tan yaw = |v| sin Φ

( |v| cos Φ + s )² tan² yaw = |v|² ( 1 ‒ cos² Φ )

( |v|² cos² Φ + 2 s |v| cos Φ + s² ) tan² yaw = |v|² ‒ |v|² cos² Φ

|v|² cos² Φ (1 + tan² yaw ) + 2 s |v| cos Φ tan² yaw + s² tan² yaw ‒ |v|² = 0

|v|² cos² Φ / cos² yaw + 2 s |v| cos Φ tan² yaw + s² tan² yaw ‒ |v|² = 0

This is a quadratic equation in cos Φ :

a = |v|² / cos² yaw
b = 2 s |v| tan² yaw
c = s² tan² yaw ‒ |v|²

cos Φ = (‒b / 2a ) ( 1 ± sqrt[ 1 ‒ 4 a c / b² ] )

‒b / 2a = ‒(s / |v|) sin² yaw
‒4 a c / b^2 = (|v|² cos² yaw ‒ s² sin² yaw)) / ( s² sin⁴ yaw )

So:

cos Φ = ± sqrt[ ( (s / |v|) sin² yaw)² + ( cos² yaw ‒ (s / |v|)² sin² yaw) ] ‒ (s / |v|) sin² yaw

Note there are two solutions (one for the +, one for the ‒ of the ±). This is because if the bike is faster than the wind, riding straight into the wind and the yaw angle is zero. As the rider turns 90 degrees, the wind moves to the side, never reaching 90 degrees. The yaw eventually hits a maximum, then decreases again, until when the rider is moving in the direction of the wind, the relative wind is once again head‒one (the rider is overtaking the wind). So for any given value of yaw for which a heading exists (with the exception of the maximum yaw) there are two headings which will give that yaw. Were the rider moving slower than the wind, there would only be one heading for each yaw value, and we'd need to replace the ± with a +.

I checked this result numerically and it works. Note if the value in the square root is negative then there's no solution for that value of yaw. For example, if the bike is moving faster than the wind, there is no way the wind can be overtaking the bike, so the yaw angles larger than a peak value fail to yield a real solution. (Aside: negative square roots yield imaginary numbers, and it is interesting to try and interpret what that means in this context.)

So assuming there are two solutions, a given value of yaw could come from two headings, so I need to sum the probability of both:

P(yaw) ∝
| ( (|v|² + s²) + 2 s |v| cos Φ₁ ) / [ |v| ( |v| + s cos Φ₁ ) ] | +
| ( (|v|² + s²) + 2 s |v| cos Φ₂ ) / [ |v| ( |v| + s cos Φ₂ ) ] |

However, I can simplify this if I recognize these cosines can be written:
cos Φ₁ = c0 ‒ Δc/2
cos Φ₂ = c0 + Δc/2

where

c0 = ‒(s / |v|) sin² yaw
Δc/2 = sqrt[ ( (s / |v|) sin² yaw)² + ( cos² yaw ‒ (s / |v|)² sin² yaw) ]
(I'll clean this up further a bit later)
then

P(yaw) ∝
| ( (|v|² + s²) + 2 s |v| [c0 + Δc/2] ) / [ |v| ( |v| + s [c0 + Δc/2] ) ] | +
| ( (|v|² + s²) + 2 s |v| [c0 ‒ Δc/2] ) / [ |v| ( |v| + s [c0 ‒ Δc/2] ) ] |

First, there's the ugly business of those absolute value signs. Since yaw first increases with Φ, then it decreases, I'm going to assume the two terms (which have the same sign as the derivatives) are of opposite sign. I can then subtract them then take the absolute value, as opposed to summing the absolute values:

P(yaw) ∝
| ( (|v|² + s²) + 2 s |v| [c0 + Δc/2] ) / [ |v| ( |v| + s [c0 + Δc/2] ) ] ‒
( (|v|² + s²) + 2 s |v| [c0 ‒ Δc/2] ) / [ |v| ( |v| + s [c0 ‒ Δc/2] ) ] |

I'm going to try to get out of this tangled mess by consolidating the denominators:

P(yaw) ∝
| [ ( |v| + s [c0 ‒ Δc/2] ) ( (|v|² + s²) + 2 s |v| [c0 + Δc/2] ) ‒
( |v| + s [c0 + Δc/2] ) ( (|v|² + s²) + 2 s |v| [c0 ‒ Δc/2] ) ] /
[ |v| ( (|v| + s c0)² ‒ s² (Δc/2)² ) ] |

Lots of stuff cancels... only terms proportional to Δc (but not (Δc)²) survive in the numerator:

numerator =
2 [ ‒s ( |v|² + s² + 2 s |v| c0 ) + 2 s |v| (|v| + s c0) ] (Δc/2) =
2 [ ‒s |v|² ‒ s³ ‒ 2 s² |v| c0 + 2 s |v|² + 2 s² |v| c0) ] (Δc/2) =
2 [ s |v|² ‒ s³] (Δc/2) =
2 s (|v|² ‒ s²) (Δc/2) =
s (|v|² ‒ s²) Δc =

So:

P(yaw) ∝
| s (|v|² ‒ s²) Δc / [ |v| ( (|v| + s c0)² ‒ s² (Δc/2)² ) ] | =
| (s / |v|) (|v|² ‒ s²) Δc / ( (|v| + s c0)² ‒ s² (Δc/2)² ) |

It's clear the result only depends on the ratio of s and |v|, not on the magnitude, so if I define:

γ = |v| / s

Then I can further simplify:
P(yaw) ∝ | (γ ‒ 1/γ) Δc / ( (γ + c0)² ‒ (Δc/2)² ) |

Δc = 2 sqrt[ (1/γ)² sin⁴ yaw + cos² yaw ‒ (1/γ)² sin² yaw ]
= 2 sqrt[ (1/γ)² sin² yaw (sin² yaw ‒ 1) + cos² yaw ]
= 2 sqrt[ ‒(1/γ)² sin² yaw cos² yaw + cos² yaw ]
= 2 (cos yaw) sqrt[1 ‒ (1/γ)² sin² yaw]
(Δc/2)² = (cos² yaw) [1 ‒ (1/γ)² sin² yaw]
c0 = ‒sin² yaw / γ

It's getting better, but when I plotted the result, I realized I wasn't yet done. Combine these three:

P(yaw)
∝ | 2 (γ ‒ 1/γ) cos yaw sqrt[1 ‒ (1/γ)² sin² yaw] / ( (γ ‒ sin² yaw / γ)² ‒ cos² yaw (1 ‒ (1/γ)² sin² yaw) ) |
= | 2 (γ ‒ 1/γ) cos yaw sqrt[1 ‒ sin² yaw / γ²] / ( γ² (1 ‒ sin² yaw / γ²)² ‒ cos² yaw (1 ‒ sin² yaw / γ²) ) |

Substitute in a temporary variable:
z ≡ sqrt [ 1 ‒ (1/γ)² sin² yaw ]

Then
P(yaw) ∝ | 2 (γ ‒ 1/γ) z cos yaw / ( γ² z⁴ ‒ z² cos² yaw ) |
= | 2 z (γ ‒ 1/γ) cos yaw / [ z² ( γ² z² ‒ cos² yaw ) ] |
= | 2 (γ ‒ 1/γ) cos yaw / [ z ( γ² z² ‒ cos² yaw ) ] |
= | 2 (γ² ‒ 1) cos yaw / [ z γ ( γ² ‒ 1 ) ] |
= 2 cos yaw / sqrt [ γ² ‒ sin² yaw ]

Wow -- that's a remarkable improvement. Jumping ahead to next post, I can evaluate the normalizing constant analytically, yielding:

P(yaw) = 2 cos yaw / ( π sqrt [ γ² ‒ sin² yaw ] )

A quick sanity check here: the result depends only on even powers of sin yaw, so the probability of positive and negative yaw values of the same magnitude are the same. That's good.

Here's a quick plot: I'll show it again next post. Note the y-axis is logarithmic.

I'll continue with this next time...

1 comment:

fishboy said...

Nice one Dan. Great to see a visual representation of how the probability changes as the wind speed increases, and pours some water on the notion that wheels and other gear are "optimised" for a sweet spot of 7.5 to 15 deg yaw.

The most important yaw angle is the one you're riding in...