namespace GraphicsAndTaylorRows
static double f(double x) { return x <= 1 ? 1 : x * f(x - 1); }
public static double Taylor(double d,int i)
return (Math.Pow(d, i) / f(i)) * Math.Pow(-1, i);
static void Main(string[] args)
float x = float.Parse(Console.ReadLine());
Console.WriteLine($"X = {x}; Y = {-Math.Sqrt(9 - Math.Pow(x + 6, 2))}");
else if (x >= -6 && x < -3)
Console.WriteLine($"X = {x}; Y = {x + 3}");
else if (x >= -3 && x < 0)
Console.WriteLine($"X = {x}; Y = {Math.Sqrt(9 - x * x)}");
else if (x >= 0 && x < 3)
Console.WriteLine($"X = {x}; Y = {Math.Abs(x - 3)}");
else if (x >= 3 && x < 9)
Console.WriteLine($"X = {x}; Y = {x/2-3/2}");
for (double i = -2d; i <= 2d; i+=0.2d)
Console.WriteLine($"Y = {Math.Pow(Math.E,-i)}" + " X = " + i);
double correctness = Math.Pow(10, -6);
Console.WriteLine($"Математическая функция:\tРяд Тейлора:\tКоличество итераций:\t");
for (double i = -2d; i <= 2d; i+=0.2d)
y = Math.Pow(Math.E, -i);
while(row + correctness <= y)
row += Taylor(i,iteration);
row += Taylor(i, iteration);
Console.WriteLine($"{y}\t{row}\t{iteration-1}");