The five friends formula is based on the facing, incoming water and incoming dragon (incoming mountain). This formula begets wealth and many oppurtunities for the person who can apply it correctly. Here I will be discussing how this formula follows a logical pattern based on the yin/yang transformation of the taiji and applying early heaven numbers. The other names for this formula is five ghost, five ghost carry treasure and five ghost carry money.
Application of this formula will not be discussed as it is too complicated and only authentic feng shui masters/practitioners/teachers around the world would know the formula and its application. In feng shui, besides the formula, even the application needs to be correct otherwise there would be no results. Feng shui is after all a result oriented science.
The birth of the triagrams

Explantion of the image - From Tai Ji - Yin (Earth) and yang (Heaven) took birth. Yin and Yang further divided to Greater Yin, Lesser Yang, Lesser Yin and Greater Yang. From these four further divisions took place and the eight triagrams were born. From greater yang we have Qian and Dui, from greater yin comes Kun and Gen, from lesser yang comes Kan and Xun, from lesser yin comes Li and Zhen.
The sequence of numbers in the early heaven differ from the sequence of numbers in the later heaven, and it should also not be confused with the lo shu numbers.
The numbers are as follows :-
Greater Yang
Qian - 1
Dui - 2
Lesser Yin
Li - 3
Zhen - 4
Lesser Yang
Xun - 5
Kan - 6
Greater Yin
Gen - 7
Kun - 8
I use the term brother or friend for the ones belonging to or having taken birth from the same parent. For eg. Qian and Dui are friends as they are both born of greater yang. Hence Qian and Dui share the same root.
The Formula:

There are five conclusive patterns, out of that, three of them are numerological.
Facing and incoming water share the same qi. Example if facing is from greater qi than incoming water will also be from the greater qi. Facing and dragon have opposite qi's. This pattern is consistent in all cases.
In case of polarity (yin/yang) facing and incoming dragon share the same polarity. If facing is yang than incoming dragon will also be yang. However facing and incoming water belong to different polarities. If facing is yang then incoming water will be yin. This pattern is there in all the cases.
Taking an example
Facing - Qian - Greater Yang
Incoming water - Kun - Greater Yin
Incoming dragon - Xun - Lesser Yang
Now looking at the numerological aspect of it. When the early heaven numbers are applied, the facing and incoming water always adds up to form 9.
Taking an example
Facing - Qian - Greater Yang - 1
Incoming water - Kun - Greater Yin - 8
Facing (1) + Incoming water (8) = 9
When applying the early heaven numbers to the incoming dragon and incoming water the findings are such:
- Facing that belong to the yang qi (greater yang and lesser yin) the incoming water and incoming dragon add up to form number 13. Reducing to a one digit number (1 + 3) we get 4.
- Facing that belong to the yin qi (lesser yang and greater yin) the incoming dragon and incoming water add up to form number 5.
In this formula the case is slightly different.

The third numerological pattern is When we add up the early heaven numbers of the facing, incoming water and the incoming dragon then the single digit numbers will form 1,2,3,4,5,6,7,8 respectively. Looking at the diagram above if we take from facing Xun, kan, gen, kun, qian, dui, li, zhen then the single digit numbers will form 1,2,3,4,5,6,7,8 respectively. These single digit numbers are again similar to the early heaven number of the incoming dragon.
Taking an example
Facing Qian (1) + Incoming water Kun (8) + Incoming dragon Xun (5) = 14
Reducing to a single digit - 1 + 4 = 5
The early heaven number of Xun (incoming dragon) is also equal to 5.
This is yet another formula in feng shui, that can be deduced mathematically and follows a logical pattern. In my course of studies I have found that feng shui and ba zi both have a logical pattern in their respective formulas.