using System;
namespace ConsoleApp1
{
internal static class Program
private static Tuple<double,int> F(double x)
double xs = x * x;
double result = 0.0;
double k1 = 1.0;
double k2 = 3.0;
double k3 = 4.0;
double nominator = xs;
double sign = -1.0;
double result2 = 1.0;
int n = 1;
while (Math.Abs(result - result2) > double.Epsilon)
++n;
result = result2;
var d = nominator / (k1 * k2 * k3);
result2 = result + sign * d;
nominator *= xs;
k1 += 1.0;
k2 += 1.0;
k3 += 1.0;
sign = -sign;
}
return Tuple.Create(result, n);
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
using System;
namespace ConsoleApp1
{
internal static class Program
{
private static Tuple<double,int> F(double x)
{
double xs = x * x;
double result = 0.0;
double k1 = 1.0;
double k2 = 3.0;
double k3 = 4.0;
double nominator = xs;
double sign = -1.0;
double result2 = 1.0;
int n = 1;
while (Math.Abs(result - result2) > double.Epsilon)
{
++n;
result = result2;
var d = nominator / (k1 * k2 * k3);
result2 = result + sign * d;
nominator *= xs;
k1 += 1.0;
k2 += 1.0;
k3 += 1.0;
sign = -sign;
}
return Tuple.Create(result, n);
}