Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace MPI_дз_вычтех_
- {
- class Program
- {
- delegate double func(double c);
- const double eps = 0.001;
- static void Main(string[] args)
- {
- func f = (x) => 0.5 - Math.Log10(x);
- double a = 0.5;
- double b = 2;
- double xn = a;
- int counter = 0;
- Console.WriteLine("Первое уравнение МПИ:");
- while(Math.Abs(f(xn)-xn) > eps)
- {
- xn = f(xn);
- Console.WriteLine("x{0}={1}",counter++, xn);
- }
- Console.WriteLine("x*={0}", xn);
- f = (x) => Math.Pow(x, 3) + 0.4 * Math.Pow(x,2) + 0.6 * x - 1.6;
- counter = 0;
- b = 1;
- Console.WriteLine("Второе уравнение МПД:");
- while (Math.Abs(b - a) > eps)
- {
- xn = (a + b) / 2;
- Console.WriteLine("x{0}={1}",counter++,xn);
- if (f(xn) * f(a) < 0) b = xn;
- else if (f(xn) * f(b) < 0) a = xn;
- }
- Console.WriteLine("x*={0}", xn);
- Console.WriteLine("Третье уравнение метод Ньютона:");
- counter = 0;
- a = 0;
- xn = a;
- f = (x) => Math.Asin(2 * x / (1 + Math.Pow(x, 2))) - Math.Exp(-Math.Pow(x, 2));
- func df = (x) => 2 * x * Math.Exp(-Math.Pow(x, 2)) + ((2/(Math.Pow(x,2)+1)) - (4*Math.Pow(x,2)/(Math.Pow((Math.Pow(x,2)+1),2))))/(Math.Sqrt(1 - ((4*Math.Pow(x,2)/(Math.Pow((Math.Pow(x,2)+1),2))))));
- func xk = (x) => xn - f(xn)/df(xn) ;
- while (Math.Abs(xk(xn) - xn) > eps)
- {
- xn = xk(xn);
- Console.WriteLine("x{0}={1}", counter++, xn);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement