Computing $sum_{n = 1}^{+ infty} frac{1}{n^2 + 1}$ using Fourier series.
$begingroup$
$f$ is a $2 pi$ periodic function on $ ] - pi,pi[$ defined as :
$$f(x) = e^{-x}$$
Using Fourier series, compute the sums :
$$ sum_{n = 1}^{+ infty} frac{1}{n^2 + 1} , sum_{- infty}^{+ infty} frac{1}{n^2 + 1} $$
How do I compute $sum_{n = 1}^{+ infty} frac{1}{n^2 + 1}$ ?
I have computed the fourier coefficient and found that:
$$a_0 = frac{2}{pi} (1 - e^{- pi}) $$
$$a_n = frac{2}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) $$
$$b_n = frac{2n}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) $$
Using Dirichlet theorem and taking $x = 0$ to make the $b_n$ disappear, I get:
$$S_f (1) = frac{2}{pi} (1 - e^{- pi}) + sum_{n = 1}^{+ infty} frac{2}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) . (-1)^n = 1 $$
I do not see how to proceed to get the value of the sum?
The same problem for the second sum.
real-analysis sequences-and-series fourier-analysis fourier-series
$endgroup$
|
show 6 more comments
$begingroup$
$f$ is a $2 pi$ periodic function on $ ] - pi,pi[$ defined as :
$$f(x) = e^{-x}$$
Using Fourier series, compute the sums :
$$ sum_{n = 1}^{+ infty} frac{1}{n^2 + 1} , sum_{- infty}^{+ infty} frac{1}{n^2 + 1} $$
How do I compute $sum_{n = 1}^{+ infty} frac{1}{n^2 + 1}$ ?
I have computed the fourier coefficient and found that:
$$a_0 = frac{2}{pi} (1 - e^{- pi}) $$
$$a_n = frac{2}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) $$
$$b_n = frac{2n}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) $$
Using Dirichlet theorem and taking $x = 0$ to make the $b_n$ disappear, I get:
$$S_f (1) = frac{2}{pi} (1 - e^{- pi}) + sum_{n = 1}^{+ infty} frac{2}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) . (-1)^n = 1 $$
I do not see how to proceed to get the value of the sum?
The same problem for the second sum.
real-analysis sequences-and-series fourier-analysis fourier-series
$endgroup$
1
$begingroup$
"same problem for the second sum" - not exactly; once you find the first sum, multiply it by $2$ and add $1$.
$endgroup$
– user170231
Jan 30 at 16:20
$begingroup$
@user170231 Thank you. I'm still stuck with the first sun though.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:21
1
$begingroup$
Your coefficients are not correct: $$a_0=frac1piint_{-pi}^pi e^{-x},mathrm dx=frac{e^pi-e^{-pi}}pi=frac{2sinhpi}pi$$ Similarly you should have ended up with $$a_n=frac{2(-1)^nsinhpi}{pi(n^2+1)}text{ and }b_n=frac{2n(-1)^nsinhpi}{pi(n^2+1)}$$ I think you are just missing a factor of $e^pi$ in certain places. (NB: $2sinhpi=e^pi-e^{-pi}$.)
$endgroup$
– user170231
Jan 30 at 17:04
$begingroup$
@user170231 To compute the coefficients, I used the formula: $$ a_n = frac{2}{pi} int_{0}^{pi} f(x) cos (nx)$$ and : $$ b_n = frac{2}{pi} int_{0}^{pi} f(x) sin (nx)$$ Isn't it correct?
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 17:18
1
$begingroup$
The formula I cited specifically works only for functions that are $2pi$-periodic over the interval $(-pi,pi)$. There is a formula for $P$-periodic functions over the interval $(x_0,x_0+P)$ listed on the page I linked under the section "A more general definition" (Eq. 4) for the more general case. It suggests$$a_n=frac2piint_0^pi f(x)cos nx,mathrm dx$$works for a function $f(x)$ that is $pi$-periodic over $(0,pi)$.
$endgroup$
– user170231
Jan 30 at 18:33
|
show 6 more comments
$begingroup$
$f$ is a $2 pi$ periodic function on $ ] - pi,pi[$ defined as :
$$f(x) = e^{-x}$$
Using Fourier series, compute the sums :
$$ sum_{n = 1}^{+ infty} frac{1}{n^2 + 1} , sum_{- infty}^{+ infty} frac{1}{n^2 + 1} $$
How do I compute $sum_{n = 1}^{+ infty} frac{1}{n^2 + 1}$ ?
I have computed the fourier coefficient and found that:
$$a_0 = frac{2}{pi} (1 - e^{- pi}) $$
$$a_n = frac{2}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) $$
$$b_n = frac{2n}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) $$
Using Dirichlet theorem and taking $x = 0$ to make the $b_n$ disappear, I get:
$$S_f (1) = frac{2}{pi} (1 - e^{- pi}) + sum_{n = 1}^{+ infty} frac{2}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) . (-1)^n = 1 $$
I do not see how to proceed to get the value of the sum?
The same problem for the second sum.
real-analysis sequences-and-series fourier-analysis fourier-series
$endgroup$
$f$ is a $2 pi$ periodic function on $ ] - pi,pi[$ defined as :
$$f(x) = e^{-x}$$
Using Fourier series, compute the sums :
$$ sum_{n = 1}^{+ infty} frac{1}{n^2 + 1} , sum_{- infty}^{+ infty} frac{1}{n^2 + 1} $$
How do I compute $sum_{n = 1}^{+ infty} frac{1}{n^2 + 1}$ ?
I have computed the fourier coefficient and found that:
$$a_0 = frac{2}{pi} (1 - e^{- pi}) $$
$$a_n = frac{2}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) $$
$$b_n = frac{2n}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) $$
Using Dirichlet theorem and taking $x = 0$ to make the $b_n$ disappear, I get:
$$S_f (1) = frac{2}{pi} (1 - e^{- pi}) + sum_{n = 1}^{+ infty} frac{2}{pi(n^2 + 1)} (1 - (-1)^n . e^{- pi} ) . (-1)^n = 1 $$
I do not see how to proceed to get the value of the sum?
The same problem for the second sum.
real-analysis sequences-and-series fourier-analysis fourier-series
real-analysis sequences-and-series fourier-analysis fourier-series
asked Jan 30 at 15:45
Zouhair El YaagoubiZouhair El Yaagoubi
538411
538411
1
$begingroup$
"same problem for the second sum" - not exactly; once you find the first sum, multiply it by $2$ and add $1$.
$endgroup$
– user170231
Jan 30 at 16:20
$begingroup$
@user170231 Thank you. I'm still stuck with the first sun though.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:21
1
$begingroup$
Your coefficients are not correct: $$a_0=frac1piint_{-pi}^pi e^{-x},mathrm dx=frac{e^pi-e^{-pi}}pi=frac{2sinhpi}pi$$ Similarly you should have ended up with $$a_n=frac{2(-1)^nsinhpi}{pi(n^2+1)}text{ and }b_n=frac{2n(-1)^nsinhpi}{pi(n^2+1)}$$ I think you are just missing a factor of $e^pi$ in certain places. (NB: $2sinhpi=e^pi-e^{-pi}$.)
$endgroup$
– user170231
Jan 30 at 17:04
$begingroup$
@user170231 To compute the coefficients, I used the formula: $$ a_n = frac{2}{pi} int_{0}^{pi} f(x) cos (nx)$$ and : $$ b_n = frac{2}{pi} int_{0}^{pi} f(x) sin (nx)$$ Isn't it correct?
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 17:18
1
$begingroup$
The formula I cited specifically works only for functions that are $2pi$-periodic over the interval $(-pi,pi)$. There is a formula for $P$-periodic functions over the interval $(x_0,x_0+P)$ listed on the page I linked under the section "A more general definition" (Eq. 4) for the more general case. It suggests$$a_n=frac2piint_0^pi f(x)cos nx,mathrm dx$$works for a function $f(x)$ that is $pi$-periodic over $(0,pi)$.
$endgroup$
– user170231
Jan 30 at 18:33
|
show 6 more comments
1
$begingroup$
"same problem for the second sum" - not exactly; once you find the first sum, multiply it by $2$ and add $1$.
$endgroup$
– user170231
Jan 30 at 16:20
$begingroup$
@user170231 Thank you. I'm still stuck with the first sun though.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:21
1
$begingroup$
Your coefficients are not correct: $$a_0=frac1piint_{-pi}^pi e^{-x},mathrm dx=frac{e^pi-e^{-pi}}pi=frac{2sinhpi}pi$$ Similarly you should have ended up with $$a_n=frac{2(-1)^nsinhpi}{pi(n^2+1)}text{ and }b_n=frac{2n(-1)^nsinhpi}{pi(n^2+1)}$$ I think you are just missing a factor of $e^pi$ in certain places. (NB: $2sinhpi=e^pi-e^{-pi}$.)
$endgroup$
– user170231
Jan 30 at 17:04
$begingroup$
@user170231 To compute the coefficients, I used the formula: $$ a_n = frac{2}{pi} int_{0}^{pi} f(x) cos (nx)$$ and : $$ b_n = frac{2}{pi} int_{0}^{pi} f(x) sin (nx)$$ Isn't it correct?
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 17:18
1
$begingroup$
The formula I cited specifically works only for functions that are $2pi$-periodic over the interval $(-pi,pi)$. There is a formula for $P$-periodic functions over the interval $(x_0,x_0+P)$ listed on the page I linked under the section "A more general definition" (Eq. 4) for the more general case. It suggests$$a_n=frac2piint_0^pi f(x)cos nx,mathrm dx$$works for a function $f(x)$ that is $pi$-periodic over $(0,pi)$.
$endgroup$
– user170231
Jan 30 at 18:33
1
1
$begingroup$
"same problem for the second sum" - not exactly; once you find the first sum, multiply it by $2$ and add $1$.
$endgroup$
– user170231
Jan 30 at 16:20
$begingroup$
"same problem for the second sum" - not exactly; once you find the first sum, multiply it by $2$ and add $1$.
$endgroup$
– user170231
Jan 30 at 16:20
$begingroup$
@user170231 Thank you. I'm still stuck with the first sun though.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:21
$begingroup$
@user170231 Thank you. I'm still stuck with the first sun though.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:21
1
1
$begingroup$
Your coefficients are not correct: $$a_0=frac1piint_{-pi}^pi e^{-x},mathrm dx=frac{e^pi-e^{-pi}}pi=frac{2sinhpi}pi$$ Similarly you should have ended up with $$a_n=frac{2(-1)^nsinhpi}{pi(n^2+1)}text{ and }b_n=frac{2n(-1)^nsinhpi}{pi(n^2+1)}$$ I think you are just missing a factor of $e^pi$ in certain places. (NB: $2sinhpi=e^pi-e^{-pi}$.)
$endgroup$
– user170231
Jan 30 at 17:04
$begingroup$
Your coefficients are not correct: $$a_0=frac1piint_{-pi}^pi e^{-x},mathrm dx=frac{e^pi-e^{-pi}}pi=frac{2sinhpi}pi$$ Similarly you should have ended up with $$a_n=frac{2(-1)^nsinhpi}{pi(n^2+1)}text{ and }b_n=frac{2n(-1)^nsinhpi}{pi(n^2+1)}$$ I think you are just missing a factor of $e^pi$ in certain places. (NB: $2sinhpi=e^pi-e^{-pi}$.)
$endgroup$
– user170231
Jan 30 at 17:04
$begingroup$
@user170231 To compute the coefficients, I used the formula: $$ a_n = frac{2}{pi} int_{0}^{pi} f(x) cos (nx)$$ and : $$ b_n = frac{2}{pi} int_{0}^{pi} f(x) sin (nx)$$ Isn't it correct?
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 17:18
$begingroup$
@user170231 To compute the coefficients, I used the formula: $$ a_n = frac{2}{pi} int_{0}^{pi} f(x) cos (nx)$$ and : $$ b_n = frac{2}{pi} int_{0}^{pi} f(x) sin (nx)$$ Isn't it correct?
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 17:18
1
1
$begingroup$
The formula I cited specifically works only for functions that are $2pi$-periodic over the interval $(-pi,pi)$. There is a formula for $P$-periodic functions over the interval $(x_0,x_0+P)$ listed on the page I linked under the section "A more general definition" (Eq. 4) for the more general case. It suggests$$a_n=frac2piint_0^pi f(x)cos nx,mathrm dx$$works for a function $f(x)$ that is $pi$-periodic over $(0,pi)$.
$endgroup$
– user170231
Jan 30 at 18:33
$begingroup$
The formula I cited specifically works only for functions that are $2pi$-periodic over the interval $(-pi,pi)$. There is a formula for $P$-periodic functions over the interval $(x_0,x_0+P)$ listed on the page I linked under the section "A more general definition" (Eq. 4) for the more general case. It suggests$$a_n=frac2piint_0^pi f(x)cos nx,mathrm dx$$works for a function $f(x)$ that is $pi$-periodic over $(0,pi)$.
$endgroup$
– user170231
Jan 30 at 18:33
|
show 6 more comments
3 Answers
3
active
oldest
votes
$begingroup$
With the correct coefficients (see comments), you have for $x in]-pi,pi[$:
$$
e^{-x} = frac{2}{pi} sinh(pi) + 2 sinh(pi) sum_{n=1}^{infty}frac{ (-1)^n (nsin (nx) + cos(nx)) }{pi(n^2 + 1)}
$$
so
$$
e^{x} + e^{-x} = frac{4}{pi} sinh(pi) + 4 sinh(pi) sum_{n=1}^{infty}frac{ (-1)^n cos(nx) }{pi(n^2 + 1)}
$$
Now we can evaluate this for $x to pmpi$. To be more precise (see the answer by @kvantour), the evaluation $x to pmpi$ corresponds to the average of the two values at $pmpi$ which is exactly what the Fourier series converges to at this point of discontinuity.
$$
cosh (pm pi) = frac{2}{pi} sinh(pi)+ 2 sinh(pi) sum_{n=1}^{infty}frac{1 }{pi(n^2 + 1)}
$$
and in turn
$$
sum_{n=1}^{infty}frac{1 }{(n^2 + 1)} = frac{pi coth(pi) -1}{2 }
$$
Then the second question follows:
$$
sum_{- infty}^{+ infty} frac{1}{n^2 + 1} = 1 + 2 sum_{1}^{+ infty} frac{1}{n^2 + 1} = pi coth(pi) simeq 1.0037 ; pi
$$
Comment: for comparison,
$$
int_{- infty}^{+ infty} frac{1}{x^2 + 1} {rm{dx}} = pi
$$
$endgroup$
1
$begingroup$
You cannot make the statement $xrightarrowpi$ and just know its value. $f(x)$ is discontinuous in that point.
$endgroup$
– kvantour
Jan 31 at 11:52
1
$begingroup$
@kvantour Thank you. I have adressed that point and edited my answer accordingly.
$endgroup$
– Andreas
Jan 31 at 15:13
1
$begingroup$
Good point. done.
$endgroup$
– Andreas
Jan 31 at 15:25
add a comment |
$begingroup$
When you state Using Fourier series, it does not necessarily mean that you have to use the Fourier Cosine and Sine series. You can also write it in exponential form:
Any periodic function $tilde{f}(t)$ with period $2pi$ can be written
as:
$$ f(t) = sum_{n=-infty}^infty c_n,e^{int} $$ with $$
c_n=frac{1}{2pi}int_{-pi}^pi tilde f(t),e^{-int},textrm{d}t
$$
note: we make a distinction between the fourier series $f(t)$ and the periodic function $tilde f(t)$ to indicate that they are different when $tilde f(t)$ is discontiniuous.
When you apply this for $tilde f(t)$, which is periodic over $2pi$, discontinuous and defined in the region $]-pi,pi[$ as $exp(-t)$, you obtain
$$
c_n = frac{sinh(pi)}picdotfrac{(-1)^n,(1-in)}{1+n^2}
$$
giving you:
$$
f(t)=frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{(-1)^n,(1-in)}{1+n^2},e^{int}
$$
You already notice the familiar part in the sum which is of interest, the problem is the $(-1)^n$. This we can get rid of with the proper choice of $t$. If $t=pmpi$ then $exp(pm inpi)=(-1)^n$. But be advised $f(t)$ is periodic with a period of $2pi$ and is not continuous in the points $t=npi$. The value the Fourier Series will return is:
$$ f(pi)=f(-pi)= frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{(1-in)}{1+n^2} = frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{1}{1+n^2}$$
The latter reduction of the sum is straightforward as the imaginary part is zero.
But we cannot use this, as we do not know what $f(pi)$ is since $tilde f(t)$ is discontinuous at these points. Luckily, some smart people solved this conundrum and showed that at a discontinuity, the Fourier series converges to the average of the two values, i.e.
$$ f(pi)=f(-pi)=frac{lim_{trightarrowpi^-}tilde f(t) + lim_{trightarrow pi^+}tilde f(t)}{2} = frac{exp(-pi)+exp(pi)}{2} = cosh(pi)$$
See: Fourier series at discontinuities
So in the end, we have the solution:
$$f(pi)=cosh(pi)=frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{1}{1+n^2}$$
or
$$bbox[5px,border:2px solid #00A000]{pi coth(pi)=sum_{n=-infty}^inftyfrac{1}{1+n^2}=1+2sum_{n=1}^inftyfrac{1}{1+n^2}}$$
remark: computing $f(0)$ gives directly, without any fuss:
$$bbox[5px,border:2px solid #000000]{frac{pi}{sinh(pi)}=sum_{n=-infty}^inftyfrac{(-1)^n}{1+n^2}}$$
$endgroup$
1
$begingroup$
I computed the sum using $f(0)$, but I will pay more attention to the points of discontinuity, so thank you so much for your additional important information.
$endgroup$
– Zouhair El Yaagoubi
Jan 31 at 12:11
add a comment |
$begingroup$
Try using Parseval's theorem,
$$frac{1}{pi}int_{-pi}^pi |f(x)|^2 dx = frac{a_0}{2} + sum_{n=1}^{infty} a_n^2+b_n^2$$
If it comes out too nasty, then I think your coeffecients might be off.
$endgroup$
$begingroup$
I do not see how Parseval's theorem will give me the sum, can you elaborate more? Although, I have checked the coefficient well. They seem to be correct.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:12
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3093698%2fcomputing-sum-n-1-infty-frac1n2-1-using-fourier-series%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
With the correct coefficients (see comments), you have for $x in]-pi,pi[$:
$$
e^{-x} = frac{2}{pi} sinh(pi) + 2 sinh(pi) sum_{n=1}^{infty}frac{ (-1)^n (nsin (nx) + cos(nx)) }{pi(n^2 + 1)}
$$
so
$$
e^{x} + e^{-x} = frac{4}{pi} sinh(pi) + 4 sinh(pi) sum_{n=1}^{infty}frac{ (-1)^n cos(nx) }{pi(n^2 + 1)}
$$
Now we can evaluate this for $x to pmpi$. To be more precise (see the answer by @kvantour), the evaluation $x to pmpi$ corresponds to the average of the two values at $pmpi$ which is exactly what the Fourier series converges to at this point of discontinuity.
$$
cosh (pm pi) = frac{2}{pi} sinh(pi)+ 2 sinh(pi) sum_{n=1}^{infty}frac{1 }{pi(n^2 + 1)}
$$
and in turn
$$
sum_{n=1}^{infty}frac{1 }{(n^2 + 1)} = frac{pi coth(pi) -1}{2 }
$$
Then the second question follows:
$$
sum_{- infty}^{+ infty} frac{1}{n^2 + 1} = 1 + 2 sum_{1}^{+ infty} frac{1}{n^2 + 1} = pi coth(pi) simeq 1.0037 ; pi
$$
Comment: for comparison,
$$
int_{- infty}^{+ infty} frac{1}{x^2 + 1} {rm{dx}} = pi
$$
$endgroup$
1
$begingroup$
You cannot make the statement $xrightarrowpi$ and just know its value. $f(x)$ is discontinuous in that point.
$endgroup$
– kvantour
Jan 31 at 11:52
1
$begingroup$
@kvantour Thank you. I have adressed that point and edited my answer accordingly.
$endgroup$
– Andreas
Jan 31 at 15:13
1
$begingroup$
Good point. done.
$endgroup$
– Andreas
Jan 31 at 15:25
add a comment |
$begingroup$
With the correct coefficients (see comments), you have for $x in]-pi,pi[$:
$$
e^{-x} = frac{2}{pi} sinh(pi) + 2 sinh(pi) sum_{n=1}^{infty}frac{ (-1)^n (nsin (nx) + cos(nx)) }{pi(n^2 + 1)}
$$
so
$$
e^{x} + e^{-x} = frac{4}{pi} sinh(pi) + 4 sinh(pi) sum_{n=1}^{infty}frac{ (-1)^n cos(nx) }{pi(n^2 + 1)}
$$
Now we can evaluate this for $x to pmpi$. To be more precise (see the answer by @kvantour), the evaluation $x to pmpi$ corresponds to the average of the two values at $pmpi$ which is exactly what the Fourier series converges to at this point of discontinuity.
$$
cosh (pm pi) = frac{2}{pi} sinh(pi)+ 2 sinh(pi) sum_{n=1}^{infty}frac{1 }{pi(n^2 + 1)}
$$
and in turn
$$
sum_{n=1}^{infty}frac{1 }{(n^2 + 1)} = frac{pi coth(pi) -1}{2 }
$$
Then the second question follows:
$$
sum_{- infty}^{+ infty} frac{1}{n^2 + 1} = 1 + 2 sum_{1}^{+ infty} frac{1}{n^2 + 1} = pi coth(pi) simeq 1.0037 ; pi
$$
Comment: for comparison,
$$
int_{- infty}^{+ infty} frac{1}{x^2 + 1} {rm{dx}} = pi
$$
$endgroup$
1
$begingroup$
You cannot make the statement $xrightarrowpi$ and just know its value. $f(x)$ is discontinuous in that point.
$endgroup$
– kvantour
Jan 31 at 11:52
1
$begingroup$
@kvantour Thank you. I have adressed that point and edited my answer accordingly.
$endgroup$
– Andreas
Jan 31 at 15:13
1
$begingroup$
Good point. done.
$endgroup$
– Andreas
Jan 31 at 15:25
add a comment |
$begingroup$
With the correct coefficients (see comments), you have for $x in]-pi,pi[$:
$$
e^{-x} = frac{2}{pi} sinh(pi) + 2 sinh(pi) sum_{n=1}^{infty}frac{ (-1)^n (nsin (nx) + cos(nx)) }{pi(n^2 + 1)}
$$
so
$$
e^{x} + e^{-x} = frac{4}{pi} sinh(pi) + 4 sinh(pi) sum_{n=1}^{infty}frac{ (-1)^n cos(nx) }{pi(n^2 + 1)}
$$
Now we can evaluate this for $x to pmpi$. To be more precise (see the answer by @kvantour), the evaluation $x to pmpi$ corresponds to the average of the two values at $pmpi$ which is exactly what the Fourier series converges to at this point of discontinuity.
$$
cosh (pm pi) = frac{2}{pi} sinh(pi)+ 2 sinh(pi) sum_{n=1}^{infty}frac{1 }{pi(n^2 + 1)}
$$
and in turn
$$
sum_{n=1}^{infty}frac{1 }{(n^2 + 1)} = frac{pi coth(pi) -1}{2 }
$$
Then the second question follows:
$$
sum_{- infty}^{+ infty} frac{1}{n^2 + 1} = 1 + 2 sum_{1}^{+ infty} frac{1}{n^2 + 1} = pi coth(pi) simeq 1.0037 ; pi
$$
Comment: for comparison,
$$
int_{- infty}^{+ infty} frac{1}{x^2 + 1} {rm{dx}} = pi
$$
$endgroup$
With the correct coefficients (see comments), you have for $x in]-pi,pi[$:
$$
e^{-x} = frac{2}{pi} sinh(pi) + 2 sinh(pi) sum_{n=1}^{infty}frac{ (-1)^n (nsin (nx) + cos(nx)) }{pi(n^2 + 1)}
$$
so
$$
e^{x} + e^{-x} = frac{4}{pi} sinh(pi) + 4 sinh(pi) sum_{n=1}^{infty}frac{ (-1)^n cos(nx) }{pi(n^2 + 1)}
$$
Now we can evaluate this for $x to pmpi$. To be more precise (see the answer by @kvantour), the evaluation $x to pmpi$ corresponds to the average of the two values at $pmpi$ which is exactly what the Fourier series converges to at this point of discontinuity.
$$
cosh (pm pi) = frac{2}{pi} sinh(pi)+ 2 sinh(pi) sum_{n=1}^{infty}frac{1 }{pi(n^2 + 1)}
$$
and in turn
$$
sum_{n=1}^{infty}frac{1 }{(n^2 + 1)} = frac{pi coth(pi) -1}{2 }
$$
Then the second question follows:
$$
sum_{- infty}^{+ infty} frac{1}{n^2 + 1} = 1 + 2 sum_{1}^{+ infty} frac{1}{n^2 + 1} = pi coth(pi) simeq 1.0037 ; pi
$$
Comment: for comparison,
$$
int_{- infty}^{+ infty} frac{1}{x^2 + 1} {rm{dx}} = pi
$$
edited Jan 31 at 15:25
answered Jan 30 at 17:48
AndreasAndreas
8,4161137
8,4161137
1
$begingroup$
You cannot make the statement $xrightarrowpi$ and just know its value. $f(x)$ is discontinuous in that point.
$endgroup$
– kvantour
Jan 31 at 11:52
1
$begingroup$
@kvantour Thank you. I have adressed that point and edited my answer accordingly.
$endgroup$
– Andreas
Jan 31 at 15:13
1
$begingroup$
Good point. done.
$endgroup$
– Andreas
Jan 31 at 15:25
add a comment |
1
$begingroup$
You cannot make the statement $xrightarrowpi$ and just know its value. $f(x)$ is discontinuous in that point.
$endgroup$
– kvantour
Jan 31 at 11:52
1
$begingroup$
@kvantour Thank you. I have adressed that point and edited my answer accordingly.
$endgroup$
– Andreas
Jan 31 at 15:13
1
$begingroup$
Good point. done.
$endgroup$
– Andreas
Jan 31 at 15:25
1
1
$begingroup$
You cannot make the statement $xrightarrowpi$ and just know its value. $f(x)$ is discontinuous in that point.
$endgroup$
– kvantour
Jan 31 at 11:52
$begingroup$
You cannot make the statement $xrightarrowpi$ and just know its value. $f(x)$ is discontinuous in that point.
$endgroup$
– kvantour
Jan 31 at 11:52
1
1
$begingroup$
@kvantour Thank you. I have adressed that point and edited my answer accordingly.
$endgroup$
– Andreas
Jan 31 at 15:13
$begingroup$
@kvantour Thank you. I have adressed that point and edited my answer accordingly.
$endgroup$
– Andreas
Jan 31 at 15:13
1
1
$begingroup$
Good point. done.
$endgroup$
– Andreas
Jan 31 at 15:25
$begingroup$
Good point. done.
$endgroup$
– Andreas
Jan 31 at 15:25
add a comment |
$begingroup$
When you state Using Fourier series, it does not necessarily mean that you have to use the Fourier Cosine and Sine series. You can also write it in exponential form:
Any periodic function $tilde{f}(t)$ with period $2pi$ can be written
as:
$$ f(t) = sum_{n=-infty}^infty c_n,e^{int} $$ with $$
c_n=frac{1}{2pi}int_{-pi}^pi tilde f(t),e^{-int},textrm{d}t
$$
note: we make a distinction between the fourier series $f(t)$ and the periodic function $tilde f(t)$ to indicate that they are different when $tilde f(t)$ is discontiniuous.
When you apply this for $tilde f(t)$, which is periodic over $2pi$, discontinuous and defined in the region $]-pi,pi[$ as $exp(-t)$, you obtain
$$
c_n = frac{sinh(pi)}picdotfrac{(-1)^n,(1-in)}{1+n^2}
$$
giving you:
$$
f(t)=frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{(-1)^n,(1-in)}{1+n^2},e^{int}
$$
You already notice the familiar part in the sum which is of interest, the problem is the $(-1)^n$. This we can get rid of with the proper choice of $t$. If $t=pmpi$ then $exp(pm inpi)=(-1)^n$. But be advised $f(t)$ is periodic with a period of $2pi$ and is not continuous in the points $t=npi$. The value the Fourier Series will return is:
$$ f(pi)=f(-pi)= frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{(1-in)}{1+n^2} = frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{1}{1+n^2}$$
The latter reduction of the sum is straightforward as the imaginary part is zero.
But we cannot use this, as we do not know what $f(pi)$ is since $tilde f(t)$ is discontinuous at these points. Luckily, some smart people solved this conundrum and showed that at a discontinuity, the Fourier series converges to the average of the two values, i.e.
$$ f(pi)=f(-pi)=frac{lim_{trightarrowpi^-}tilde f(t) + lim_{trightarrow pi^+}tilde f(t)}{2} = frac{exp(-pi)+exp(pi)}{2} = cosh(pi)$$
See: Fourier series at discontinuities
So in the end, we have the solution:
$$f(pi)=cosh(pi)=frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{1}{1+n^2}$$
or
$$bbox[5px,border:2px solid #00A000]{pi coth(pi)=sum_{n=-infty}^inftyfrac{1}{1+n^2}=1+2sum_{n=1}^inftyfrac{1}{1+n^2}}$$
remark: computing $f(0)$ gives directly, without any fuss:
$$bbox[5px,border:2px solid #000000]{frac{pi}{sinh(pi)}=sum_{n=-infty}^inftyfrac{(-1)^n}{1+n^2}}$$
$endgroup$
1
$begingroup$
I computed the sum using $f(0)$, but I will pay more attention to the points of discontinuity, so thank you so much for your additional important information.
$endgroup$
– Zouhair El Yaagoubi
Jan 31 at 12:11
add a comment |
$begingroup$
When you state Using Fourier series, it does not necessarily mean that you have to use the Fourier Cosine and Sine series. You can also write it in exponential form:
Any periodic function $tilde{f}(t)$ with period $2pi$ can be written
as:
$$ f(t) = sum_{n=-infty}^infty c_n,e^{int} $$ with $$
c_n=frac{1}{2pi}int_{-pi}^pi tilde f(t),e^{-int},textrm{d}t
$$
note: we make a distinction between the fourier series $f(t)$ and the periodic function $tilde f(t)$ to indicate that they are different when $tilde f(t)$ is discontiniuous.
When you apply this for $tilde f(t)$, which is periodic over $2pi$, discontinuous and defined in the region $]-pi,pi[$ as $exp(-t)$, you obtain
$$
c_n = frac{sinh(pi)}picdotfrac{(-1)^n,(1-in)}{1+n^2}
$$
giving you:
$$
f(t)=frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{(-1)^n,(1-in)}{1+n^2},e^{int}
$$
You already notice the familiar part in the sum which is of interest, the problem is the $(-1)^n$. This we can get rid of with the proper choice of $t$. If $t=pmpi$ then $exp(pm inpi)=(-1)^n$. But be advised $f(t)$ is periodic with a period of $2pi$ and is not continuous in the points $t=npi$. The value the Fourier Series will return is:
$$ f(pi)=f(-pi)= frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{(1-in)}{1+n^2} = frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{1}{1+n^2}$$
The latter reduction of the sum is straightforward as the imaginary part is zero.
But we cannot use this, as we do not know what $f(pi)$ is since $tilde f(t)$ is discontinuous at these points. Luckily, some smart people solved this conundrum and showed that at a discontinuity, the Fourier series converges to the average of the two values, i.e.
$$ f(pi)=f(-pi)=frac{lim_{trightarrowpi^-}tilde f(t) + lim_{trightarrow pi^+}tilde f(t)}{2} = frac{exp(-pi)+exp(pi)}{2} = cosh(pi)$$
See: Fourier series at discontinuities
So in the end, we have the solution:
$$f(pi)=cosh(pi)=frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{1}{1+n^2}$$
or
$$bbox[5px,border:2px solid #00A000]{pi coth(pi)=sum_{n=-infty}^inftyfrac{1}{1+n^2}=1+2sum_{n=1}^inftyfrac{1}{1+n^2}}$$
remark: computing $f(0)$ gives directly, without any fuss:
$$bbox[5px,border:2px solid #000000]{frac{pi}{sinh(pi)}=sum_{n=-infty}^inftyfrac{(-1)^n}{1+n^2}}$$
$endgroup$
1
$begingroup$
I computed the sum using $f(0)$, but I will pay more attention to the points of discontinuity, so thank you so much for your additional important information.
$endgroup$
– Zouhair El Yaagoubi
Jan 31 at 12:11
add a comment |
$begingroup$
When you state Using Fourier series, it does not necessarily mean that you have to use the Fourier Cosine and Sine series. You can also write it in exponential form:
Any periodic function $tilde{f}(t)$ with period $2pi$ can be written
as:
$$ f(t) = sum_{n=-infty}^infty c_n,e^{int} $$ with $$
c_n=frac{1}{2pi}int_{-pi}^pi tilde f(t),e^{-int},textrm{d}t
$$
note: we make a distinction between the fourier series $f(t)$ and the periodic function $tilde f(t)$ to indicate that they are different when $tilde f(t)$ is discontiniuous.
When you apply this for $tilde f(t)$, which is periodic over $2pi$, discontinuous and defined in the region $]-pi,pi[$ as $exp(-t)$, you obtain
$$
c_n = frac{sinh(pi)}picdotfrac{(-1)^n,(1-in)}{1+n^2}
$$
giving you:
$$
f(t)=frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{(-1)^n,(1-in)}{1+n^2},e^{int}
$$
You already notice the familiar part in the sum which is of interest, the problem is the $(-1)^n$. This we can get rid of with the proper choice of $t$. If $t=pmpi$ then $exp(pm inpi)=(-1)^n$. But be advised $f(t)$ is periodic with a period of $2pi$ and is not continuous in the points $t=npi$. The value the Fourier Series will return is:
$$ f(pi)=f(-pi)= frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{(1-in)}{1+n^2} = frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{1}{1+n^2}$$
The latter reduction of the sum is straightforward as the imaginary part is zero.
But we cannot use this, as we do not know what $f(pi)$ is since $tilde f(t)$ is discontinuous at these points. Luckily, some smart people solved this conundrum and showed that at a discontinuity, the Fourier series converges to the average of the two values, i.e.
$$ f(pi)=f(-pi)=frac{lim_{trightarrowpi^-}tilde f(t) + lim_{trightarrow pi^+}tilde f(t)}{2} = frac{exp(-pi)+exp(pi)}{2} = cosh(pi)$$
See: Fourier series at discontinuities
So in the end, we have the solution:
$$f(pi)=cosh(pi)=frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{1}{1+n^2}$$
or
$$bbox[5px,border:2px solid #00A000]{pi coth(pi)=sum_{n=-infty}^inftyfrac{1}{1+n^2}=1+2sum_{n=1}^inftyfrac{1}{1+n^2}}$$
remark: computing $f(0)$ gives directly, without any fuss:
$$bbox[5px,border:2px solid #000000]{frac{pi}{sinh(pi)}=sum_{n=-infty}^inftyfrac{(-1)^n}{1+n^2}}$$
$endgroup$
When you state Using Fourier series, it does not necessarily mean that you have to use the Fourier Cosine and Sine series. You can also write it in exponential form:
Any periodic function $tilde{f}(t)$ with period $2pi$ can be written
as:
$$ f(t) = sum_{n=-infty}^infty c_n,e^{int} $$ with $$
c_n=frac{1}{2pi}int_{-pi}^pi tilde f(t),e^{-int},textrm{d}t
$$
note: we make a distinction between the fourier series $f(t)$ and the periodic function $tilde f(t)$ to indicate that they are different when $tilde f(t)$ is discontiniuous.
When you apply this for $tilde f(t)$, which is periodic over $2pi$, discontinuous and defined in the region $]-pi,pi[$ as $exp(-t)$, you obtain
$$
c_n = frac{sinh(pi)}picdotfrac{(-1)^n,(1-in)}{1+n^2}
$$
giving you:
$$
f(t)=frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{(-1)^n,(1-in)}{1+n^2},e^{int}
$$
You already notice the familiar part in the sum which is of interest, the problem is the $(-1)^n$. This we can get rid of with the proper choice of $t$. If $t=pmpi$ then $exp(pm inpi)=(-1)^n$. But be advised $f(t)$ is periodic with a period of $2pi$ and is not continuous in the points $t=npi$. The value the Fourier Series will return is:
$$ f(pi)=f(-pi)= frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{(1-in)}{1+n^2} = frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{1}{1+n^2}$$
The latter reduction of the sum is straightforward as the imaginary part is zero.
But we cannot use this, as we do not know what $f(pi)$ is since $tilde f(t)$ is discontinuous at these points. Luckily, some smart people solved this conundrum and showed that at a discontinuity, the Fourier series converges to the average of the two values, i.e.
$$ f(pi)=f(-pi)=frac{lim_{trightarrowpi^-}tilde f(t) + lim_{trightarrow pi^+}tilde f(t)}{2} = frac{exp(-pi)+exp(pi)}{2} = cosh(pi)$$
See: Fourier series at discontinuities
So in the end, we have the solution:
$$f(pi)=cosh(pi)=frac{sinh(pi)}pi sum_{n=-infty}^inftyfrac{1}{1+n^2}$$
or
$$bbox[5px,border:2px solid #00A000]{pi coth(pi)=sum_{n=-infty}^inftyfrac{1}{1+n^2}=1+2sum_{n=1}^inftyfrac{1}{1+n^2}}$$
remark: computing $f(0)$ gives directly, without any fuss:
$$bbox[5px,border:2px solid #000000]{frac{pi}{sinh(pi)}=sum_{n=-infty}^inftyfrac{(-1)^n}{1+n^2}}$$
edited Jan 31 at 15:20
answered Jan 31 at 11:58
kvantourkvantour
36829
36829
1
$begingroup$
I computed the sum using $f(0)$, but I will pay more attention to the points of discontinuity, so thank you so much for your additional important information.
$endgroup$
– Zouhair El Yaagoubi
Jan 31 at 12:11
add a comment |
1
$begingroup$
I computed the sum using $f(0)$, but I will pay more attention to the points of discontinuity, so thank you so much for your additional important information.
$endgroup$
– Zouhair El Yaagoubi
Jan 31 at 12:11
1
1
$begingroup$
I computed the sum using $f(0)$, but I will pay more attention to the points of discontinuity, so thank you so much for your additional important information.
$endgroup$
– Zouhair El Yaagoubi
Jan 31 at 12:11
$begingroup$
I computed the sum using $f(0)$, but I will pay more attention to the points of discontinuity, so thank you so much for your additional important information.
$endgroup$
– Zouhair El Yaagoubi
Jan 31 at 12:11
add a comment |
$begingroup$
Try using Parseval's theorem,
$$frac{1}{pi}int_{-pi}^pi |f(x)|^2 dx = frac{a_0}{2} + sum_{n=1}^{infty} a_n^2+b_n^2$$
If it comes out too nasty, then I think your coeffecients might be off.
$endgroup$
$begingroup$
I do not see how Parseval's theorem will give me the sum, can you elaborate more? Although, I have checked the coefficient well. They seem to be correct.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:12
add a comment |
$begingroup$
Try using Parseval's theorem,
$$frac{1}{pi}int_{-pi}^pi |f(x)|^2 dx = frac{a_0}{2} + sum_{n=1}^{infty} a_n^2+b_n^2$$
If it comes out too nasty, then I think your coeffecients might be off.
$endgroup$
$begingroup$
I do not see how Parseval's theorem will give me the sum, can you elaborate more? Although, I have checked the coefficient well. They seem to be correct.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:12
add a comment |
$begingroup$
Try using Parseval's theorem,
$$frac{1}{pi}int_{-pi}^pi |f(x)|^2 dx = frac{a_0}{2} + sum_{n=1}^{infty} a_n^2+b_n^2$$
If it comes out too nasty, then I think your coeffecients might be off.
$endgroup$
Try using Parseval's theorem,
$$frac{1}{pi}int_{-pi}^pi |f(x)|^2 dx = frac{a_0}{2} + sum_{n=1}^{infty} a_n^2+b_n^2$$
If it comes out too nasty, then I think your coeffecients might be off.
answered Jan 30 at 16:08
Nicholas ParrisNicholas Parris
1563
1563
$begingroup$
I do not see how Parseval's theorem will give me the sum, can you elaborate more? Although, I have checked the coefficient well. They seem to be correct.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:12
add a comment |
$begingroup$
I do not see how Parseval's theorem will give me the sum, can you elaborate more? Although, I have checked the coefficient well. They seem to be correct.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:12
$begingroup$
I do not see how Parseval's theorem will give me the sum, can you elaborate more? Although, I have checked the coefficient well. They seem to be correct.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:12
$begingroup$
I do not see how Parseval's theorem will give me the sum, can you elaborate more? Although, I have checked the coefficient well. They seem to be correct.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:12
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3093698%2fcomputing-sum-n-1-infty-frac1n2-1-using-fourier-series%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
"same problem for the second sum" - not exactly; once you find the first sum, multiply it by $2$ and add $1$.
$endgroup$
– user170231
Jan 30 at 16:20
$begingroup$
@user170231 Thank you. I'm still stuck with the first sun though.
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 16:21
1
$begingroup$
Your coefficients are not correct: $$a_0=frac1piint_{-pi}^pi e^{-x},mathrm dx=frac{e^pi-e^{-pi}}pi=frac{2sinhpi}pi$$ Similarly you should have ended up with $$a_n=frac{2(-1)^nsinhpi}{pi(n^2+1)}text{ and }b_n=frac{2n(-1)^nsinhpi}{pi(n^2+1)}$$ I think you are just missing a factor of $e^pi$ in certain places. (NB: $2sinhpi=e^pi-e^{-pi}$.)
$endgroup$
– user170231
Jan 30 at 17:04
$begingroup$
@user170231 To compute the coefficients, I used the formula: $$ a_n = frac{2}{pi} int_{0}^{pi} f(x) cos (nx)$$ and : $$ b_n = frac{2}{pi} int_{0}^{pi} f(x) sin (nx)$$ Isn't it correct?
$endgroup$
– Zouhair El Yaagoubi
Jan 30 at 17:18
1
$begingroup$
The formula I cited specifically works only for functions that are $2pi$-periodic over the interval $(-pi,pi)$. There is a formula for $P$-periodic functions over the interval $(x_0,x_0+P)$ listed on the page I linked under the section "A more general definition" (Eq. 4) for the more general case. It suggests$$a_n=frac2piint_0^pi f(x)cos nx,mathrm dx$$works for a function $f(x)$ that is $pi$-periodic over $(0,pi)$.
$endgroup$
– user170231
Jan 30 at 18:33