📄 sample5_12.cs
字号:
/*
* 示例程序Sample5_12: NLEquations类的求实函数或复函数方程一个复根的蒙特卡洛法
*/
using System;
using CSharpAlgorithm.Algorithm;
namespace CSharpAlgorithm.Sample
{
class Class1
{
// 建立NLEquation的子类,在其中重载函数func
class NLEq : NLEquations
{
protected override double Func(double x, double y)
{
double u=x*x-y*y-6.0*x+13.0;
double v=2.0*x*y-6.0*y;
double z=Math.Sqrt(u*u+v*v);
return z;
}
}
[STAThread]
static void Main(string[] args)
{
// 求解
NLEq nleq = new NLEq();
double x=0.5;
double y=0.5;
double b=1.0;
int m=10;
double eps=0.000001;
nleq.GetRootMonteCarlo(ref x, ref y, b, m, eps);
Console.WriteLine(new Complex(x, y));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -