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;
- using System.Threading.Tasks;
- using static System.Math;
- namespace laba3
- {
- class Program
- {
- const double ex = 0.00001;
- public static double Add(double x, int n)
- {
- return ((Pow(x,(2*n+1)) ) / (2*n + 1));
- }
- static void Main(string[] args)
- {
- string str;
- Console.WriteLine("Запрос необходимых данных:");
- Console.WriteLine(" * * * ");
- Console.WriteLine("Введите x начальный ");
- str = Console.ReadLine();
- double x;
- while (!double.TryParse(str, out x))
- {
- Console.WriteLine("Неправильный формат ввода");
- Console.WriteLine("Введите x начальный ");
- str = Console.ReadLine();
- }
- Console.WriteLine("Введите x конечный ");
- str = Console.ReadLine();
- double xk;
- while (!double.TryParse(str, out xk))
- {
- Console.WriteLine("Неправильный формат ввода");
- Console.WriteLine("Введите x конечный ");
- str = Console.ReadLine();
- }
- Console.WriteLine("Введите шаг ");
- str = Console.ReadLine();
- double dx;
- while (!double.TryParse(str, out dx))
- {
- Console.WriteLine("Неправильный формат ввода");
- Console.WriteLine("Введите шаг");
- str = Console.ReadLine();
- }
- int kolvo = (int)((xk - x) / dx);
- Console.WriteLine("Начинаю построение");
- Console.WriteLine(" * * * ");
- Console.WriteLine("| параметр х|Приближенный y| Количество | y точный |");
- double y, temp, sum = 0;
- int n = 0;
- for (int i = 0; i < kolvo; i++)
- {
- y = Log(((1+x)/(1-x)));
- n = 0;
- sum = 0;
- temp = Add(x, n);
- while (Abs(temp) > ex)
- {
- sum += temp;
- n++;
- temp = Add(x, n);
- }
- Console.WriteLine("| {0,5:f2} | {1,4:f6} | {2,6:f6} | {3,6:f6} |", x,2* sum, n, y);
- x += dx;
- }
- Console.WriteLine("Построение завершено");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement