Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace KR
- {
- class Program
- {
- public static double f(double x){
- return 2*x*x-8*x-7;
- }
- public static void Main(string[] args)
- {
- Console.WriteLine("Исходный пример - f(x)=2*x*x - 8*x -7 | X=[0;3] \n Точность = 0.5");
- double a=0;
- double b=3;
- double E=0.5;
- double sh=(b-a)/4;
- double x0=a;
- double Fx0=f(x0);
- double x,F;
- M: double x1=x0+sh;
- double Fx1=f(x1);
- if(Fx0>Fx1){
- x0=x1;
- Fx0=Fx1;
- if(x0>a&&x0<b){
- goto M;
- }
- }
- if(Math.Abs(sh)>E){
- x=x0;
- F=f(x0);
- }
- else{
- x0=x1;
- Fx0=Fx1;
- sh=-sh/4;
- goto M;
- }
- Console.WriteLine("Найденное X = {0}, Значение функции = {1}",x,F);
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement