Continuous score Approximation

Source: Internet
Author: User

In mathematics,ScoreOrComplex scoreThat is, the following expression:

HereA0 is an integer and all other numbersANAll are positive integers. A longer expression can be defined according to the sample. IfPart molecules(Partial numerator) andPartial denominator(Partial denominator) allows the assumption of any value that can include a function in some contexts, the final expression is a generalized continuous score. When we need to distinguish the above standard form from the generalized concatenation score, we can call itSimpleOrRegular score, Or isStandard Form.

 

 

 

Consecutive scores are often used in the approximation of irrational numbers, for example:

The resulting approximate score ,,,,......

 

 

Consider real numbersR. SetIYesRAndFIs its decimal part. ThenRThe join score of is [I;…], Here, "…" Yes 1/F. Replace with semicolonsFirstComma.

Calculate the real numberRMark, write downR(Technically Floor ). SlaveRSubtract this integer. If the difference is 0, it is stopped; otherwise, the reciprocal of the difference is found and repeated. This process will be terminated if and only ifRIs a rational number.

Find the 3.245 join score
Stop
The join score of 3.245 is [3; 4, 12, 4].

The number 3.245 can also be expressed as a join score. Expand [3; 4, 12, 3, 1]. For more information, see the following finite join scores.

This algorithm is suitable for real numbers, but if it is implemented using floating-point numbers, it may cause numerical disasters. As an alternative, any floating point number is a precise rational number (in modern computers, the denominator is usually the power of 2 and the power of 10 in electronic calculators ), therefore, the variant of the Euclidean GCD algorithm can be used to give accurate results.

 

 

 

Then we can obtain the golden shard's endpoint ,,,,,,......

Note that the sub-families of the above series can be sorted in order to obtain the Fibonacci series.

Then we can obtain the approximate fraction, (approx. rate), (confidentiality rate), and... Of the circumference rate ),,......

Math, it can be proved that the approximate value of the approximate value is obtained from the (narrow) consecutive score where the numerator or denominator is smaller than the next progressive score.

 

 

 

The motive for studying the continuous score is that a real number is expressed purely in mathematics.

Most people are familiar with the decimal representation of real numbers:

HereA0 can be any integer, OtherAIAll are an element of {0, 1, 2,..., 9. In this representation, for example, the number π is represented as an integer sequence {3, 1, 4, 1, 5, 9, 2 ,...}.

This decimal number indicates some problems. For example, in this case, constant 10 is used because we use a 10-hexadecimal system. We can also use an octal or binary system. Another problem is that many rational numbers lack a limited representation in this system. For example, number 1/3 is expressed as an infinite sequence {0, 3, 3, 3, 3 ,....}.

The continuous score representation avoids the two problems of real number representation. Let's consider how to describe a number such as 415/93, which is about 4.4624. It is similar to 4, but actually a little more than 4, about 4 + 1/2. However, 2 in the denominator is inaccurate. The more accurate denominator is a little more than 2, which is about 2 + 1/6, so 415/93 is approximately 4 + 1/(2 + 1/6 ). However, 6 of the denominator is inaccurate. The denominator is a little more accurate than 6, and the actual denominator is 6 + 1/7. So 415/93 is actually 4 + 1/(2 + 1/(6 + 1/7 )). This is accurate.

Remove the redundant part of the expression 4 + 1/(2 + 1/(6 + 1/7) to obtain a brief mark [4; 2, 6, 7].

The concatenation score of a real number can be defined in this way. It has some desirable properties:

  • The continuous score of a number is limited. if and only when the number is rational.
  • The "simple" rational number of consecutive scores is short.
  • The continuous score of any rational number is unique if it does not follow 1. ([A0;A1 ,...AN, 1] = [A0;A1 ,...AN+ 1].)
  • The join score of an irrational number is unique.
  • The join score is repeated. if and only if it is a quadratic irrational number (that is, the real number solution of the quadratic equation with an Integer Coefficient), the join score is [1].
  • QuantityXThe cut-off contiguous score of indicates that the result is generated very early.XThe rational number approximation of "optimal possibility" in a specific sense (see Theorem 5 inference 1 below ).

The last attribute is very important, and the traditional decimal point cannot. Truncation decimal number of a number indicates the rational number approximation of the number, but it is usually not a very good approximation. For example, truncation 1/7 = 0. 142857... produces an approximation ratio at various positions, such as 142/1000, 14/100, and 1/10. But the obvious best rational number approximation is "1/7" itself. The Truncation decimal number of π indicates generating an approximation ratio, such as 31415/10000 and 314/100. The concatenation score of π starts at [3; 7, 15, 1,292,...]. Truncation indicates that an excellent rational number is generated to approach 3, 22/7, 333/106, 355/113, 103993/33102 ,.... The denominator of 314/100 and 333/106 is very close, but the error of the approximate value of 314/100 is 19 times higher than that of 333/106. As an approximation of π, [3; 7, 15, 1] Is 3.1416 times more accurate than 100.

 

 

 

 

Now let's first look back at the hierarchical Reid algorithm:

SetA,BAndB>A

 

\ Mbox {({\ fontfamily {cwm7} \ fontseries {m} \ selectfont \ char 66 }...
... Tfamily {cwm1} \ fontseries {m} \ selectfont \ char 162 }})
\ End {cases} \ end {displaymath} "src =" http://episte.math.ntu.edu.tw/articles/mm/mm_02_3_08/img1.gif "width =" 423 "border =" 0 ">



 

 

This computation algorithm was developed by Dr. Reid during the first three hours of the Yuan Dynasty, remembering the seventh volume in his immortal book of the original. Its main purpose is to calculate two numbers.AAndBIs the most common factorRN). Today, if we want a computer to design the most common problems for us, we should be proud of Dr. Reid, because the method he used two thousand years ago is still the best at present.

Now, we have completely divided the form sub in the (a) group into fractions, as shown below:

 

\ Mbox {({\ fontfamily {cwm3} \ fontseries {m} \ selectfont \ char 14 }...
... N} {R _ {N-1 }}\\
& \ Frac {R _ {N-1 }}{ R_N} = a_n
\ End {eqalign} \ right.
\ End {displaymath} "src =" http://episte.math.ntu.edu.tw/articles/mm/mm_02_3_08/img2.gif "width =" 198 "border =" 0 ">



 

 

In group B, replace the first type with the inverted data of the third type, and then the inverted data of the third type.

 

\ Mbox {({\ fontfamily {cwm3} \ fontseries {m} \ selectfont \ char 6 })}...
... Inus0.1pt {\ fontfamily {cwm1} \ fontseries {m} \ selectfont \ char 98 }})
\ End {eqnarray *} "src =" http://episte.math.ntu.edu.tw/articles/mm/mm_02_3_08/img5.gif "width =" 363 "border =" 0 ">

 



In the above formula, the right margin refers to the "nearest score" (more precisely, there is a single score ). In order to save space and speed, we thought

 

A_0 + \ frac {1} {A_1} \; \ lower1.5ex \ hbox {+ + $ }\; \ frac {1} {A_2 }\;...
... Fontseries {m} \ selectfont \ char 67 }}\ quad
[A_0, A_1, \ cdots, a_n]
\ End {displaymath} "src =" http://episte.math.ntu.edu.tw/articles/mm/mm_02_3_08/img6.gif "width =" 323 "border =" 0 ">

 

The following is the implementation of the continuous score Code. It is purely my own. If there are any deficiencies, please point out

 

 

 

# Include <iostream>
# Include <cmath>
Using namespace STD;

_ Int64 num [1000]; // records the continuous score Series

// Continued Fractions

Long fraction (_ int64 R ,__ int64 F)
{
_ Int64 M = 1;
While (M <= f)
{
M * = 10;
}

_ Int64 S = r * m + F;
Long Len = 0;


While (S % m! = 0)
{
_ Int64 T = S % m;
Num [Len ++] = s/m;
S = m;
M = T;
}
Num [Len ++] = s/m;
// Store the denominator in sequence

Return Len;
}

Int main ()
{
_ Int64 r, f;
While (scanf ("% i64d. % i64d", & R, & F )! = EOF)
{
Long Len = fraction (r, f );
Long I;
For (I = 0; I <Len; ++ I)
{
Printf ("% ld: % i64d \ n", I + 1, num [I]);
}
}
Return 0;
}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.