-
I'd love to tell you, but I've forgotten what a string truncation is.
-
Whether there is a mistake in the formula, I didn't look closely. From the design of the program, you have at least two errors:
Cycle condition m !=0 。Here m is a float, and the float variable has precision, so m !
0 will be true, i.e. your for loop will never end. float variable and 0 for judgment, not ==, !=, and you should determine whether the absolute value of m is less than a threshold, for example.
After you find the intersection x, let a = x. That is, the next step is to find the intersection between (x, b). But how do you make sure that the intersection is between (x, b) and not between (a, x)?
There is a problem with the design here, after finding the intersection point x, the value of f(x) should be determined. Knowing that f(a) <0 and f(b) >0, if f(x) <0, then the next step should be between (x, b), but if f(x) >0, then the next step should be between (a, x).
I experimented and found that this function could not converge with this method. The y-value corresponding to the final intersection point cannot be reduced when it converges.
int main()
The purpose of the else loop is to keep finding the abscissa until the y value is equal to 0, and then the approximate root is found.
printf("%f", x);
return 0;
It seems that this method does not work well for functions that are too high-order. You can try this method by changing the number of times the ss function is smaller.
-
Let the unary equation be . f(x)
where f(x) is a continuous function over the real interval d.
It is not difficult to prove that if it is right.
x1,x2∈d(x1
x2), there is. f(x1)
f(x2)0, then f(x) has at least one in the interval (x1, x2).
We are interested in the curve y
The image of f(x) in (x1, x2) is linearly approximated, i.e., it is regarded as the passing point.
P1 (x1, f(x1)), p2 (x2, f(x2)). (f(x2)
f(x1))
x2x1)(y
f(x1))
xx1).The root of the equation is then approximately the x-coordinate of the intersection of the string p1p2 (which is a straight line intersecting the x-axis) on the x-axis.
We make y on the upper chord
0, the intercept of the chord can be solved: x
f(x2)f(x1))
x2x1))
x1………#
This is the equation f(x).
The first approximation of 0.
Write it as x3
Then we calculate f(x3) and, if we are lucky enough, f(x3)0, we find the root of the equation. Of course, usually there are just that. f(x3)0 or f(x3).
There will be this. f(x1)
f(x3) or. f(x2)
f(x3) repeats the above step, i.e., using ( ) again, to obtain a more accurate approximation of the equation f(x)0.
With enough of the above steps, the root of an arbitrary-precision equation can be obtained.
This is how the string truncation method is used to calculate the approximation of the root of a unary equation.
If the landlord is looking for the textbook for the class, it is not helping the landlord, the book is not good, and no one has to do the electronic version. >>>More
1 Overview of Programming.
An overview of programming languages. >>>More
In fact, it's not difficult to learn C, the key is that you have to find a teacher who suits you or self-study**, I didn't learn when I signed up for the class, and then I didn't learn it online**, I read it at the beginning, Mr. Xia's, I feel that the lecture is very concise and clear, the kind that you can understand when you listen to it, and what you talk about is the key, and there is a difference from others is that there are many difficult concepts with metaphorical examples, for example, the array I recently saw is compared to a box with things in order, and I understand the array variables and assignments at once. It's much better than what I read before, Hao Bin and Zeng Yi's cumbersome like reading a textbook.
Right!
The divisible 5 between 1 and 40 is: >>>More
Hello, there hasn't been much time lately, so I can only remind you that the focus of this zhi topic is not dao >>>More