Last active
February 15, 2016 19:33
-
-
Save fotonmoton/f808c3351caa820be9b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace lab1 | |
{ | |
class Program | |
{ | |
public static double power(double x, double n) | |
{ | |
if (n == 0) | |
{ | |
return 1; | |
} | |
else | |
{ | |
return x * power(x, n - 1); | |
} | |
} | |
public static double arctan(double x, double n) | |
{ | |
if (n == 0) | |
{ | |
return x; | |
} | |
else | |
{ | |
return (power(-1, n) / (2 * n + 1) * power(x, 2 * n + 1)) + arctan(x, n - 1); | |
} | |
} | |
static void Main(string[] args) | |
{ | |
//double x, n, result, result1; | |
//Console.WriteLine("please input x for arctan(x)+arctan(1/x), e.g. '2'. x must be integer number."); | |
//x = double.Parse(Console.ReadLine()); | |
//Console.WriteLine("please input n to define calculation precision, number should be between 1 and 10"); | |
//n = double.Parse(Console.ReadLine()); | |
//result = arctan(x, n) + arctan(1 / x, n); | |
//Console.WriteLine("arctan(x)+arctan(1/x) equals to " + result); | |
//Console.WriteLine("arctan(x)+arctan(1/x) via embded function Math.Atan() equals to " + Math.Atan(x) + Math.Atan(1 / x)); | |
Console.WriteLine(arctan(0.2, 10)); | |
Console.WriteLine(Math.Atan(0.2)); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment