📄 sample5_3.cs
字号:
/*
* 示例程序Sample5_3: NLEquations类的求非线性方程一个实根的埃特金迭代法
*/
using System;
using CSharpAlgorithm.Algorithm;
namespace CSharpAlgorithm.Sample
{
class Class1
{
// 建立NLEquation的子类,在其中重载函数func
class NLEq : NLEquations
{
protected override double Func(double x)
{
double y = 6.0-x*x;
return y;
}
}
[STAThread]
static void Main(string[] args)
{
// 求解
NLEq nleq = new NLEq();
double x = 0.0;
if (nleq.GetRootAitken(ref x, 60, 0.000001))
Console.WriteLine("求得的根为:" + x);
else
Console.WriteLine("求解失败");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -