private static double T2(double x) { double res = 0; double r = x * x; double cur = x; for (int i = 1; i <= Factorial.Expanded; i += 2) { if (i != 1) { cur *= r; } res += ((i - 1) % 4 == 0 ? 1 : -1) * cur * Factorial.Get(i); } return(res); }
private static double T1(double x) { double res = 0; double r = (x + Math.PI * 0.5) * (x + Math.PI * 0.5); double cur = 1; for (int i = 0; i <= Factorial.Expanded; i += 2) { if (i != 0) { cur *= r; } res += (i % 4 == 0 ? -1 : 1) * cur * Factorial.Get(i); } return(res); }
/// <summary> /// <see cref="Math.E"/>^x를 반환함 /// </summary> /// <returns></returns> public static double Exp(double x) { if (x == 0) { return(1); } if (x == 1) { return(Math.E); } double res = 1; int a = (int)Math.Round(x); double p = 1; double r = x - a; for (int n = 1; n <= Factorial.Expanded; ++n) { p *= r; res += p * Factorial.Get(n); } return(IntPow(Math.E, a) * res); }