M
M
mpvcluuuuub2020-10-27 23:20:36
C++ / C#
mpvcluuuuub, 2020-10-27 23:20:36

Why does nan ind pop up when expanding the Fourier series?

I began to learn the pluses, such a task, to expand the function using the Fourier series, the accuracy is 0.0001.
The value of the function is found, but the row does not work5f9881118187b061957269.png

#include <iostream>
#include <cmath>

using namespace std;

void main() {
  setlocale(LC_ALL, "Russian");
  cout << "Введите значение аргумента: ";
  double x;
  cin >> x;
  const double pi = atan(1) * 4;
  double function = (pi - x) / 2;
  cout << "Значение функции: " << function << endl;
  double sum = 0;
  double i = 0;
  do {
    sum += sin(i * x) / i;
    i++;
  } while (abs(function - sum) > 0.0001);
  cout << "Значение суммы ряда по функции: " << sum;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-10-27
@mpvcluuuuub

Something does not add up in the task.
Let's take x = 0
F(0) = (π - 0) / 2 = π/2
Σ i = [1, ∞) (sin(i * 0) / i) = 0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question