I'm writing a program, that calculates cos(1), using Taylor series. That would really be not that hard:
CODE
using System;
namespace TaylorSeriesCosOne
{
class Program
{
static void Main(string[] args)
{
double cosOne = 1;
int n = 2;
int factorial = 1;
double power = 1;
while (n <= 14)
{
power = power * -1;
factorial = factorial * n * (n - 1);
cosOne = cosOne + (power / factorial);
Console.WriteLine("n: {0} \tcosOne: {1}", n, cosOne);
n = n + 2;
}
Console.WriteLine("\ncos(1) = {0}", cosOne);
Console.ReadLine();
}
}
}
But... The problem: it's not really an accurate answer. And I want it to be a lot more accurate (more than 10^(-1000), for example). My first thought was to write HugeInteger and HugeDecimal classes (well, parts of them, that I would use in this program). I'm just not sure, if that's the easiest way to do it. I'm not in a hurry with this, so I thought, that I'll just post here and ask if anyone have any suggestions.