A
A
Alexander2018-06-12 12:54:57
Mathematics
Alexander, 2018-06-12 12:54:57

Calculating an infinite Taylor series?

Please help me with a solution.
Develop an algorithm and write a program to calculate and display in the form of a table the value of a function given using an infinite Taylor series on the interval from xini to xend with a step of dx with an accuracy of ε. Give the table a title and a header. Each line must contain the value of the argument, the value of the function, and the number of summed terms in the series.
5b1f981e3117b686888253.png
So far everything I've posted:

#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <cmath>
#include <iomanip> 
using namespace std;

int main(int argc, char **argv)
{
  int n, i, k;
  float xn, xk, dx, eps, x, a, s;
  cout << "xn = "; std::cin >> xn;
  cout << "xk = "; std::cin >> xk;
  cout << "dx = "; std::cin >> dx;
  cout << " e = "; std::cin >> eps;

  cout << "      Raschet" << endl;
  cout << setw(10) << "x" << setw(10) << "y" << setw(10) << "n" << endl;
  cout << "------------------------------------" << endl;
  k = round(1.0*(xk - xn) / dx + 1);
  for (i = 1; i <= k; i++)
  {
  x = x0 + (i - 1)*dx; 
  a = 0.5*x;
  s = a;
  n = 1;
  while (fabs(a)>e)
  {
    n = n + 1;
    ???
    s = s + a;
  }
    cout << setw(10) << x << setw(10) << s << setw(10) << n << endl;
  }

  system("pause");
  return 0;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Farwisdomer, 2018-06-12
@Farwisdomer

You didn't throw anything. On this resource, the task will not be solved for you.

I
Ivan Klimenko, 2018-06-15
@yeswell

Derive the formula for the nth term of the series. This is the whole task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question