门户网站与搜索引擎的区别,网站程序怎么备份,图书信息管理系统代码网站建设,注册安全工程师含金量1 割线法
割线法用于求方程 f(x) 0 的根。它是从根的两个不同估计 x1 和 x2 开始的。这是一个迭代过程#xff0c;包括对根的线性插值。如果两个中间值之间的差值小于收敛因子#xff0c;则迭代停止。
亦称弦截法#xff0c;又称线性插值法.一种迭代法.指用割线近似曲线求… 1 割线法
割线法用于求方程 f(x) 0 的根。它是从根的两个不同估计 x1 和 x2 开始的。这是一个迭代过程包括对根的线性插值。如果两个中间值之间的差值小于收敛因子则迭代停止。
亦称弦截法又称线性插值法.一种迭代法.指用割线近似曲线求方程根的2步迭代法.此法用通过点(xkf(xk))及(xk-1f(xk-1))的割线 近似曲线yf(x)用割线的根作为方程根的新近似xk1从而得到方程求根的割线法迭代程序 ( k12…n)
其中x0x1为初始近似.若f(x)在根x*的邻域内有二阶连续导数且f′(x*)≠0则当x0x1在x*邻域内时割线法收敛于x*其收敛阶为 2 源程序
using System; using System.Text; using System.Collections; using System.Collections.Generic;
namespace Legalsoft.Truffer.Algorithm { public delegate double delegateFunctionX(double x); public static partial class Algorithm_Gallery { public static delegateFunctionX funx null; public static bool Secant(double x1, double x2, out double x0, double Epsilon) { int n 0; double xm; x0 x1; if (funx(x1) * funx(x2) 0) { do { x0 (x1 * funx(x2) - x2 * funx(x1)) / (funx(x2) - funx(x1)); double c funx(x1) * funx(x0); x1 x2; x2 x0; n; if (Math.Abs(c) float.Epsilon) { break; } xm (x1 * funx(x2) - x2 * funx(x1)) / (funx(x2) - funx(x1)); } while (Math.Abs(xm - x0) Epsilon); return true; } else { return false; } } } } 3 源代码
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;namespace Legalsoft.Truffer.Algorithm
{public delegate double delegateFunctionX(double x);public static partial class Algorithm_Gallery{public static delegateFunctionX funx null;public static bool Secant(double x1, double x2, out double x0, double Epsilon){int n 0;double xm;x0 x1;if (funx(x1) * funx(x2) 0){do{x0 (x1 * funx(x2) - x2 * funx(x1)) / (funx(x2) - funx(x1));double c funx(x1) * funx(x0);x1 x2;x2 x0;n;if (Math.Abs(c) float.Epsilon){break;}xm (x1 * funx(x2) - x2 * funx(x1)) / (funx(x2) - funx(x1));} while (Math.Abs(xm - x0) Epsilon);return true;}else{return false;}}}
}