Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Метод Хорд
- using System;
- namespace ConsoleApplication2
- {
- class Program
- {
- static double f(double x)
- {
- x = Math.Pow(x, 4) - 8 * Math.Pow(x, 3) - (2 * x * x) - 3;
- return x;
- }
- static void Main(string[] args)
- {
- double a, b, c = 0.0, c0 = 0.0, eps;
- Console.Write("Введите a: ");
- a = Convert.ToDouble(Console.ReadLine());
- Console.Write("Введите b: ");
- b = Convert.ToDouble(Console.ReadLine());
- Console.Write("Введите eps: ");
- eps = Convert.ToDouble(Console.ReadLine());
- do
- {
- c0 = c;
- c = a - (b - a) / (f(b) - f(a)) * f(a);
- if ((f(a) * f(c)) > 0)
- a = c;
- else
- b = c;
- }
- while (Math.Abs(c - c0) > eps);
- Console.Write("Корень: ");
- Console.WriteLine(c);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment