Qin Jiushao algorithm is a polynomial simplification algorithm proposed by the mathematician Qin Jiushao in the Southern Song Dynasty of China. In the West is called the Horner algorithm.
Qin Jiushao (about 1202-1261), the word DAO Ancient, the Southern Song Dynasty people, was born in Rushire (today, Shandong Qufu area people).
Generally, the evaluation of a unary n-th polynomial needs to undergo 2n-1 and n -Times addition , whereas the Qin Jiushao algorithm requires only n multiplication and n - th addition.
At the time of manual calculation, the operation process is greatly simplified.
Rewrite an n-th polynomial into the following form: When the value of the polynomial is evaluated, the value of the first polynomial in the inner bracket is computed, that is, the value of the polynomial is computed by the inward and outer layers, i.e.In this way, the value of the n-th polynomial f (x) is converted to the value of the N-once polynomial. Conclusion: For an n-th polynomial, at most, do n multiplication and N-time addition.
1 int Get (int x) 2 {3 int sum=0; 4 for (int i=n;i>=0;---i) 5 sum=sum*x+A[i]; 6 return sum; 7 }
Inexperienced shallow, Dianran also shallow, calendar thing deep, machine also deep.
Qin Jiushao algorithm knowledge points