我是靠谱客的博主 虚心鸡翅,最近开发中收集的这篇文章主要介绍算法之【牛顿迭代法】As we all know, basic numerical calculation in the computer is: addition, subtraction, multiplication and division.,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

众所周知,计算机的基本数值算法是加减乘除,甚至只是加减法。而次方和开根算法都是由四则运算混合表示而成的,因而根号计算比四则运算要慢很多。无理数如√2的浮点数计算就是由牛顿迭代法得出的。牛顿迭代法是一种用于计算曲线方程根的精确算法(尤其是幂函数方程),比二分法更加高效,因为它基于微分。

As we all know, basic numerical calculation in the computer is: addition, subtraction, multiplication and division.

Or even only the addition and subtraction. But the power and root algorithm is a complex combination of the four fundamental operations, so they are much slower. Irrational numbers such as √2 whose floating point is obtained by the Newton-Raphson method. Newton-Raphson method is a precise algorithm used to calculate the curvilinear equation (especiallypower function), it’s more efficient than Dichotomy because it is based on the differential.

以计算√x(精度e)为例的c语言函数:

A example using C language calculating √x with precision ’e’:

double abs_value(double x)

{

 if(x<0)x=-x;

 return x;

}

double sqrt_root(double x,double e)

{

 double x0=1;

 while(abs_value(x0*x0-x)>e)

X0=(x0+x/x0)/2;

 return x0;

}


最后

以上就是虚心鸡翅为你收集整理的算法之【牛顿迭代法】As we all know, basic numerical calculation in the computer is: addition, subtraction, multiplication and division.的全部内容,希望文章能够帮你解决算法之【牛顿迭代法】As we all know, basic numerical calculation in the computer is: addition, subtraction, multiplication and division.所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(39)

评论列表共有 0 条评论

立即
投稿
返回
顶部