-->
当前位置:首页 > 题库

PROGRAMMING:Finding the single root of a polynomial by dichotomy

Luz5年前 (2021-05-10)题库442
The principle of dichotomy for finding the root of a function is: if the two endpoints of the continuous function $$f (x) $$in the interval $$[a, b] $$have different values, that is, $$f (a) f (b) < 0 $$, then it has at least one root $$R $$, that is, $$f (R) = 0 $$.
The steps of dichotomy are as follows:
-Check the length of the interval, if it is less than the given threshold, stop and output the midpoint of the interval $$(a + b) / 2 $$; otherwise
-If $$f (a) f (b) < 0 $$, calculate the value of the midpoint $$f ((a + b) / 2) $$;
-If $$f ((a + b) / 2) $$is exactly 0, then $$(a + b) / 2 $$is the root of the request; otherwise
-If $$f ((a + b) / 2) $$and $$f (a) $$have the same number, then the root is in the interval $$[(a + b) / 2, b] $$, let $$a = (a + b) / 2 $$, repeat the cycle;
-If $$f ((a + b) / 2) $$and $$f (b) $$have the same number, then the root is in the interval $$[a, (a + b) / 2] $$, let $$B = (a + b) / 2 $$, repeat the cycle.
This topic requires the preparation of procedures to calculate a given third-order polynomial $$f (x) = a_ 3 x^3 +a_ 2 x^2 +a_ 1 x+a_ The root of 0 $$in the given interval $$[a, b] $.
###Input format:
Input the four coefficients of the polynomial in the first line_ 3$$、$$a_ 2$$、$$a_ 1$$、$$a_ In line 2, $$a $$and $$B $$are given sequentially. The problem guarantees that a polynomial has a unique single root in a given interval.
###Output format:
Output the root of the polynomial in the interval in one line, accurate to 2 decimal places.
###Input example:
```in
3 -1 -3 1
-0.5 0.5
```
###Output example:
```out
zero point three three
```






answer:If there is no answer, please comment