Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- public static readonly Func<double, double> Function1 = x
- => 3 * Math.Pow(x, 4) + Math.Pow(x - 1, 2);
- public static readonly Func<double, double> Function2 = x
- => Math.Pow(x, 3) * Math.Sin(x);
- public static void Main()
- {
- // double.TryParse(Console.ReadLine(), out double a);
- // double.TryParse(Console.ReadLine(), out double b);
- Console.WriteLine("***Dichotomy method***\n");
- (double end, double start) interval = new DichotomyMethod().FindRoot(Function2, 0, 6);
- var x = (interval.start + interval.end) / 2;
- Console.WriteLine($"Interval: {interval}");
- Console.WriteLine($"Root: {x}");
- Console.WriteLine($"Value in root: {Function2(x)}");
- Console.WriteLine("\n\n***Golden section method***\n");
- var goldenSectionMethod = new GoldenSectionMethod(Function2);
- var y = goldenSectionMethod.FindMin(0, 6);
- Console.WriteLine("Root: " + y);
- Console.WriteLine($"Value in root: {Function2(y)}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement