算法——Horner scheme--A8站源码交易平台

  • 时间:2020-03-31 14:02 编辑:益达 来源:原创 阅读:229
  • 扫一扫,手机访问
摘要:Horner 算法是以英国数学家 William George Horner 命名的一种多项式求值的快速算法,同秦九韶算法: 只需要n次乘法和n次加法。在人工计算时,一次大大简化了运算进程。

A8站源码交易平台

https://www.a8zhan.com/




标题描述

In numerical analysis, the Horner scheme or Horner algorithm, named after William George Horner, is an algorithm for the efficient evaluation of polynomials in monomial form. Horner’s method describes a manual process by which one may approximate the roots of a polynomial equation. The Horner scheme can also be viewed as a fast algorithm for dividing a polynomial by a linear polynomial with Ruffini’s rule.
Application
The Horner scheme is often used to convert between different positional numeral systems — in which case x is the base of the number system, and the ai coefficients are the digits of the base-x representation of a given number — and can also be used if x is a matrix, in which case the gain in computational efficiency is even greater.
History
Even though the algorithm is named after William George Horner, who described it in 1819, the method was already known to Isaac Newton in 1669, and even earlier to the Chinese mathematician Ch’in Chiu-Shao in the 13th century. TASK: write a program to calculate sum of Polynomial by Horner scheme.

输入

tow lines. The first line have tow numbers,n and x, n<=20, x<=10 The second line have n+1 numbers, a0,a1…an.

输出

The sum of Polynomial

样例输入

5 2
0 1 2 3 4 5

样例输出

258

代码

#include
using namespace std;
int main(){
int n, x, sum = 0;
cin>>n>>x;
int a[20];
for(int i = 0; i <= n; i++){
cin>>a[i];

for(int i = n; i >= 0; i--){
sum = sum*x + a[i];
}
cout<<sum<<endl;
 return 0;


A8站源码交易平台-思路

1.Horner 算法是以英国数学家 William George Horner 命名的一种多项式求值的快速算法,同秦九韶算法:
只需要n次乘法和n次加法。在人工计算时,一次大大简化了运算进程。
2.
把一个n次多项式
1.png


改写成如下形式:
2.png
3.求多项式的值时,首先计算最内层括号内一次多项式的值。
4.对于一个n次多项式,至多做n次乘法和n次加法。

https://www.a8zhan.com/

<sum<<endl;

  • 全部评论(0)
最新发布的资讯信息
【A8站-免费源码分享|直播源码】直播系统源码开发:关于安卓开发工具和obs直播推流(2020-10-30 09:41)
【计算机/互联网|】【独家修复】用户定制版短视频点赞系统,支持抖音+快手+刷宝+微视等所有主流短视频评论系统源码(2020-10-26 16:34)
【技术宅-为技术而疯|网站架设教程】【独家首发】最新更新已对接短信2020全新抖音快手点赞任务系统霸屏天下小红书头条威客兼职完整搭建架设视频教程(2020-10-25 13:56)
【技术宅-为技术而疯|网站架设教程】最新可用个人发卡网系统源码完整搭建架设视频教程(2020-10-25 10:53)
【技术宅-为技术而疯|网站架设教程】独家更新全新V10抢单系统唯品会京东淘宝自动抢单区块系统源码全开源抢单收单接单返利+搭建架设完整视频教程(2020-10-25 10:52)
【计算机/互联网|】柔丫纸尿裤云仓系统源码部署(2020-10-15 18:13)
【计算机/互联网|】侏罗纪软件模式定制开发(2020-10-14 15:33)
【计算机/互联网|】S2b2C供应商系统 营销闭环(2020-10-10 17:46)
【计算机/互联网|程序设计开发】盛都汇系统奖励机制(2020-10-10 17:20)
【A8站-免费源码分享|网站源码】积分商城系统APP开发(2020-09-23 14:56)
联系我们
Q Q:3101359898 点击直接对话
电话:18580901894
邮箱:admin#a8zhan.com
时间:09:00 - 24:00
手机二维码 访问手机版
返回顶部