Answer the question
In order to leave comments, you need to log in
How many terms of the Fourier series must be used to approximate?
It is necessary to research the convergence of the Fourier series in cosines, for this function
F(x)=1-x;
segment from 0 to 1
And determine how many terms of the Fourier series must be used to approximate the function at the ends of the segment and in the region of the middle of the segment?
How to determine this number of members of the series?
I already asked this question, but I did not understand the last point. I
wrote a program that calculates the Fourier series for this function.
Is it possible to subtract the values of the Fourier series with a different number of terms from the values of the function to determine the exact value of the error and find the maximum difference obtained? will this be the solution?
#include "math.h"
#include "conio.h"
#include "stdlib.h"
#include "iostream"
#include <fstream>
using namespace std;
double const pi = 3.14159;
double koef_An(double a, double b, double c)
{
double n;
double T = 0;
for (n = 1; n <= c; n+=2) {
T += 2/((pi*pi)*((2*n-1)*(2*n-1)));
cout << "koef An= " << T << endl;
}
return(T);
}
void main()
{
//f(x)=1-х на отрезке от 0 до 1
double a = 0;
double b = 1;
double c = 3;// кол - во n, для четных n(n = 2k) имеем an = 0, для нечетных(n = 2k - 1)
double X = 0;
double An;
double A0 = 1;//Для этих данных а0=1
double fx;
cout << " A0= " << A0 << endl;
//ofstream myfile;
//myfile.open("data.txt");
for (double X = 0; X <= 1; X += 0.1)
{
for (int k = 1; k <= c; k += 2)
{
fx = koef_An(a, b, k)*cos(pi*(2 * k - 1)*X);
//cout<<"k= "<<k<<" l= "<<l<<" Ak="<<Ak<<endl;
fx += 0.5;
//myfile << X << " " << fx<<"\n";
cout << "fx=" << fx << endl;
}
cout << "-------------------------------" << " X=" << X << endl;
}
//myfile.close();
_getch();
}
Answer the question
In order to leave comments, you need to log in
The series converges in
1) Dalambard if lim ( a[n+1] / a[n] ) < 1 for n-> ∞
2) Cauchy if lim (sqr(a[n], 1/n)) for n -> ∞
You can try to calculate the limit
If you estimate the convergence approximately numerically, you can check that each term of the series is less than the previous one. Check either up to a certain number n, or until the accuracy falls below some value.
You make a function that calculates the difference between the value of the function at a point and its expansion depending on n. As soon as this difference < ε (specified accuracy) then this amount is enough.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question