复杂方程可以自己定义,以下是看别人的题目,然后自己来做
以下是计算结果
csharp
private void GetMinResult(out double resultX1, out double min)
{
double x1, result;
Random random1 = new Random(DateTime.Now.Millisecond* DateTime.Now.Second);
min = 999999;
resultX1 = 0;
for (int i = 0; i < 654321; i++)
{
if (random1.Next(0, 100) % 2 == 0)
{
x1 = resultX1 + random1.NextDouble()*100;
}
else
{
x1 = resultX1 - random1.NextDouble()*100;
}
if (x1 < 0 || x1 > 50)
{
continue;
}
result = x1 * Math.Sin(x1) * Math.Cos(2 * x1) - 2 * x1 * Math.Sin(3 * x1) + 3 * x1 * Math.Sin(4 * x1);
if (result < min)
{
resultX1 = x1;
min = result;
}
}
}