# Sonar 2 Equations

A) Coordinate System

Figure 1 shows the Cartesian coordinate system I used on my sonar system.Â  This system uses two planes which are separated by a line perpendicular from the face of the transmitter. The face of the transmitter transducer is X = 0 and Y = 0.Â  In Plane 1 (right plane) both the angle and X are positive and in Plane 2 both the angle and X are negative. Â In both planes Y is positive and increase as the distance from the transmitter increases.Â  In my system both receivers are six inches from the transmitter.

Figure 1 â€“ Sonar Coordinate System

Â

Â

Echo Time and distance

Distance in inches = ( echo time in uS / 2 )Â  / 74.0 = Echo Time uS / 148.0

Divided by 2 because the echo time is a round trip, double the distance

Divided by 74.0 because sound travels one inch in 74.0uS at 25Â°C.

Â

B) Identifying Objects from two echoes

If the object is directly in front of the sonar system the time it takes the echo from an object to reach the right and left receivers will be the same.Â  As the object is moved to the left or right of the sonarâ€™s center the echo will take longer to reach one receiver that the other receiver.Â  Â From this time difference the objects coordinates can be calculated.Â  This gives you the X and Y location of the closest edge of the object relative to the sonarâ€™s transmitter.Â  From the pulse width of the echoes the length of the object can be estimated and the objectâ€™s far edge coordinates can be calculated.Â  Since a number of factors can affect the signalâ€™s pulse width the far edge coordinates is only an estimate.

C) Correlation between Right and Left Echoes

Â When combining the echoes from the right and left receivers to determine the coordinates of an object, it is important to make sure the two echoes are actually from the same object.Â  Echoes from objects at an angle greater than 30Â° from the sonarâ€™s norm will be very weak and it is unlikely that both receivers will receive echoes from an object at an angle greater than +/-30Â°.Â  Therefore 30Â° can be used to establish the maximum difference in time between left and right echo signals coming from the same object.

Trig can be used to calculate this max difference, however it can be approximated using the equation below.Â  In this equation, Dmax is a good estimate of the maximum distance between echoes coming from the same object.Â  At a distance of 40â€ the two echoes must be within about 4â€ to be from the same object.Â  At a distance of 80â€ the two echoes must be within about 1.0â€ to be from the same object.

Maximum distance between two echoes from same object

Eavg = ( Edr + Edl) / 2

Dmax = 2060188 / ( Eavg / 0.00009315)1.050964

Dmax = Maximum Distance between two echoes to be from same object

Â Â Â Â Â Â Â  Edr = Right Echo Distance

Â Â Â Â Â Â Â  Edl = Left Echo Distance

Â Â Â Â Â Â Â  Eavg = Average Echo Distance

Graph #1 – Max Distance between two echoes from same object

Â

D) Objects with two echoes within maximum seperation

a) Object is in front or to the side

Echoes received be directly in front of the sonar system or off to one side or the other of the sonar system.Â  The equations to calculate the X coordinate of an object is slightly different for objects directly in front verses object to the side of the sonar system.Â  Figure 2 shows the echoes, A & C from an object in front of the sonar and within two perpendiculars from the center of each receiver.Â  Figure 3 shows the echoes, A & C, from an object outside the receiversâ€™ perpendiculars.

Figure 2, Object inside Receiversâ€™ perpendiculars

Figure 3, Object outside Receiversâ€™ perpendiculars

b) X Calculations

1) Objects Inside Receiversâ€™ Perpendicular, Figure 2

If the sqrt ( abs( A2 â€“ C2)) is less than the distance between the two receivers the object is within the receiversâ€™ perpendiculars.

When an object is inside the perpendiculars, the X calculations from two echoes is calculating the distance to the center of the object, not to the edge of the object.

The equation is (see Appendix A for derivation):

if ( A > C )

Â  Â  Â  Â  X2 Â =Â  (C2Â  – A2 + X12)/ 2X1

Â  Â  Â  Â  Xo =Â  X2 – X1/2

Â  Â  Â  Â  Â  Â  Â  Â if ( C > A )

Â  Â  Â  Â  X2 Â =Â  (A2 – C2 + X12)/ 2X1

Â  Â  Â  Â  Xo =Â  X2 – X1/2

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  XoÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  X distance to the Â center of object from the sonar norm Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  A Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Echo distance to right side receiver ( ET / 148)

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  C Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Echo distance to the left side receiver (Et / 148)

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  X1 Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Distance between the two receivers.

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  All distances are in inches.

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Echo Time is in uS.

2) Objects Outside Receiversâ€™ Perpendicular, Figure 3

If the sqrt ( A2 â€“ C2) is greater than the distance between the two receivers the object is outside the receiversâ€™ perpendiculars.

When an object is outside the perpendicular, the X calculations from the two echoes is the distance to objectâ€™s closest edge.

The equations is (See Appendix B for derivation):

if ( A > C )

X2 Â = Â (A2C2 â€“ X12)/ 2X1

Xo = ( X2 + X1/2 )

if ( C > A )

X2 Â = Â (C2 -A2 â€“ X12)/ 2X1

Xo = -( X2 + X1/2 )

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  XoÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  X distance from sonar norm to leading edge of object

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  A Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Echo distance to right side receiver

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  C Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Echo distance to the left side receiver

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  X1 Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Distance between the two receivers.

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  All distances are in inches.

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Echo Time is in uS.

Â

3) Y Calculations

The objectâ€™s Y coordinate is the distance from the Sonar plane, to the face or the object closest edge.Â  In Figures 1 & 2 this distance labeled Y.Â  The equation for Y is the same if the object is inside or outside the receiversâ€™ perpendiculars.Â  It is:

Yo = sqrt (C2 â€“ X22)

E) Object with only one Echo

There is a 12â€ on the outside of each receiver window, the separation of the two receivers, where an object will be picked up by one receiver and not the other receiver.

Figure #4 – Single Echo area

This window can be described with the following equation.

XRmin = C * Sin 30Â° ) â€“ 12â€

XLmin = -C * Sin 30Â° ) + 12â€

An object detected by one receiver and not the other falls somewhere between Xmin and Xmax.Â  From my testing it appears the width of this window is more like 8â€ and good estimate of the objectâ€™s X coordinate can be obtained with the following equation.

Â Â Â Â Â Â Â  Echo received by Right Receiver

Yo =Â  ( Echo Time Â /148 )

Xo = 0.5*C â€“ 10

Yo = ( Echo Time Â / 148 )

Xo = 10 – 0.5*C

F) Far Edge or Object Width Calculations

The Pulse Width of the returned echo is a good indication of size (length) of the object.Â  However, there are a number of things other things that will also affect the pulse width of the echo.

These are a main things that will affect the pulse width of an echo.

• Material object is made of.
• Angle of the object.
• Height of object.
• Width of object.
• Distance the object is from the sonar.
• Transmitter Pulse Width.

The first two are unknowns which at this time cannot be factored in an equation.Â  However, in my Sonar 3 system I am measuring the amplitude of the echo pulse which may help identify the objects material and angle.

The echo from an object of some given size will have a minimum pulse width that is related to the transmitted signalâ€™s pulse width.Â  The transmitter pulse width is related to the number of transmitter cycles and the amount of ringing. Â In my Sonar 2 I used two transmit cycles in most of my testing which resulted in in resulted in a transmitter pulse width of about 150uS, two cycles plus ringing.Â  This creates an offset of about 1.8â€ which must be subtracted from the far edge calculation.Â  In my Sonar 3 I have reduced the transmit cycles to one and am working on some ideas to reduce the ringing.

Both the width and height of the object will change the Pulse Width of the returned echo.Â  The reason this happens is because as you move across the surface of the object away from closest edge the distance to the receiver increases and it takes longer for the echo to return.Â  To the receiver this appears to be one long echo which produces a longer pulse width.

For objects with two matching echoes, I use the largest pulse width.Â  However I am still reviewing this.Â  It might be better to use the pulse width of the shortest echo distance or an average of the two pulse widths.

Also distance affects the pulse width.Â  When the same object is moved further away from the sonar system its pulse width becomes shorter.Â  Therefore there is a need for a correction factor, which I have labeled K, that adjusts the pulse width based on echo distance.Â  I am still working on defining the best value for K.

The following equations are used to generate a rough estimate of the size of the object.Â  They can be used to tell the difference between a thin pole and a wall, but there are too many unknowns to accurately determine the width of the object

Figure 5 â€“ Object Size

Ed Â Â Â Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â Â  Echo Distance to the closest edge of object in inches

Edf Â Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â Â  Echo distance to far edge

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  PWÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Pulse Width in uS

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  PwÂ Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Pulse Width in inches

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  OsÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Object Size, inches

KÂ Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Pulse width correction for distance, for now it is zero.

Adjust Pulse Width for distance and Convert to inches

PwÂ Â Â Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â  (( PW / 2 )Â  / 74 ) * Â ( Â Ed * K )Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  // Convert Pulse Width to Inches

Far Edge Echo Distance

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  EdfÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Ed + Pw

Object Size

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  OSÂ Â Â Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â  âˆš ( Edf2 â€“ Ed2 )

Far Edge Coordinates Calculations

Assuming the Object Size is its width, not it height, these are coordinates of the far edge.

Far Edge XeÂ Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â  Xs + OS

Far Edge YÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Assumed to be same as near edge Y

F)Â  Examples

a) Single Echo Object

Echo TimeÂ Â Â Â Â Â Â Â Â Â  (A)Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  9,960uS

Echo Pulse WidthÂ Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  300uS

Â

Yo =Â  ( Echo Time Â /148 )

Xo = 0.5*C â€“ 10

Calculation

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Yo = 9960 / 148 = 67.2â€

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Xo = 0.5 *67.2 – 10 = 23.6â€

Yo = 67.2â€

Xo = 23.6â€

Far Edge Calculation from Pulse Width

Â PwÂ Â Â Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â  (( PW / 148 ) * Â (Â  Ed * K )

PwÂ Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  (( 300us / 148 ) Â = Â 2.0â€

EdfÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Ed + Pw

EdfÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  67.2 + 2.0Â  =Â  69.2â€

Â OSÂ Â Â Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â  âˆš ( Edf2 â€“ Ed2 )

Â OSÂ Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  âˆš (69.22 â€“ 67.22)Â  =Â  16.6â€

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  XeÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Xs + OS

XeÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  23.6â€ + 16.6â€ = 40.2â€

Object SizeÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â  16.6â€

Far Edge XÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â  40.2″ (estimate)

b) Double Echo Object, Inside Perpendiculars

Right Receiver Echo (A) TimeÂ Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  8,513uS Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  DistanceÂ Â Â Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  57.5â€

Left Receiver EchoÂ Â Â  (C) TimeÂ Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  8,330uS Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Distance Â Â Â Â Â Â Â Â Â Â Â Â Â  â€Â Â Â Â Â Â Â Â Â Â Â Â Â  56.2â€

Pulse WidthÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  850uS

Â

X2 Â =Â  (A2C2 + X12)/ 2X1

Xo = X1/2 â€“ X2

Yo = sqrt (C2 â€“ X22)

Â X & Y Calculations

X2 = ( 56.22 â€“ 57.52 + 122 ) / ( 2 * 12) = 1.2

X0 = 6.0 â€“ 1.2 = 4.8â€

Y0 = sqrt ( 56.22 â€“ 1.22 ) = 56.1â€

Xo = 4.8â€

Y0 = 56.1â€

Far Edge Calculation from Pulse Width

Right Pulse Width > Left Pulse Width, use Right Pulse Width

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  PwÂ Â Â Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â  (( PW / 148 ) * Â (Â  Ed * K )

PwÂ Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  (( 850us / 148 )Â  =Â  5.7â€

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â EdfÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Ed + Pw

EdfÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  57.5 + 5.7Â  =Â  63.2â€

Â Â Â Â Â Â Â Â Â Â Â Â Â Â  OSÂ Â Â Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â  âˆš ( Edf2 â€“ Ed2 )

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  OSÂ Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  âˆš (63.22 â€“ 57.52)Â  =Â  26.3â€

XeÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Xs – OS

XeÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  -6.1â€ – 26.3â€ = -32.4â€

Object SizeÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  26.3â€

Far Edge XÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â  -32.4â€ (estimate)

The pulse width of the returned echo is 850uS which corresponds to an object size of about 26â€.Â  If this is the width of the object its far edge X coordinate would be 32.4â€.Â  However, this is out of the sonarâ€™s range at a Y distance of 56.2â€, therefore this large pulse width must be due to the height of the object and may not be an indication of its width.Â  All we can say is this is an indication of the objects size.

Â

c) Double Echo Object, Outside Perpendiculars

Right Receiver Echo (C) TimeÂ Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  21,108uSÂ Â Â Â Â Â Â Â Â Â Â Â Â  DistanceÂ Â Â Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  142.6â€

Left Receiver EchoÂ Â Â  (A) TimeÂ Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  21,024uSÂ Â Â Â Â Â Â Â Â Â Â Â Â  Distance Â Â Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  142.0â€

Right Pulse WidthÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  425uS

Left Pulse WidthÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  525uS

Â

X2 Â =Â  ((A2C2 â€“ X12)/ 2X1 ) + X1/2

Xo = X2 + X1/2

Ys = sqrt (C2 â€“ X22)

Calculations

X2 = (( 142.62 â€“ 142.02 â€“ 122 ) / 2*12) = 24.6â€

Xo = 24.6 + 12 / 2 = 30.6â€

Yo = sqrt ( 142.02 â€“ 24.62 )Â  =Â  139.8â€

Xo = 30.6â€

Y0 = 139.8â€

Â

Far Edge Calculation from Pulse Width

Â Left Pulse Width > Right Pulse Width, use Left Pulse Width

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  PwÂ Â Â Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â  (( PW / 148 ) * Â (Â  Ed * K )

PwÂ Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  (( 525 / 148 )Â  =Â  3.5â€

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â EdfÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Ed + Pw

EdfÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â Â  + 3.5Â  =Â  145.5â€

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  OSÂ Â Â Â Â Â Â Â Â  = Â Â Â Â Â Â Â Â Â Â  âˆš ( Edf2 â€“ Ed2 )

OSÂ Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  âˆš (145.52 â€“ 1422)Â  =Â  31.7â€

XeÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  Xs + OS

XeÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  30.6â€ + 31.7â€ = 68.3â€

Object SizeÂ Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â Â  31.7â€Â  This is probably too large to be the actual width

Far Edge XÂ Â Â Â Â Â Â Â Â Â  =Â Â Â Â Â Â Â Â Â Â Â  68.3â€ this is beyond the sonar’s X range.

Appendix A â€“ Equation Derivation for Objects Inside Receiversâ€™ Perpendicular, Figure 2

A = sqrt ( Y2 + ( X1 – X2)2 )

A2 = Y2 + ( X1 – X2 )2

Y = sqrt ( A2 â€“ ( X1 – X2)2

C2 = X22 + Y2

Y2 = -X22 + C2

Y = sqrt (-X22 + C2)

sqrt (-X22 + C2) = sqrt ( A2 â€“ ( X1 – X2)2 )

C2 â€“ X22 =Â  A2 â€“ ( X1 – X2)2

C2 â€“ X22 =Â  A2-(X12 -2X1X2+X22)

C2 â€“ X22 =Â  A2-X12+2X1X2-X22

C2 Â =Â  A2-X12+2X1X2

2X1X2 Â =Â  C2 – A2 Â + X12

X2 Â =Â  (C2 – A2 + X12)/ 2X1

X = X2 – X1 / 2

Â Â

Appendix B â€“ Equation Derivation for Objects Outside Receiversâ€™ Perpendicular, Figure 3

A = sqrt ( Y2 + ( X1 + X2)2 )

A2 = Y2 + ( X1 + X2 )2

Y = sqrt ( A2 â€“ ( X1 + X2)2

C2 = X22 + Y2

Y2 = -X22 + C2

Y = sqrt (-X22 + C2)

sqrt (-X22 + C2) = sqrt ( A2 â€“ ( X1 + X2)2 )

C2 â€“ X22 =Â  A2 â€“ ( X1 + X2)2

C2 â€“ X22 =Â  A2-(X12+2X1X2+X22)

C2 â€“ X22 =Â  A2-X12-2X1X2-X22

C2 Â =Â  A2-X12-2X1X2

2X1X2 Â =Â  A2 – C2 Â – X12

X2 Â =Â  (A2C2 â€“ X12)/ 2X1

X = X2 + X1 / 2