using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
public delegate double Func(double x);
static void Main(string[] args)
{
Func value = function;
const double e = 0.001;
double a, b;
a = 0.5;
b = 1.5;
while (Math.Abs(b - a) > 2*e)
{
double c = (a + b) / 2;
if (value(b) * value(c) < 0)
{
a = c;
}
else
{
b = c;
}
}
Console.WriteLine((a + b) / 2);
Console.ReadLine();
}
static double function(double x)
{
double tmp = Math.Pow(2, 0.5);
return 4 * Math.Sin(3 * x - 1) - Math.Pow(x, tmp) + 1;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
public delegate double Func(double x);
static void Main(string[] args)
{
Func procedure = function;
double a, b;
a = 0.5;
b = 1.5;
use_procedure_for_a_and_b(ref a, ref b, procedure);
Console.WriteLine((a + b) / 2);
Console.ReadLine();
}
static void use_procedure_for_a_and_b(ref double a, ref double b, Func procedure)
{
const double e = 0.001;
while (Math.Abs(b - a) > 2 * e)
{
double c = (a + b) / 2;
if (procedure(b) * procedure(c) < 0)
{
a = c;
}
else
{
b = c;
}
}
}
static double function(double x)
{
double tmp = Math.Pow(2, 0.5);
return 4 * Math.Sin(3 * x - 1) - Math.Pow(x, tmp) + 1;
}
}
}