# UnitMath Examples ( Avaiation ) Last Modified: 2/5/2000

### email Examples FAQ Home Sales \$\$\$ What's New Windows demo

This page is used to present examples of using UnitMath in aviation. < information to answers I've presented to newsgroups.

### Find Heading; Given Ground Course and Wind (Using Solver) TOP Find the angle that a plane must fly, and the ground speed, given: a air speed, ground heading, and wind.

The figures at the right show what is known and what we are looking for.

In the figures:
TAS: Plane's true air speed.
COG: Plane's course on ground.
SOG: Plane's speed relative to the ground.
WA: Angle of the wind.
WS: Magnitude of the winds speed.

From the middle drawing the speed in the "x" direction is TAS cos( CS ) + WS cos( WA ), and the speed in the "y" direction is TAS sin( CS ) + WS sin( WA ). Using the function atanxy() the following equation is true at the desired CS.

atanxy( TAS cos( CS ) + WS cos( WA ); TAS sin( CS ) + WS sin( WA ) ) = COG

### Examples

Simple case the plane should fly at COG, but a good test for the algorithm.

WA: 45 deg;
WS: 10 knots;
TAS: 100 knots;
COG: 45 deg;
CS: 0 to 2 pi as deg;

solve( atanxy( TAS cos( CS ) + WS cos( WA ); TAS sin( CS ) + WS sin( WA ) ) = COG; CS: deg/10 ) ~ CS: ( 44.9 to 45.1 ) deg;

CS: ( 44.9 to 45.1 ) deg;
SOG: sqrt( ( TAS cos( CS ) + WS cos( WA ) )^2 + ( TAS sin( CS ) + WS sin( WA ) )^2 ) as knots ~ 110.000 knots

"test"
atanxy( TAS cos( CS ) + WS cos( WA ); TAS sin( CS ) + WS sin( WA ) ) as deg ~ 45. deg

Another simple case again the plane should fly at COG, but again a good test for the algorithm.

WA: 45 deg + 180 deg; WS: 10 knots; TAS: 100 knots; COG: 45 deg;
CS: 0 to 2 pi as deg;

solve( atanxy( TAS cos( CS ) + WS cos( WA ); TAS sin( CS ) + WS sin( WA ) ) = COG; CS: deg/10 ) ~ CS: ( 44.9 to 45.1 ) deg;

CS: ( 44.9 to 45.1 ) deg;
SOG: sqrt( ( TAS cos( CS ) + WS cos( WA ) )^2 + ( TAS sin( CS ) + WS sin( WA ) )^2 ) as knots ~ 90.000 knots

"test"
atanxy( TAS cos( CS ) + WS cos( WA ); TAS sin( CS ) + WS sin( WA ) ) as deg ~ 45. deg

A more realistic example note that the wind speed and the plane speed are not exact. This is more realistic and gives you a flavor for the possible angles ( CS ) needed and the resulting SOGs.

WA: 0 deg; WS: 100 knots pm 5 knots; TAS: 100 knots pm 1 knot; COG: 45 deg; CS: 0 to 2 pi as deg;

solve( atanxy( TAS cos( CS ) + WS cos( WA ); TAS sin( CS ) + WS sin( WA ) ) = COG; CS: deg/10 ) ~
CS: ( 86.6 to 93.6 ) deg;
CS: ( 176.4 to 180.1 ) deg;

CS: ( 86.6 to 93.6 ) deg;
SOG: sqrt( ( TAS cos( CS ) + WS cos( WA ) )^2 + ( TAS sin( CS ) + WS sin( WA ) )^2 ) as knots ~ ( 132.772 to 150.008 ) knots

Note the second case can be ignored as atanxy gets a false zero there.
"test"
atanxy( TAS cos( CS ) + WS cos( WA ); TAS sin( CS ) + WS sin( WA ) ) as deg ~ ( 41.689 to 48.694 ) deg

A final example to show that the equation works for angles outside the range 0 to 180 degrees..

WA: 270 deg; WS: 25 knots pm 4 knots; TAS: 225 knots pm 1 knot; COG: 195 deg; CS: 0 to 2 pi as deg;

solve( atanxy( TAS cos( CS ) + WS cos( WA ); TAS sin( CS ) + WS sin( WA ) ) = COG; CS: deg/10 ) ~ CS: ( 187.8 to 189.9 ) deg;

CS: ( 187.8 to 189.9 ) deg; SOG: sqrt( ( TAS cos( CS ) + WS cos( WA ) )^2 + ( TAS sin( CS ) + WS sin( WA ) )^2 ) as knots ~ ( 228. to 230. to 233. ) knots

"test"
atanxy( TAS cos( CS ) + WS cos( WA ); TAS sin( CS ) + WS sin( WA ) ) as deg ~ ( 193. to 195. to 197. ) deg Find the angle that a plane must fly, and the ground speed, given: a air speed, ground heading, and wind.

The figures at the right show what is known and what we are looking for.

In the figures:
TAS: Plane's true air speed.
COG: Plane's course on ground.
SOG: Plane's speed relative to the ground.
WA: Angle of the wind.
WS: Magnitude of the winds speed.

let:
wx: wind speed in the "x" direction.
wy: wind speed in the "y" direction.
gx: plane ground speed in the "x" direction.
gy: plane ground speed in the "y" direction.
ga: is slope of the ground course.

then
wx: WS cos( WA );
wy: WS sin( WA );
ga: tan( COG );

We then have two equations.
( gx - wx ) ^2 + ( gy - wy ) ^2 = TAS^2
gy = ga * gx

and with a bit af algebra we get a quadratic equation in gx. Which can be solved with the well known quadratic formula.
( gx - wx ) ^2 + ( ga * gx - wy ) ^2 - TAS^2 = 0
gx^2 - 2 gx wx + wx^2 + ga^2 gx^2 - 2 wy gx ga + wy^2 - TAS^2 = 0
( 1 + ga^2 ) gx^2 - 2 ( wy ga + wx ) gx + ( wx^2 + wy^2 - TAS^2 ) = 0

gx = -b pm sqrt( sq b - 4 a c )/(2 a )
a = ( 1 + ga^2 )
b = - 2 ( wy ga + wx )
c = ( wx^2 + wy^2 - TAS^2 )

### Examples

Simple case the plane should fly at COG, but a good test for the algorithm. Note there are always two solutions.

WA: 45 degrees; WS: 10 knots;
wx: WS cos( WA ) as knots; wy: WS sin( WA ) as knots;
COG: 45 deg; ga: tan( COG ); = 1
TAS: 100 knots;

First Solution:

gx: ( 2 ( wy ga + wx ) + sqrt( sq (2 ( wy ga + wx )) - 4 ( 1 + ga^2 ) (wx^2 + wy^2 - TAS^2) ) ) /(2 ( 1 + ga^2 ) ) as knots ~ 77.8 knots
gy: ga * gx as knots; ~ 77.8 knots
SOG: sqrt( sq gx + sq gy ) as knots; = 110 knots
PA:atanxy( gx - wx; gy - wy ) as deg = 45 deg

Second Solution:

gx: (2 ( wy ga + wx ) - sqrt( sq (2 ( wy ga + wx )) - 4 ( 1 + ga^2 ) (wx^2 + wy^2 - TAS^2) ) )/(2 ( 1 + ga^2 ) ) as knots ~ -63.6 knots
gy: ga * gx as knots; ~ -63.6 knots
SOG: sqrt( sq gx + sq gy ) as knots; = 90 knots
PA:atanxy( gx - wx; gy - wy ) as deg = 225 deg

No surprises the speeds add or subtract as you fly with or against the wind.

A more realistic case.

WA: 340 degrees; WS: 35 knots;
wx: WS cos( WA ) as knots; wy: WS sin( WA ) as knots;
COG: 195 deg; ga: tan( COG ); ~ 0.3
TAS: 225 knots;

First Solution:

gx: ( 2 ( wy ga + wx ) + sqrt( sq (2 ( wy ga + wx )) - 4 ( 1 + ga^2 ) (wx^2 + wy^2 - TAS^2) ) ) /(2 ( 1 + ga^2 ) ) as knots ~ 244.2 knots
gy: ga * gx as knots; ~ 65.4 knots
SOG: sqrt( sq gx + sq gy ) as knots; ~ 252.8 knots
PA:atanxy( gx - wx; gy - wy ) as deg ~ 20.1 deg

Second Solution:

gx: (2 ( wy ga + wx ) - sqrt( sq (2 ( wy ga + wx )) - 4 ( 1 + ga^2 ) (wx^2 + wy^2 - TAS^2) ) )/(2 ( 1 + ga^2 ) ) as knots ~ -188.8 knots
gy: ga * gx as knots; ~ -50.6 knots
SOG: sqrt( sq gx + sq gy ) as knots; ~ 195.4 knots
PA:atanxy( gx - wx; gy - wy ) as deg ~ 189.9 deg

If you have a 35 knot wind blowing at 340 deg and your desired course is 195 deg, then you should set a heading of 189.9 degrees, and your speed over the ground will be 195.4 knots. Note everything was assumed to be exact which in reality it isn't. The next example is more realistic.

A final example shows the effects of uncertainty in the calculations.

WA: 270 degrees; WS: ( 25 pm 4 ) knots;
wx: WS cos( WA ) as knots; wy: WS sin( WA ) as knots;
COG: 195 deg; ga: tan( COG ); ~ 0.3
TAS: ( 225 pm 1 ) knots;

First Solution:

gx: ( 2 ( wy ga + wx ) + sqrt( sq (2 ( wy ga + wx )) - 4 ( 1 + ga^2 ) (wx^2 + wy^2 - TAS^2) ) ) /(2 ( 1 + ga^2 ) ) as knots ~ ( 207.4 to 209.8 to 212.2 ) knots
gy: ga * gx as knots; ~ ( 55.6 to 56.2 to 56.9 ) knots
SOG: sqrt( sq gx + sq gy ) as knots; ~ ( 214.7 to 217.2 to 219.7 ) knots
PA:atanxy( gx - wx; gy - wy ) as deg ~ ( 20.1 to 21.2 to 22.2 ) deg

Second Solution:

gx: (2 ( wy ga + wx ) - sqrt( sq (2 ( wy ga + wx )) - 4 ( 1 + ga^2 ) (wx^2 + wy^2 - TAS^2) ) )/(2 ( 1 + ga^2 ) ) as knots ~ ( -223.9 to -222.3 to -220.7 ) knots
gy: ga * gx as knots; ~ ( -60.0 to -59.6 to -59.1 ) knots
SOG: sqrt( sq gx + sq gy ) as knots; ~ ( 228.5 to 230.2 to 231.8 ) knots
PA:atanxy( gx - wx; gy - wy ) as deg ~ ( 187.8 to 188.8 to 189.9 ) deg

If you have a ( 21 to 29 ) knot wind blowing at 270 deg and your desired course is 195 deg, then you should set a heading of ( 187 to 190 ) degrees, and your speed over the ground will be ( 228 to 231 ) knots.

### Weight and Balance TOP

Find the total weight and center of gravity of a loaded plane. The center of gravity as measured from the datum equals TotalMoment / TotalWeight.
Where:
TotalMoment = W1 D1 + W2 D2 + W3 D3 + W4 D4 + W5 D5
TotalWeight = W1 + W2 + W3 + W4 + W5

Planes are designed to handle a center of gravity (CG) any where from the "forward CG limit" to the "aft CG limit". Exceeding these limits makes the plane unstable and is very dangerous.

The following three examples show how to find the CG using Unitmath, and the effects of uncertainty on the result. In the following lbf indicates pounds of force.

### Example 1: Exact Data

Define the Densities ( weight / volume ).
OilDensity: ( 7 + 1/2 ) lbf / gallon;
FuelDensity: 6 lbf / gallon;

Define the Weights
Wt_EmptyPlane: 1625 lbf;
Wt_Oil: 12 qt * OilDensity;
Wt_Pilot: 165 lbf;
Wt_FrontPassenger: 120 lbf;
Wt_RearPassenger: 290 lbf;
Wt_Fuel: 40 gallons * FuelDensity;
Wt_Baggage: 90 lbf;

Find the Total Weight.
TotalWeight: Wt_EmptyPlane + Wt_Oil + Wt_Pilot + Wt_FrontPassenger + Wt_RearPassenger + Wt_Fuel + Wt_Baggage as lbf; = ( 2,552 + 1/2 ) lbf
TotalWeight as N ~ 11,354.1 N

Define the Moment Arms.
arm_EmptyPlane: 35 inches;
arm_Oil: - 15 inches;
arm_Pilot: 3 ft;
arm_FrontPassenger: 3 ft;
arm_RearPassenger: 70 inches;
arm_Fuel: 4 ft;
arm_Baggage: 95 inches;

Find the Moments.
moment_EmptyPlane: Wt_EmptyPlane * arm_EmptyPlane; ~ 4,739.6 ft lbf
moment_Oil: Wt_Oil * arm_Oil; = -( 28 + 1/8 ) ft lbf
moment_Pilot: Wt_Pilot * arm_Pilot; = 495 ft lbf
moment_FrontPassenger: Wt_FrontPassenger * arm_FrontPassenger; = 360 ft lbf
moment_RearPassenger: Wt_RearPassenger * arm_RearPassenger; = ( 1,691 + 2/3 ) ft lbf
moment_Fuel: Wt_Fuel * arm_Fuel; = 960 ft lbf
moment_Baggage: Wt_Baggage * arm_Baggage; = ( 712 + 1/2 ) ft lbf

Find the Total Moment.
TotalMoment: moment_EmptyPlane + moment_Oil + moment_Pilot + moment_FrontPassenger + moment_RearPassenger + moment_Fuel + moment_Baggage as inch lbf; = 107,167.5 inch lbf

Find the Center of Gravity.
CG: TotalMoment / TotalWeight as inches ~ 42.0 inches
CG as ft & inches & in/16 ~ 3 ft + 5 inches + 15.8 in/16

So the total weight of the plane is ( 2,552 + 1/2 ) lbf and the center of gravity is at about ( 3 ft + 5 inches + 15.8 in/16 ).

### Example 2: Some Uncertainty.

Your data is never exact, so it pays to see what the range of results is with reasonable uncertainty.

Define the Densities ( weight / volume ).
OilDensity: 7.50 lbf / gallon;
FuelDensity: 6.0 lbf / gallon;

Define the Weights.
Wt_EmptyPlane: 1625 lbf * ( 1 pm 5 % ); ~ ( ( 1,543 + 3/4 ) to ( 1,706 + 1/4 ) ) lbf
Wt_Oil: 12.0 qt * OilDensity; ~ ( 22.4 to 22.6 ) lbf
Wt_Pilot: (165 pm 5 ) lbf;
Wt_FrontPassenger: (120 pm 5 ) lbf;
Wt_RearPassenger: ( 290 pm 5 ) lbf;
Wt_Fuel: 40. gallons * FuelDensity;
Wt_Baggage: 90. lbf;

Find the Total Weight.
TotalWeight: Wt_EmptyPlane + Wt_Oil + Wt_Pilot + Wt_FrontPassenger + Wt_RearPassenger + Wt_Fuel + Wt_Baggage as lbf; ~ ( 2,450.7 to 2,654.4 ) lbf
TotalWeight as N ~ ( 10,901.1 to 11,807.3 ) N

"Define the Moment Arms."
arm_EmptyPlane: 35. inches; ~ ( ( 2 + 7/8 ) to 3.0 ) ft
arm_Oil: - 15. inches; ~ ( -( 1 + 1/4 ) Ý 4.2e-2 ) ft
arm_Pilot: 3 ft pm 6 inch; ~ 3. ft
arm_FrontPassenger: 3 ft pm 6 inch; ~ 3. ft
arm_RearPassenger: 70 inches pm 6 inch; ~ ( ( 5 + 5/6 ) Ý 1/2 ) ft
arm_Fuel: 4 ft pm 3 inch; ~ 4. ft
arm_Baggage: 95 inches pm 6 inch; ~ ( ( 7 + 11/12 ) Ý 1/2 ) ft

Find the Moments.
moment_EmptyPlane: Wt_EmptyPlane * arm_EmptyPlane; ~ ( 4,438.3 to 5,047.7 ) ft lbf
moment_Oil: Wt_Oil * arm_Oil; ~ -3.e1 ft lbf
moment_Pilot: Wt_Pilot * arm_Pilot; ~ ( 400 to 495 to 595 ) ft lbf
moment_FrontPassenger: Wt_FrontPassenger * arm_FrontPassenger; ~ ( 287.5 to 437.5 ) ft lbf
moment_RearPassenger: Wt_RearPassenger * arm_RearPassenger; ~ 2.e3 ft lbf
moment_Fuel: Wt_Fuel * arm_Fuel; ~ ( 881.3 to 1,041.4 ) ft lbf
moment_Baggage: Wt_Baggage * arm_Baggage; ~ ( 663.8 to 761.7 ) ft lbf

Find the Total Moment.
TotalMoment: moment_EmptyPlane + moment_Oil + moment_Pilot + moment_FrontPassenger + moment_RearPassenger + moment_Fuel + moment_Baggage as inch lbf; ~ ( 97,940.6 to 116,694.0 ) inch lbf
TotalMoment as ft lbf ~ ( 8,161.7 to 9,724.5 ) ft lbf

Find the Center of Gravity. Note this calculation took a bit over 4 minutes. The time is required since we are finding the global extremes of an equation with 14 variables
CG: TotalMoment / TotalWeight as inches ~ ( 39.5 to 42.0 to 44.5 ) inches
( 39.5 to 42.0 to 44.5 ) inches as ft & inches & in/16 ~ 3 ft + ( 3.5 to 6 to 8.5 ) inches

As you would expect the larger the uncertainties in the data the larger the uncertainty in the result. So the total weight of the plane is between 2,450.7 lbf and 2,654.4 lbf and the center of gravity is at between 39.5 inches and 44.5 inches. So long as the forward CG limit is less than 39.5 inches and the aft CG limit is > 44.5 inches you're fine.

### Example 3: Large Uncertainties.

It's unlikely that all the weights will be at the extremes and placed at the worst possible place, but it's worth knowing how forgiving your plane is.

Define the densities ( weight / volume ).
OilDensity: 7.50 lbf / gallon;
FuelDensity: 6.0 lbf / gallon;

Define the weights.
Wt_EmptyPlane: 1625 lbf * ( 1 pm 20 % ); ~ ( 1,300 to 1,625 to 1,950 ) lbf
Wt_Oil: (12 pm 1) qt * OilDensity; ~ ( 20.6 to 22.5 to 24.4 ) lbf
Wt_Pilot: (165 pm 10 ) lbf;
Wt_FrontPassenger: (120 to 200 ) lbf;
Wt_RearPassenger: ( 120 to 300 ) lbf;
Wt_Fuel: ( 40 to 50 ) gallons * FuelDensity;
Wt_Baggage: ( 100 to 300 ) lbf;

Find the Total Weight.
TotalWeight: Wt_EmptyPlane + Wt_Oil + Wt_Pilot + Wt_FrontPassenger + Wt_RearPassenger + Wt_Fuel + Wt_Baggage as lbf; ~ ( 2,053.6 to 3,251.9 ) lbf

Define the Moment Arms.
arm_EmptyPlane: ( 34 to 36.1 ) inches; ~ ( 2.8 to 3.0 ) ft
arm_Oil: - 15. inches; ~ ( -1.3 Ý 4.2e-2 ) ft
arm_Pilot: 3 ft pm 9 inch; ~ ( 3 Ý 0.8 ) ft
arm_FrontPassenger: 3 ft pm 9 inch; ~ ( 3 Ý 0.8 ) ft
arm_RearPassenger: 70 inches pm ft; ~ ( 5.8 Ý 1 ) ft
arm_Fuel: 4 ft pm 3 inch; ~ 4. ft
arm_Baggage: 95 inches pm ft; ~ ( 7.9 Ý 1 ) ft

Find the Moments.
moment_EmptyPlane: Wt_EmptyPlane * arm_EmptyPlane; ~ ( 3,683.3 to 4,746.4 to 5,874.4 ) ft lbf
moment_Oil: Wt_Oil * arm_Oil; ~ ( -31.5 to -24.9 ) ft lbf
moment_Pilot: Wt_Pilot * arm_Pilot; ~ ( 348.8 to 495 to 656.3 ) ft lbf
moment_FrontPassenger: Wt_FrontPassenger * arm_FrontPassenger; ~ ( 270 to 480 to 750 ) ft lbf
moment_RearPassenger: Wt_RearPassenger * arm_RearPassenger; ~ ( 580 to 2,050 ) ft lbf
moment_Fuel: Wt_Fuel * arm_Fuel; ~ 1.e3 ft lbf
moment_Baggage: Wt_Baggage * arm_Baggage; ~ ( 691.7 to 1,583.3 to 2,675 ) ft lbf

Find the Total Moment.
TotalMoment: moment_EmptyPlane + moment_Oil + moment_Pilot + moment_FrontPassenger + moment_RearPassenger + moment_Fuel + moment_Baggage as inch lbf; ~ ( 77,216.9 to 159,196.1 ) inch lbf
TotalMoment as ft lbf ~ ( 6,434.7 to 9,581.6 to 13,266.3 ) ft lbf

Find the Center of Gravity. Note this calculation took almost 6 minutes. The time is required since we are finding the global extremes of an equation with 14 variables.

CG: TotalMoment / TotalWeight as inches ~ ( 36.3 to 52.6 ) inches

So the total weight of the plane is between 2,053.6 lbf and 3,251.9 lbf and the center of gravity is between 36.3 inches and 52.6 inches. So long as the forward CG limit is less than 36.3 inches and the aft CG limit is greater than 52.6 inches you're fine. It not you need to either get better data, or more control over the situation.