First of all, let's talk about this algorithm in modern terms. It mainly deals with how to calculate the calendar, specifically, the ancient lunar calendar. It adjusts the trajectory of the moon's movement using various ratios and coefficients, ultimately calculating the length of each month and the date of the new moon (the first day of the lunar month). This algorithm may seem complex, but its logic is based on the regular movement of the moon, continuously correcting and adjusting to strive for accuracy.

Next, let's translate it sentence by sentence:

1. Calculate the change rate by using the diminishing rate, then adjust the waxing and waning of the moon using this rate. If the loss is insufficient, reverse the process and continue calculating according to the previous rules.

2. Multiply the degrees of the moon's movement per month by the most recent nightly timekeeping unit, then divide by 200 to get the bright minutes. Subtract the bright minutes from the monthly degrees of the moon's movement to calculate the dark minutes. Convert the minutes to degrees, multiply the total degrees by the minutes, add it to the fixed degrees of the night, and get the dark and bright fixed degrees. If the remaining minutes exceed half, round up; if not enough, discard.

3. There are four methods for calculating the moon's movement, and there are three ways of calculating the waxing and waning of the moon, which interact to influence the calculation of days. By dividing the moon's movement ratio by these influences, the number of days in the calendar can be calculated. Multiply the total degrees in a circle (360 degrees) by the number of days in a lunar month, then divide by the synodic month (the number of days in a synodic month) to get the synodic minutes. Multiply the total degrees by the synodic number, calculate the remaining minutes based on the number of days in the synodic month, and get the retrograde minutes. Use this method to calculate the degrees of progress per month, obtaining a difference rate each time there is a synodic month.

4. The following section provides specific numerical calculation examples, illustrating the application of the gain and loss rates in the lunar calendar calculations. Phrases like "one day decrease by seventeen at the beginning," "second day (limited to remaining one thousand two hundred and ninety, minute difference four hundred and fifty-seven.) This is the previous limit," and so on, are specific calculation steps and results that are challenging to express concisely in modern language, thus requiring retention of the original text. These numbers represent the daily adjustment values, critical values, and intermediate results.

5. "Thirteenth day (limited to three thousand nine hundred twelve, with a micro-division of one thousand seven hundred fifty-two.) This is the limit." After that, specific calculation steps and some key parameters were listed, such as "lesser method, four hundred seventy-three," "historical cycle, one hundred seventy-five thousand six hundred sixty-five," "difference rate, ten thousand nine hundred eighty-six," "conjunction fraction, eighteen thousand three hundred twenty-eight," "micro-division, nine hundred fourteen," "micro-division method, two thousand two hundred nine." These are all constants and intermediate results used in the algorithm.

6. Finally, subtract the days of the meeting month from the upper element accumulated month (referring to the cumulative month number of a certain starting date), and then multiply the conjunction fraction and micro-division by the result respectively. If the micro-division is enough to carry over, carry over from the conjunction fraction, and if the conjunction fraction is enough for the week days, subtract the week days. The remaining days that do not complete the historical week correspond to the solar calendar; if they are complete, subtract them, and the remaining is the lunar calendar. The remaining part is calculated based on the number of days in each month to obtain the final date. It should be noted that there may be a residue in this calculation process, and this residue value represents the potential calculation error.

In conclusion, this passage describes a quite complex ancient calendar calculation method, which is difficult to explain in modern language, and many professional terms are also difficult to fully express their precise meanings in common language. The large number of numbers and calculation steps in the original text reflect the exquisite calculation skills of ancient astronomers and their profound understanding of the laws of celestial motion.

Adding two days, the remaining days are two thousand five hundred eighty, and the micro-division is nine hundred fourteen. Calculate the number of days according to the method, subtract if it reaches thirteen, and the remaining is the remaining days and micro-division. The lunar and solar calendars are interrelated in this manner, with the limits and remainders for entry in the front, and the limits and remainders for the back, with the month in between.

Next, respectively make the adjustments for the late and early calendars, multiply the number of meetings by the small fraction to get the micro-division, add the increase and subtract the decrease to the lunar and solar remaining days, and adjust the number of days if there is a surplus or shortage in the remaining days. Multiply the determined remaining days by the profit and loss rate; if the monthly and weekly calculations yield one, use the total profit and loss as the additional fixed number.

Multiply the differential rate by the remainder of the new moon, obtain a value of one using differentiation methods, and subtract it from the remainder of the day in the calendar. If it's insufficient, add a month and a week, then subtract one day. Add the obtained remainder of the day to its minutes, simplify the differentiation with the total count to obtain the minutes, thus obtaining the entry calendar time of the new moon night.

To find the second day, add one day; the remainder of the day is thirty-one, and the minutes are also thirty-one. If the minutes added to the total have a remainder, subtract the full month and week from it. Add another day, and the calendar is completed. Subtract the remainder when the day and minutes are full, marking the start of the calendar. If the minutes are not full, keep them, add the remainder of two thousand seven hundred and twenty, and thirty-one minutes, which is the next calendar entry.

Multiply the total count by the surplus and remainder of the night of the late and rapid calendar; subtract the full half week from the remainder as the minutes. Add the surplus number and subtract the deficit number, adjusting the yin and yang balance of the day's remainder. If the day remainder is in excess or insufficient, use the month and week to adjust the number of days. Multiply the determined day remainder by the profit and loss rate; if the month and week result in one, use the total profit and loss as the fixed number of the night.

Multiply the profit and loss rate by the number of missing moments in the night of the nearest solar term; two hundredth is bright, subtract the profit and loss rate from it to get dark, then use the profit and loss night number as the fixed number of dark and light.

List out the fixed number of additional hours and dark and light, divide by twelve to get the degrees; one-third of the remainder is weak, less than one is strong, and two weak are weak. The result is the degree of deviation from the ecliptic. For the solar calendar, subtract the ecliptic degree from the solar calendar day; for the lunar calendar, use subtraction to obtain the degree of deviation from the ecliptic. Positive for strong, negative for weak, add or subtract strong and weak, add for the same, subtract for different. When subtracting, like terms cancel each other out, while unlike terms are added; without counterparts, add two strong and subtract one weak.

From the year Ji-Chou of the Shangyuan period to the year Bing-Xu of the Jian'an period, a total of seven thousand three hundred and seventy-eight years have been accumulated. Ji-Chou, Wu-Yin, Ding-Mao, Bing-Chen, Yi-Si, Jia-Wu, Gui-Wei, Ren-Shen, Xin-You, Geng-Xu, Ji-Hai, Wu-Zi, Ding-Chou, Bing-Yin.

This passage outlines methods of ancient astronomical calculations, specifically the prediction of the movement trajectory of the five stars. Let's break it down sentence by sentence and explain it in contemporary terms.

First, it defines five planets: Jupiter (the Planet of the Year), Mars (the Red Planet), Saturn (the Ringed Planet), Venus (the Bright Star), and Mercury (the Herald Star). Then it explains some basic parameters for calculating their orbital trajectories, such as the daily rotation rate and the annual rotation rate (the angles they move each day and each year). How is the movement of the moon calculated? Multiply the angle of rotation per year by the number of weeks to obtain the moon's movement pattern (the lunar calculation method), then multiply the lunar movement pattern by the number of days to obtain more accurate lunar movement information (the lunar phase), and finally integrate this information to calculate the specific movement conditions for each month (the lunar number). In short, it calculates the orbital trajectories of planets through a series of multiplication and division operations. The last sentence states to multiply the Dipper fraction (斗分) by the daily rotation rate to obtain the Dipper fraction (what this Dipper fraction specifically refers to needs to be understood in conjunction with the knowledge of astrology at that time).

Next, it begins to calculate the gains and losses of the five stars. What are the major remainder and minor remainder? It is to obtain a major remainder and a minor remainder through a series of calculations (multiply the common method by the number of months, and then divide by the day method). If the major remainder exceeds sixty, subtract sixty. This part of the calculation is more complex, involving the use of many astronomical parameters, with the aim of predicting the positions of the planets more accurately.

Then it calculates the number of days and remainders that the five stars move each month (the day of entering the month, the remaining days). This part of the calculation is also quite complex, requiring the use of various parameters calculated earlier, as well as some other astronomical constants (the method of conjunction, the minor remainder of the new moon), to ultimately obtain the number of days the planets move each month and the remaining degrees.

Next is to calculate the degrees and remainders of the five stars (the degree, the degree remainder). This part of the calculation involves converting excess degrees into weeks of the lunar cycle, then reducing them to obtain the final degrees and remainders. If it exceeds a week, subtract the number of weeks, and also consider the Dipper fraction.

After that, it lists a series of constants that are necessary for the above calculations. For example, the calendar month (how many days in a year), the intercalary month (number of intercalary months), the calendar month (how many months in a year), the mid-year (how many months in a year), the common method, the day method, the number of conjunctions, the number of weeks, the Dipper fraction, and so on. These numbers are the results derived by ancient astronomers through long-term observation and calculation.

Finally, the text lists the specific parameters of Jupiter and Mars separately, including the synodic period, solar period, lunar conjunction, lunar remainder, lunar conjunction method, solar method, new moon remainder, small new moon remainder, entry day of the month, day remainder, new moon virtual division, constellation division, degrees, and degree remainder. These data are all calculated based on the above formulas and are used to predict the orbits of Jupiter and Mars. These data are quite complex and require a deep understanding of ancient astronomical calculation methods to comprehend their meanings.

In summary, this passage describes an ancient astronomical calculation system used to predict the positions of the five planets. The calculation process is complex and requires a mastery of numerous constants and formulas. This system reflects the in-depth research and understanding of the laws of celestial motion by ancient Chinese astronomers.

According to the traditional Chinese calendar: Saturn completes 3,529 orbits in a year. The Sun completes 3,653 orbits in a year. When combined, this results in approximately 12 months in a year. There are 53,843 orbits remaining. Calculated by a month, there are a total of 6,751 orbits. Calculated by a day, it is 278,581 orbits. The new moon's large remainder is 54, and the small remainder is 534. Each month has 24 days, and the remaining uncompleted orbits are 166,272. The virtual division is 923, and the constellation division is 511,750. The degree is 12, and the remaining degrees are 1,733,148.

Venus completes 9,022 orbits in a year. The Sun completes 7,213 orbits in a year. When combined, this results in approximately 9 months in a year. There are 152,293 orbits remaining. Calculated by a month, there are a total of 171,418 orbits. Calculated by a day, it is 5,313,958 orbits. The new moon's large remainder is 25, and the small remainder is 1,129. Each month has 27 days, and the remaining uncompleted orbits are 56,954. The virtual division is 328, and the constellation division is 1,308,190. The degree is 292, and the remaining degrees are 56,954.

Mercury completes 11,561 orbits in a year. The Sun completes 1,834 orbits in a year. When combined, this results in approximately 1 month in a year. There are 211,331 orbits remaining. Calculated by a month, there are a total of 219,659 orbits. Calculated by a day, it is 6,809,429 orbits. The new moon's large remainder is 29, and the small remainder is 773. Each month has 28 days, and the remaining uncompleted orbits are 6,419,967. The virtual division is 684, and the constellation division is 1,676,345. The degree is 57, and the remaining degrees are 6,419,967.

Finally, take the year you want to calculate, multiply it by the constant π, and see how many daily cycles you can get; this is called accumulation. The part that is not enough for a daily cycle is called the remainder. Then divide π by the remainder; if you get an integer, that is the past years of conjunctions; if you get two integers, that is the previous years of conjunctions; if you get nothing, that is the conjunction of that year. Subtract the remainder from π, and what remains is the degrees and minutes. The conjunction of Venus and Mercury, odd numbers are in the morning, even numbers are in the evening.

First, let's calculate the moon's situation. Multiply the number of days in each month by the remaining days, and add them together. If it can be evenly divided by the standard number of days in a month, count it as a full month; if not enough for a month, record it as remaining days. Then subtract the accumulated months from the total recorded days; what remains is the month transitioning into the next lunar month. Next, consider the impact of the leap month; if it meets the conditions for a leap month, subtract the number of days in a leap month, then subtract the remaining days from the year, and what remains is the number of remaining months not accounted for in the solar calendar. If it's during the transition of the leap month, adjust using the new moon day.

Next, use the conventional method to multiply by the remaining number of months, and then multiply the standard value of the months by the remaining days of the new moon, add these two results together, and then simplify using the conjunction cycle. If the result can be evenly divided by the daily degree standard, then you have the day of the celestial body conjunction with the moon; if not enough to be divisible, the remainder is the remaining days, recorded outside the solar calendar calculations.

Then, multiply the number of weeks by the degrees and minutes; if it can be evenly divided by the daily degree standard, you get one degree; if not enough to be divisible, the remainder is the remaining degrees, starting from the five stars of the Ox constellation. The above outlines the calculation method for the conjunction of celestial bodies with the moon.

Next, calculate the years. Add up the number of months and the remaining days; if the total can be evenly divided by the standard number of days in a month, count it as one year; if not enough for a year, record it within that year; if it exceeds one year, subtract one year, and if there is a leap month, it must also be considered; the remaining days are recorded for the next year; if it exceeds one year again, record it for the following two years. For Venus and Mercury, if they appear in the morning, adding one day will shift it to appearing in the evening; if they appear in the evening, adding one day will shift it to appearing in the morning.

Add the remaining days of the new moon and synodic months. If it exceeds the standard number of days in a lunar month, add either a large remainder of 29 days or a small remainder of 773 minutes. If the small remainder exceeds the standard value of the daily degree, subtract it from the large remainder, using the same method as before.

Add the days of the month to the remaining days. If the remaining days can be divided by the standard value of the daily degree, it results in one day. If the remaining days from the previous synodic period exactly fill the virtual minutes, subtract one day. If the remaining days exceed 773, subtract 29 days. If it is less than 29 days, subtract 30 days instead. The remaining days indicate the date of the next new moon.

Finally, add the degrees and the remaining degrees. If it can be divided by the standard value of the daily degree, one degree is obtained.

Here are the specific data for Jupiter, Mars, Saturn, and Venus:

Jupiter: Not visible for 32 days, 3,484,646 minutes; visible for 366 days; invisible motion of 5 degrees, 2,509,956 minutes; visible motion of 40 degrees (subtracting retrograde motion of 12 degrees, actual motion of 28 degrees).

Mars: Not visible for 143 days, 973,113 minutes; visible for 636 days; invisible motion of 110 degrees, 478,998 minutes; visible motion of 320 degrees (subtracting retrograde motion of 17 degrees, actual motion of 303 degrees).

Saturn: Not visible for 33 days, 166,272 minutes; visible for 345 days; invisible motion of 3 degrees, 1,733,148 minutes; visible motion of 15 degrees (subtracting retrograde motion of 6 degrees, actual motion of 9 degrees).

Venus: Not visible in the morning in the east for 82 days, 113,908 minutes; visible in the west for 246 days (subtracting retrograde motion of 6 degrees, actual motion of 240 degrees); invisible motion in the morning covering 100 degrees, 113,908 minutes; visible in the east (same daily degree as in the west, invisible for 10 days, retrograde motion of 8 degrees).

As for Mercury, it appeared in the morning for a total of 33 days, traversing a total of 612,255 minutes. Then, it appeared in the western sky for 32 days. (Subtracting one degree of retrograde motion, it actually traversed 32 degrees.) After that, it moved forward by 65 degrees, still totaling 612,255 minutes. Then it appeared in the east. It moved in the east at the same daily degree as in the west, not visible for a total of 18 days, and retrograded by 14 degrees.

Calculate the degrees Mercury travels each day and the remaining arc, then add the remaining arc after it conjuncts with the Sun. If the remaining arc reaches the degrees of one day, begin counting from a full cycle. This allows you to calculate when and how far Mercury appears. Multiply the denominator of Mercury's orbit by the degrees of its appearance above the horizon; if the remaining arc can be evenly divided by the daily degrees, this results in one. If not, and it exceeds half, it is also counted as one. Then add the obtained number to the degrees it travels each day; if the total degrees reach the denominator, add one degree. The denominators for retrograde and direct motion are different; multiply the current operating denominator by the remaining arc. If the result equals the original denominator, you have obtained the degrees of its current operation. The remaining arc inherits from the previous ones, and for retrograde, subtract. If the degrees for the hidden phase are insufficient, use the Big Dipper to divide by the degrees, using the operating denominator as a ratio; the degrees will increase or decrease, mutually constraining each other. Anything referring to "full," "approximately," or "complete" is seeking precise division; "remove" and "divide" refer to exhaustive division.

As for Jupiter, in the morning, it is aligned with the Sun, then becomes obscured, continuing in direct motion for 16 days, traveling a total of 1,742,323 minutes, with the planet moving 2 degrees and 3,467 minutes. Then it appears in the east behind the Sun. In direct motion, it moves quickly, traveling at a rate of 11/58 of a degree each day, covering 11 degrees in 58 days. It continues in direct motion but slows down, traveling 9 minutes each day, covering 9 degrees in 58 days. Then it stops for 25 days, and then it starts to turn. In retrograde, it moves at a rate of 1/7 of a degree daily, retreating 12 degrees in 84 days. After stopping again for 25 days, it resumes direct motion, traveling at a rate of 9/58 of a degree each day, covering 9 degrees in 58 days. In direct motion, it moves quickly, traveling 11 minutes each day, covering 11 degrees in 58 days, and becomes hidden in the west in the evening. It lasts for 16 days, traveling a total of 1,742,323 minutes, with the planet having moved a total of 2 degrees and 3,467 minutes, then it conjuncts with the Sun again. A complete cycle totals 398 days, 3,484,646 minutes, with the planet having moved a total of 43 degrees and 2,509,956 minutes.

Sun: In the morning, it appears with the sun, then it disappears. After that, it proceeds forward for a total of 71 days, covering 1489868 minutes and traveling 55 degrees and 242860.5 minutes on the planet. Then in the morning, it can be seen in the east, behind the sun. While proceeding, it travels 14/23 of a minute each day, covering 112 degrees over 184 days. Then it slows down, traveling 12/23 of a minute each day, covering 48 degrees over 92 days. Then it comes to a halt for 11 days. Next, it moves in retrograde, traveling 17/62 of a minute each day, moving back 17 degrees over 62 days. Then it stops again, not moving for 11 days, and then it starts moving forward again, covering 48 degrees over 92 days at a pace of 12 minutes per day. Moving forward once more, it speeds up, traveling 14 minutes each day, covering 112 degrees over 184 days. At this point, it is in front of the sun, setting in the west at night. After 71 days, it has covered 1489868 minutes and traveled 55 degrees and 242860.5 minutes on the planet, and then it appears with the sun again. The entire cycle lasts 779 days and 973113 minutes, covering 414 degrees and 478998 minutes on the planet.

Saturn: In the morning, it appears with the sun, then it disappears. After that, it proceeds forward for a total of 16 days, covering 1122426.5 minutes and traveling 1 degree and 1995864.5 minutes on the planet. Then in the morning, it can be seen in the east, behind the sun. While proceeding, it travels 3/35 of a minute each day, covering 7.5 degrees over 87.5 days. Then it comes to a halt for 34 days. Next, it moves in retrograde, traveling 1/17 of a minute each day, moving back 6 degrees over 102 days. Then after 34 days, it starts moving forward again, covering 7.5 degrees over 87 days at a pace of 3 minutes per day. At this point, it is in front of the sun, setting in the west at night. After 16 days, it has covered 1122426.5 minutes and traveled 1 degree and 1995864.5 minutes on the planet, and then it appears with the sun again. The entire cycle lasts 378 days and 166272 minutes, covering 12 degrees and 1733148 minutes on the planet.

Venus, when it meets the sun in the morning, will first go retrograde. After five days, it retreats four degrees, and then it can be seen in the east behind the sun. Continuing retrograde, it retreats three-fifths of a degree per day, and after ten days, it has retreated six degrees. Then it will "stay," remaining stationary for eight days. Next, it will "rotate," which means it begins to go direct, moving slowly at a rate of three degrees and forty-six minutes per day, covering a total of thirty-three degrees in forty-six days, and then it starts to go direct. After that, the speed increases to one degree and ninety-one minutes per day, covering a total of one hundred and six degrees in ninety-one days. The speed continues to increase, moving at a rate of one degree plus ninety-one minutes and twenty-two seconds per day, covering a total of one hundred and thirteen degrees in ninety-one days, at this point, it is positioned behind the sun and can be seen in the east during the morning. Finally, it moves direct for forty-one days and fifty-six thousand nine hundred and fifty-four minutes, covering a total of fifty degrees and fifty-six thousand nine hundred and fifty-four minutes, and then it meets the sun again. One conjunction lasts a total of two hundred and ninety-two days and fifty-six thousand nine hundred and fifty-four minutes, with the same degree of planetary motion.

When Venus meets the sun in the evening, it will first go retrograde; this time, it goes direct for forty-one days and fifty-six thousand nine hundred and fifty-four minutes, covering a total of fifty degrees and fifty-nine thousand nine hundred and fifty-four minutes, and then it can be seen in the west, positioned in front of the sun. Then it continues to go direct, moving quickly at a rate of one degree plus ninety-one minutes and twenty-two seconds per day, covering a total of one hundred and thirteen degrees in ninety-one days. The speed then slightly decreases to one degree and fifteen minutes per day, covering a total of one hundred and six degrees in ninety-one days, continuing to go direct. The speed slows down, moving at a rate of three degrees and forty-six minutes per day, covering a total of thirty-three degrees in forty-six days. It will "stay," remaining stationary for eight days. Then it will "rotate," starting to go retrograde, retreating three-fifths of a degree per day, retreating six degrees after ten days, at which point it is in front of the sun and appears in the west in the evening. Going retrograde, it moves quickly, retreating four degrees after five days, and then it meets the sun again. Two conjunctions mark the end of one cycle, totaling five hundred and eighty-four days and fifty-six thousand nine hundred and eight minutes, with the same degree of planetary motion.

When Mercury meets the Sun in the morning, it first goes into retrograde, retreating seven degrees over nine days, and then it becomes visible in the east behind the Sun. It continues to retrograde rapidly, retreating one degree each day. It then pauses for two days. Next, it "revolves," starting to move direct again at a slower speed, traveling eight-ninths of a degree each day and traveling eight degrees in nine days, and begins to move direct. Its speed increases, moving one and a quarter degrees each day, covering twenty-five degrees in twenty days, at which point it is located behind the Sun and appears in the east at dawn. It then moves direct for sixteen days and 641,967 minutes, covering thirty-two degrees and 641,967 minutes, before meeting the Sun again. One conjunction takes a total of fifty-seven days and 641,967 minutes, with the planet covering the same distance.

The Sun sets and vanishes along with the stars. According to calculations, this planet travels thirty-two degrees and 641,967 minutes over the course of sixteen days. In the evening, it appears in the western sky, ahead of the Sun. Sometimes it moves very quickly, traveling one degree and a quarter in a day, covering twenty-five degrees in twenty days. Other times, it moves slowly, only moving seven-eighths of a degree each day, taking nine days to travel eight degrees. It may pause completely for two days. It may also go retrograde at times, retreating one degree in a day, at which point it appears in front of the Sun and sets in the west in the evening. During retrograde, it moves slowly, taking nine days to retreat seven degrees, and eventually meets the Sun again.

From one conjunction to the next, it takes a total of one hundred fifteen days and 6,005,005 minutes for this planet to operate in the same manner.