Traditional Culture Encyclopedia - The 24 Solar Terms - How to calculate the number of days in heavenly stems and earthly branches with known dates?

How to calculate the number of days in heavenly stems and earthly branches with known dates?

It is simple to calculate the chronology of trunks and branches from known years: the number of years is reduced by 3, the remainder is divided by 10, and the remainder is divided by 12.

Branches.

The formula for calculating the branch date from the known date is very similar to the formula of the lottery, as shown below:

g = 4C+[C/4]+5y+[y/4]+[3 *(M+ 1)/5]+d-3

Z = 8c+[c/4]+5y+[y/4]+[3 * (m+1)/5)+d+7+I (i=0 in odd months and i=6 in even months).

Where c is the number of centuries minus one, y is the last two digits of the year, m is the month and d is the number of days. 1 and February according to the previous year's 13 and.

65438+ April. The remainder of g divided by 10 is heavenly stems, and the remainder of z divided by 10 is earthly branches.

Using several formulas related to stem and branch skillfully, the stem in ancient books can be calculated without a perpetual calendar.

Branch date corresponding to Gregorian calendar date.

-

Ganzhi Jiri has been used since the Xia Dynasty. According to the solar eclipse recorded in China's ancient historical classics "Spring and Autumn Annals"

According to textual research, the date of China's official branch was from February 3rd, Lu Yingong (BC 10 February) to.

Today, it has never stopped. The chronology of cadres and branches appeared later, and it was not officially announced until the second year of Jian 'an in the Eastern Han Dynasty (AD 85).

It has been ordered to be implemented throughout the country and has not been interrupted so far. Therefore, anyone who needs to be exposed to the history of China will inevitably encounter censorship.

The main branch of a certain year or day, and the problem of calculating which year or day from the annual main branch and the daily main branch. through

Usually, this transformation can be solved by looking up the almanac. But because the main branch is also a circulatory system, there are years and years naturally.

The formula for finding the expenditure by date.

Before introducing the formulas of seeking annual dry branches and daily dry branches, first introduce the characteristics of dry branches. The branch is heavenly stems and earthly branches.

Combination. There are ten heavenly stems, namely, A, B, C, D, E, Ji, G, Xin, Ren and Gui; There are twelve earthly branches, namely

Zi, Ugly, Yin, Mao, Chen, Si, Wu, Wei, Shen, You, Xu, Hai. Heavenly stems and earthly branches starts with "Jiazi" and follows the order.

Sequences are matched one by one. When used in the last one, they continue to match from the first one to form sixty branches, also called branches.

Sixty flowers. Why are there sixty branches? This is easy to answer mathematically. According to the composition of the trunk and branches

Part, its period must be the least common multiple of the number of heavenly stems and terrestrial stems. And 60 is the least common multiple of 10 and 12.

If we number "Jiazi" as 1 and "Ugly B" as 2, we can get a stalk if we continue like this.

And serial number, as follows:

1 .jiazi 2. Ugly B 3 Bing Yin 4. Ding Mao 5. Chen Wu 6. Keith 7. Wu Geng 8. Xin Wei

9. Ren Shen 10. Gui You 1 1. JOE 12. Yihai 13. Bing Zi 14. Ding Chou 15. Wuyin 16. Ji.

17. Chen Geng 18. Xinsi 19. Renwu 20. Guiwei 2 1. Shen Jia 22. Yiyou 23. Xu Bing 24. Ding hai.

25. Wu Zi 26. Ugly 27. Geng Yin 28. Xinmao 29. Yan Chen 30. Your company 3 1. Wu Jia 32. the Kingdom of Wei(220-265 A.D)

33. bing Shen 34. Dingyou 35. The reform movement of 1898. Jihai 37. Gengzi 38. Xin Chou 39. Ren Yin 40. Guimao

4 1 .Chen Jia 42. Yisi 43. Bingwu 44. Ding Wei 45. Wu Shen 46. Ji You 47. Geng Xu 48. Xinhai

49. Xunzi 50. Guichou 5 1. Good news 52. Mao yi 53. Chen Bing 54. Ding si 55 Five, five, six Not anymore.

57. Geng Shen 58. Heart has 59. Ren Xu 60. Guihai

Looking closely at this table, it is not difficult to find that it is easy to get the corresponding branch from the serial number, and the remainder of the serial number divided by 10.

Is the ordinal number of the stem (if the remainder is 0, it is the last stem), and the remainder of the serial number divided by 12 is the order of the branches.

Number (the last branch if the remainder is 0). For example, Route 37, because 37 mod 10=7(mod means

Take the remainder), the corresponding trunk is Geng, 37 mod 12= 1, and the corresponding branch is Zi, so the trunk No.37 is Geng.

Obviously, the remainder of an integer divided by 10 is its single digit, which makes it easier to find the sky.

It is not difficult to infer its serial number from the main branch. This is actually a problem of solving congruence equations. We use initials.

The remainder theorem in China's equality theory can be solved. For example, to calculate the serial number of the five-five plan, you can get it from the serial number according to the above.

According to the principle of trunk and branch, it is easy to get the following equation:

{ x mod 10 = 5

{ x mod 12 = 7。

Where x is the sequence number of the branch to find. According to China's remainder theorem, there are:

x ≡ 6 * 5 - 5 * 7 (mod 60) = 55,

That is, the serial number of the fifth five-year plan is 55. This is consistent with the comparison table above. Generally speaking, if the number of the heavenly stems is M, the earthly branches

If the sequence number is n, the sequence number of the main branch is:

x ≡ 6m - 5n (mod 60) ( 1)

Simply put, if the result of 6m-5n is positive, this number is the serial number of the main branch; If it is negative, add 60.

Is the sequence number of the main branch.

Understand the mutual calculation of main branches and their serial numbers. First, introduce the calculation of annual main branches. It should be noted that,

The calendar year of the main branch is the lunar year, not the Gregorian year. However, because the beginning of the lunar year is closer to the beginning of the Gregorian year,

So that the lunar year always coincides with most of the time in a Gregorian calendar year, so it is usually represented by the Gregorian calendar year and most of its time.

Coincident lunar year. In this way, it is easy for us to give the serial numbers of the main branches in the lunar year as follows:

x = (Y-3) mod 60,(2)

Where y is the year. Get the serial number X of the trunk and you can find the corresponding trunk. For example, the number of main branches in 2004:

x =(2004-3)mod 60 = 200 1 mod 60 = 2 1,

2 1 mod 10= 1, the aerial stem is a, 2 1 mod 12=9, and the underground branch is Shen, so 2004 is Shen Nian.

After careful observation, it can be found that in fact, if you directly divide Y-3 by 10, you can get Tiangan, and divide it directly by Y-3.

12, you can get the ground branch. this is because

x = (Y-3) mod 60

be equal to

Y-3 = 60 * n + x,

Where n is the quotient of Y-3 divided by 60. When both sides of the equation are divided by 10 at the same time, the remainder must be equal. The first item on the right is 60.

Multiplication, also a multiple of 10, can be an integer of 10, so the remainder of Y-3 divided by 10 must be equal to the remainder of x divided by 10.

Count.

Therefore, in fact, you don't need to find the serial number of the stem first, you can find the heavenly stem and the earthly branch separately, and together they are dry.

Branch, thus reducing one step operation. For Nianzao, just look at the last one. Year ending in 4

Our heavenly stems are always A, and the heavenly stems of years ending in 5 are always B … and so on.

Let's look at the calculation of daily cadres. We can imitate the calculation of a week and get a more intuitive calculation of daily expenses.

The formula is as follows:

g =(Y- 1)* 5+[(Y- 1)/4]-[(Y- 1)/ 100]+[(Y- 1)/400]+D+ 15,(3)

Where y is the year, d is the cumulative number of days, and [...] represents the quotient, that is, only the integer part of the calculation result is taken. Divide g

With 60, the remainder is the serial number of the main branch. Or divide g by 10 or 12, and you can directly get the sun-sky stem and the sun-earth branch. no

However, like the similar formula for finding Zhou Gong, this formula is not concise enough, especially the first term (Y- 1)*5, in

When y is a four-digit year, the calculation result is a large four-digit or five-digit number, which is not convenient for oral calculation.

We can improve this formula by deducing Culler formula. Let's first look at the improvement related to the year.

We know that according to the leap rule of the Gregorian calendar, the total number of days in a century may be 36,524 days, which is 36,525 days. If this

The year with 00 at the end of the century is a leap year, and this century has only 36,525 days; Otherwise, it will only be 36,524 days. We might as well.

A century with 36,524 days is called a "flat century" and a century with 36,525 days is called a "leap century". Ping century, because

36524 mod 60 = 44,

So every century, the main branch of the same day will push back 44 serial numbers. Similarly, every leap century, the same

One day, the main branch was pushed back by 45 serial numbers. This makes it easy for us to get the calculation of the first year (year) of each century.

Formula ending in 0 1) March 1:

G = 44C + [C/4] + 15,(4)

Where c is the number of centuries minus one.

And the formula for calculating the trunk and branches on March 1 day of any year can also be obtained quickly:

g = 44C+[C/4]+5(y- 1)+[y/4]+ 15,

that is

G = 44C + [C/4] + 5y + [y/4] + 10,(5)

Where y is the last two digits of the year.

Let's list the days of each month:

Month 1, February, March, May, June, July, August, September 10,1,12.

-

Days 3128 (29) 3130313031313031.

Subtract 30

The remaining days are1-2 (-1)1010/.

If we regard October and February of 65438 as March and April of 65438 of the previous year, we can also get the following formula:

d '≦[3 *(M+ 1)/5]+d-2(mod 10)(6)

and

D' ≡ 3 * (m+1)/5)+d-2+I (mod12) (odd months i=0, even months i=6), (7)

Where d' is the cumulative number of days from March 1, m is the month and d is the number of days. Merge (6), (7) and (5)

Get up, and then make appropriate simplification to get the heavenly stems and earthly branches calculation formula for any day in the Gregorian calendar:

g = 4C+[C/4]+5y+[y/4]+[3 *(M+ 1)/5]+d-3; (8)

Z = 8c+[c/4]+5y+[y/4]+[3 * (m+1)/5)+d+7+I (i=0 in odd months and i=6 in even months).

(9)

If g is obtained first, then

Z = g+4C+ 10+i (i=0 for odd months and I = 6 for even months). ( 10)

The single digit of G is the Tiangan serial number, and the remainder of Z divided by 12 is the Earthbranch serial number. It needs to be emphasized again here: 1 and February are.

Calculated as 65438+March and 65438+April of the previous year, so c and y should also be taken according to the year of the previous year.

We can compare (8) and (9) with Chuller's formula:

w =-2C+[C/4]+y+[y/4]+[ 13 *(M+ 1)/5]+d- 1,

It can be seen that their forms are very similar, and the difference is only a few constants.

Although it is no longer necessary to record the daily expenditure in China, it is sometimes necessary to calculate the daily expenditure. For example, calendars are somewhat different.

It is said that "three volts", "entering the plum blossom" and "leaving the plum blossom" are all related to Japanese dry branches. Three volts, including the initial, middle and final volts, refers to summer.

In the hottest time of the day, plum blossom entering plum blossom and plum blossom leaving plum blossom refer to the beginning and end of the rainy season in the south of the Yangtze River, which was originally related to the climate.

Language. However, because there was no accurate weather forecast in ancient times, it was impossible to accurately predict the three days and the time of entering and leaving Mei, so

In the almanac, it is hard to specify a few days as the date when the dog days begin and when plum blossoms come and go, so as to determine an approximate date for reference.

Testing. Although there is a more accurate weather forecast now, as a traditional calendar, Sanfu and Meiru have been handed down.

Let's go

According to the calendar, the third Geng Day after long summer is the beginning of the first autumn, * * * ten days; The fourth Geng Day starts from Zhongfu and lasts for ten days.

Or twenty days; After beginning of autumn, the first Geng Day started with the last beginning of autumn and lasted for ten days. The reason why the length of the upper abdomen is not fixed is

The dates of summer solstice, beginning of autumn and Geng Day fluctuate year by year, and the first Geng Day after beginning of autumn may be after summer solstice.

The fifth Geng day may also be the sixth Geng day. If it is the former, it will take more than ten days in the middle; If it is the latter, it is medium.

Up to 20 days. Please note that if the day of summer solstice is Geng Day, the first Geng Day after summer refers to the tenth day after summer, and

This is not the day of summer solstice, but the first day of the first autumn is the thirtieth day from summer to the future. Similarly, if that day in beginning of autumn is Geng Day, it will be over.

The first day of Fu was the tenth day after beginning of autumn, not the day in beginning of autumn. Entering plum means after mango comes out on the first day.

Mei refers to the first weekend after the slight summer heat, and there are the same rules.

Knowing this, we can calculate the beginning, middle and end of 2004. This requires a prophet.

Summer solstice and early autumn. If we know that the summer solstice is June 2 1 and beginning of autumn is August 7, then use formula (8), summer solstice.

G this day is:

g = 4 * 20+[20/4]+5 * 4+[4/4]+[3 *(6+ 1)/5]+2 1-3

= 80 + 5 + 20 + 1 + 4 + 2 1 - 3

= 128,

Single digit 8, the sky is dry and the things are dry. Xia Hou's third Geng Day is the 29th day of Xia Hou, that is, July 20th.

That is, the first day of the first night. The first day of Zhongfu is July 30th. You can also count the beginning of Qiuke as this day:

g = 4 * 20+[20/4]+5 * 4+[4/4]+[3 *(8+ 1)/5]+7-3

= 80 + 5 + 20 + 1 + 5 + 7 - 3

= 1 15,

Today is May Day. The first Geng Day after beginning of autumn is the day after beginning of autumn, that is, August 9th, which is the last day.

Jesus Christ. It can be seen that the mid-autumn in 2004 was only ten days. It can also be calculated from the dates of the two solar terms, namely, mango and Xiaoshu.

Plum Blossom Day and Plum Blossom Day in 2004 were June 6th and July 15 respectively.

On the other hand, knowing the year branch and the day branch, it is relatively troublesome to find the corresponding year and day. Because of dryness

Branches are recycled, so you must first know which cycle the main branch corresponding to the year and date belongs to. take for example

We use formula (2) to calculate in advance that 1864, 1924 and 1984 are all Jiazi years. If we want to know where the reform movement in 1898 is,

A year, first of all, must be determined to be the end of 19, that is, it belongs to the cycle starting from 1864. that

Yao, we can use the formula (1) to calculate that the serial number of the year of 1898 is 35, so the year of 1898 is (1864-1)+35 =1898.

The reason why we need to subtract one first is because the serial number of Jiazi is 1, so we need to subtract this serial number first.

As for the Japanese dry branch, because the Japanese dry branch in ancient books is always used with the year and month, it is not difficult to determine that it belongs to.

Which cycle? As recorded in the Biography of Emperor Ming Taizu Zhuang Lie, the day when Zhu Youjian hanged himself in Jingshan Park was Chongzhen.

Sixteen years in March, Ding Wei. In the sixteenth year of Chongzhen, AD 1644. Although March is the third month of the lunar calendar, we know agriculture.

Although the dates in the Gregorian calendar are floating, they are not within a certain range. For example, the first day of the third lunar month is always there.

The Gregorian calendar floats from March 22nd to April 19. So, let's first calculate the main branches of March 22nd 1644. We have:

g = 4 * 16+[ 16/4]+5 * 44+[44/4]+[3 *(3+ 1)/5]+22-3

= 64 + 4 + 220 + 1 1 + 2 + 22 - 3

= 320,

The unit number is 0,

z = g + 4C + 10

= 320 + 64 + 10

= 394,

Divided by 12, it is 10, so the main branch of this day is Gui You, and its serial number is 6*0-5* 10+60= 10. Ding Wei's serial number is

6*4-5*8+60=44, which is 34 days after the default, so March must be 34 days after March 22, which is April 25.

Day. That is to say, the date when Chongzhen hanged himself was1April 25, 644, which was consistent with the result of calendar search.