ldo regula_使用C中的Regula Falsi方法找到复多项式方程的根

ldo regula

Regula Falsi方法 (Regula Falsi method)

About the method:

关于方法:

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.

我们经常听到许多儿童甚至许多成人抱怨他们在解决复杂的多项式方程式时面临的困难程度。 对于许多人来说,遵循科学计算器中的步骤并找到方程式的根源也是困难的。

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.

因此,该程序可以帮助工程专业的学生以及许多店主,供应商通过False Position方法或Regula Falsi方法求解复杂的方程式。 它也方便,容易并且不需要进行计算。

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:

尽管这是一种古老的方法,但现在很少使用,但对于愿意从事复杂项目和类似难题的学生来说,它可能会很有用,因为他们可以给教授留下更好的印象并获得更多的分数。 使用的方法是

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.

我们通过定位函数具有相反符号的两个点x 0和x 1来开始此过程。 现在,我们通过一条直线连接两个点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 )的直线以找到新的交点。 如果f(x 2 )和f(x 0 )具有相同的符号,则将x 0替换为x 2并像以前一样进行。 在这两种情况下,新的搜索间隔都小于初始间隔,并最终保证了收敛到根。

We will now get an equation to find the successive approximations to the root:

现在,我们将得到一个方程式,以求根的逐次逼近:

regula-falsi-method

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方法查找给定多项式方程的根。 在这里,如果方程是二次方程,则采用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}来假设2个数字可能是方程的根。 如果实际根不在假设值之间或附近,则程序将不会运行。 如果实际根位于假设值之间,则程序将给出精确答案的近似值。

Example/program:

示例/程序:

#include <stdio.h>
#include <math.h>
#define ep 0.001
float 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 roots
printf ("\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);
else
printf("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:

输出:

Regula Falsi Method in C - output

翻译自: https://www.includehelp.com/algorithms/find-the-roots-of-a-complex-polynomial-equation-using-regula-falsi-method-in-c.aspx

ldo regula

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/543683.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

解决一次由于SSL证书到期导致的网站不能访问的问题(Nginx,php,Apache)

1. 现象放假期间收到zabbix报警&#xff0c;提示主站访问不了&#xff0c;报502。2.排查思路及过程因为是过年休息&#xff0c;放假前又没有更新&#xff0c;基本可以排除是更新和配置导致的问题。ssh连上服务器发现服务器连接和资源都没问题。这是一套lnamp架构的网站&#xf…

python字典按键值排序_在Python中按键或值按升序和降序对字典排序

python字典按键值排序Problem Statement: Write a Python program to sort (ascending and descending) a dictionary by key or value. 问题陈述&#xff1a;编写一个Python程序&#xff0c;以按键或值对字典进行排序(升序和降序)。 Example: 例&#xff1a; Input: diction…

Try Redis : Redis 入门教程

开篇 Redis 是一种以键值对&#xff08;key-value&#xff09;存储数据的NoSQL数据库。 键值对存储数据的本质是以某个键存储某个值。之后你可以用这个键把存储的值取出来。可以用SET命令以键‘servername’存储值‘fido’&#xff1a; SET servername fido这样&#xff0c;数据…

在C ++中使用getter和setter函数创建具有X和Y轴的类Point

We have two declare a point class with two Axis X and Y and we have to create/design its getter and setter functions. 我们有两个声明带有两个Axis X和Y的点类&#xff0c;并且我们必须创建/设计其getter和setter函数。 As we know that a class has some data member…

go newscanner判断文件读取结束_Go单元测试-testing

在开发程序中&#xff0c;很重要一点就是测试&#xff0c;测试可以保证代码的质量&#xff0c;保证每个函数可以正常运行。但是如何保证写出来的程序是否正确。单元测试一般是用来测试我们的代码逻辑有没有问题&#xff0c;有没有按照我们期望的运行&#xff0c;以保证代码质量…

_.uniq_在Ruby中使用Array.compact和Array.uniq方法从Array中移除元素

_.uniqRuby Array.compact和Array.uniq方法 (Ruby Array.compact and Array.uniq Methods) In the last article, we have gone through two different methods of deleting elements from the Array. We have seen their implementation with the help of their syntaxes and …

清除缓存的实现

现有的清除缓存存在着一些问题&#xff0c;占坑查询&#xff0c;后续进行完善转载于:https://www.cnblogs.com/lazVy/p/5192244.html

divi模板下载_Java Math类静态double IEEEremainder(double divi,double divisor)的示例

divi模板下载数学类静态double IEEEremainder(double divi&#xff0c;double divisor) (Math Class static double IEEEremainder(double divi , double divisor)) This method is available in java.lang package. 此方法在java.lang包中可用。 This method is used to retur…

nextdate函数白盒测试问题 软件测试_软件测试基本常识

一、软件测试的分类&#xff1a;1.按照是否执行被测试软件来分&#xff1a;静态测试&#xff1a;是指不运行软件&#xff0c;测试包括代码检查、静态结构分析、代码质量度量等&#xff0c;主要对软件需求说明书、设计说明书、软件源代码进行检查与分析。 动态测试&#xff1a;…

java 大小写转换函数_不使用Java中的任何库函数将大写转换为小写

java 大小写转换函数Given a string and we have to convert it from uppercase to lowercase. 给定一个字符串&#xff0c;我们必须将其从大写转换为小写。 Examples: 例子&#xff1a; Input:IncludeHelp.comOutput:includehelp.comInput:[email protected]Output:[email p…

ideatomcat老是运行以前的项目_日“吞”150吨垃圾,禅城集中式餐厨垃圾处理项目启用...

12月9日&#xff0c;禅城区集中式餐厨垃圾处理项目正式投料试运行&#xff0c;该项目如今每天可处理150吨垃圾。这意味着禅城区将通过先进技术实现餐厨垃圾资源化、减量化、无害化处理。禅城区集中式餐厨垃圾处理项目位于佛山市南庄污水处理厂首期工程北侧&#xff0c;禅港路西…

【HDOJ】4363 Draw and paint

看题解解的。将着色方案映射为40*40*5*5*5*5*2个状态&#xff0c;40*40表示n*m,5*5*5*5表示上下左右相邻块的颜色&#xff0c;0表示未着色。2表示横切或者竖切。基本思路是记忆化搜索然后去重&#xff0c;关键点是可能未切前当前块已经着色了。 1 /* 4363 */2 #include <ios…

java怎么知道上传文件是否成功_文件包含漏洞之——tomcat CVE-2020-1938漏洞复现

这个漏洞是今年2月份出现的&#xff0c;他的影响范围也是非常广的。2月20日&#xff0c;国家信息安全漏洞共享平台&#xff08;CNVD&#xff09;发布了Apache Tomcat文件包含漏洞&#xff08;CNVD-2020-10487/CVE-2020-1938&#xff09;&#xff0c;这个漏洞是由于Tomcat AJP协…

css word-wrap_CSS中分词“ break-all”和“ break-word”的值之间的差异

css word-wrapDefinition: 定义&#xff1a; What is the most fundamental element that comes to mind when you are considering to develop a web page? Words! If that was your answer, then pat yourself because you are already aware of what we are going to disc…

Android Studio apk 打包流程

1.Build -> Generate Signed APK...&#xff0c;打开如下窗口 2.假设这里没有打过apk包&#xff0c;点击Create new&#xff0c;窗口如下 这里只要输入几个必要项 Key store path&#xff08;生产key文件的保存路径 &#xff09; Key store password&#xff08;key 存储密码…

update yum 到指定版本_CentOS系统升级至指定版本

摘要&#xff1a;CentOS系统下用yum updates命令默认只能升级到最新版本&#xff0c;CentOS仓库并不维护历史版本&#xff0c;所以只能使用 vault.centos.org 历史版本快照进行更新。本文以...CentOS系统下用yum updates命令默认只能升级到最新版本&#xff0c;CentOS仓库并不维…

Redis过期key清理机制

Redis的key过期时间探讨 说到Redis是一个典型的key-value非关系型数据库&#xff0c;存储的key基本都有过期时间&#xff0c;或者有默认的过期时间&#xff0c;或者不设置的话永久不失效&#xff08;内存空间足够大的情况下&#xff0c;生产环境一般放置系统的配置参数才这样&a…

错误:使用printf()打印Hello world时未声明'Hello'/ Text

While printing "Hello world", if this error Hello undeclared occurred that means Hello is supplied to the compiler as a variable not as a text/string. 在打印“ Hello world”时 &#xff0c;如果发生未声明的错误“ Hello” &#xff0c;则意味着Hello是…

C#中毫米与像素的换算方法

C#中以像素作为尺寸单位&#xff0c;像素是一种相对的尺寸概念&#xff0c;与毫米的转换与当前显示器的分辨率有关。在不同分辨率下转换的系数不同。 借助GDI可以完成毫米至像素的转换。 public static double MillimetersToPixelsWidth(double length) //length是毫米&#xf…

Python | 使用__del __()和__init __()实现析构函数和构造函数的示例

To implement a constructor, we use __init()__ and to implement a destructor, we use __del()__ in python. 为了实现构造函数&#xff0c;我们使用__init()__ &#xff1b;为了实现析构函数&#xff0c;我们使用python中的__del()__ 。 Program: 程序&#xff1a; class…