ldo regula_使用C中的Regula Falsi方法找到复多项式方程的根
ldo regula
Regula Falsi方法 (Regula Falsi method)
About the method:
關(guān)于方法:
We often hear many children and even many adults complaining about the difficulty level that they face while solving complex polynomial equations. It is also difficult for many to follow the steps in a scientific calculator and find the roots of the equations.
我們經(jīng)常聽到許多兒童甚至許多成人抱怨他們在解決復(fù)雜的多項(xiàng)式方程式時面臨的困難程度。 對于許多人來說,遵循科學(xué)計算器中的步驟并找到方程式的根源也是困難的。
Therefore, this is a program that would help engineering students and many shopkeepers, vendors to solve complex equations via the False Position method or the Regula Falsi method. It is also handy, easy and calculations need not be done.
因此,該程序可以幫助工程專業(yè)的學(xué)生以及許多店主,供應(yīng)商通過False Position方法或Regula Falsi方法求解復(fù)雜的方程式。 它也方便,容易并且不需要進(jìn)行計算。
Though this is an old method and not much used now it can be useful for those students who are willing to work on a complex project and on a difficult topic like this as they can create a better impression on their professors and fetch more marks. The method used is:
盡管這是一種古老的方法,但現(xiàn)在很少使用,但對于愿意從事復(fù)雜項(xiàng)目和類似難題的學(xué)生來說,它可能會很有用,因?yàn)樗麄兛梢越o教授留下更好的印象并獲得更多的分?jǐn)?shù)。 使用的方法是 :
We start this procedure by locating two points x0 and x1 where the function has opposite signs. We now connect the two points f(x0) and f(x1) by a straight line and find where it cuts the x-axis. Let it cut the axis at x2. We find f(x2). If f(x2) and f(x0) are of opposite signs then we replace x1 by x2 and draw a straight line connecting f(x2) to f(x0) to find the new intersection point. If f(x2) and f(x0) are of the same sign then x0 is replaced by x2 and proceed as before. In both cases, the new interval of search is smaller than the initial interval and ultimately it is guaranteed to converge to the root.
我們通過定位函數(shù)具有相反符號的兩個點(diǎn)x 0和x 1來開始此過程。 現(xiàn)在,我們通過一條直線連接兩個點(diǎn)f(x 0 )和f(x 1 ),并找到它在x軸上的切割位置。 讓它在x 2處切割軸。 我們找到f(x 2 )。 如果f(x 2 )和f(x 0 )具有相反的符號,則我們將x 1替換為x 2并繪制一條將f(x 2 )連接到f(x 0 )的直線以找到新的交點(diǎn)。 如果f(x 2 )和f(x 0 )具有相同的符號,則將x 0替換為x 2并像以前一樣進(jìn)行。 在這兩種情況下,新的搜索間隔都小于初始間隔,并最終保證了收斂到根。
We will now get an equation to find the successive approximations to the root:
現(xiàn)在,我們將得到一個方程式,以求根的逐次逼近:
Problem:
問題:
To find the roots of the given polynomial equation using the Regula Falsi method. Here, we take the equation in the form of f(x) = ax2+ bx+c if the equation is a quadratic equation.
使用Regula Falsi方法查找給定多項(xiàng)式方程的根。 在這里,如果方程是二次方程,則采用f(x)= a x 2 + b x + c的形式。
Example: f(x) = x2-25
例如:f(x)= x 2 -25
In this method, we need to assume 2 numbers which might be the roots of the equation by equating the equation f(x) to zero {f(x) = 0}. If the actual roots do not lie between or are near to the assumed values, the program will not run. And if the actual roots lie between the assumed values then the program will give the approximate of exact answer.
在此方法中,我們需要通過將方程f(x)等于零{f(x)= 0}來假設(shè)2個數(shù)字可能是方程的根。 如果實(shí)際根不在假設(shè)值之間或附近,則程序?qū)⒉粫\(yùn)行。 如果實(shí)際根位于假設(shè)值之間,則程序?qū)⒔o出精確答案的近似值。
.minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}Example/program:
示例/程序:
#include <stdio.h> #include <math.h> #define ep 0.001float poly(float ar[], int, float);int main() {float a[10],y0,y1,y2,x0,x1,x2,s,r;int i,n;char flag;printf("\t\t\t*****REGULA FALSI METHOD*****");//enter 2 if it is quadratic eq.printf ("\n\n Please enter the degree of polynomial equation: "); scanf ("%d", &n);if (n>1){for (i=0;i<=n; i++){printf ("Enter the coefficient of x to the power %d: ", i);scanf ("%f", &a[i]);}do{//enter assumed values of rootsprintf ("\n Enter the initial guesses of x0 and x1: "); scanf ("%f %f",&x0,&x1);y0=poly (a, n, x0);y1=poly (a, n, x1);} while (y0*y1>0); printf ("\n x0 x1 x2 y0 y1 y2");for (i=0; i<=100; i++){s= (x0*y1)-(y0*x1);r= y1-y0;x2 = s/r;y2 = poly (a, n, x2);if (fabs (y2)<= ep){flag ='T';break;}printf("\n %f %f %f %f %f %f",x0,x1,x2,y0,y1,y2);if ((y2*y0)<0){x1=x2;y1=y2;}else{x0=x2;y0=y2;}}if(flag=='T')printf("\n\n Convergent solution= %f",x2);elseprintf("Does not converge in 100 iterations.");}else{printf("\n\tDegree not acceptable!");}return 0; }float poly(float ar[],int n,float x) {int i;float p;p=ar[n];for(i=n;i>=1;i--){p=ar[i-1]+(x*p);}return (p); }Output:
輸出:
翻譯自: https://www.includehelp.com/algorithms/find-the-roots-of-a-complex-polynomial-equation-using-regula-falsi-method-in-c.aspx
ldo regula
總結(jié)
以上是生活随笔為你收集整理的ldo regula_使用C中的Regula Falsi方法找到复多项式方程的根的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java的equals方法_Java V
- 下一篇: c语言1+2+3+4+5_C程序来计算系