Sum of an exponential function/Mathematica

234 Views Asked by At

I have a function that looks like following: $$T=2\sum_{n=1}^{\infty}\frac{(-1)^{n-1}\cos(\lambda_n x)}{\lambda_n}\exp(-\lambda_n^2 t)$$ where $\lambda_n=\frac{(2n-1)\pi}{2}$. I use Mathematica to plot $T$ as a function of $x$ in the range of {x,0,1} for different $t$ values. The solution when $t=0$ and $t=\infty$ appears correctly. However, for all values $0<t<\infty$ the software keeps running. I am wondering if the exponential function has a special command to use in Mathematica or I am missing something in my code.
Here is my Mathematica syntax:

Plot[Simplify[ Abs[2 Sum[((-1)^(n - 1) Cos[((2 n - 1) [Pi])/2 x])/(((2 n - 1) [Pi])/2) Exp[-(((2 n - 1) [Pi])/2)^2 (t)], {n, 1, Infinity}]], Assumptions -> {x > 0}] // Evaluate, {x, 0, 1}, PlotRange -> All]
Any help would be highly appreciated! Lama

1

There are 1 best solutions below

1
On

When $\,t=0\,$: $$ T=2\sum_{n=1}^{\infty}\frac{(-1)^{n-1}\cos\left(\lambda_n\,x\right)}{\lambda_n} = \frac{2}{\pi}\left[\arctan\left({\large e}^{-i\frac{\pi}{2}x}\right)+\arctan\left({\large e}^{+i\frac{\pi}{2}x}\right)\right] $$ And this is a famous square wave function.

When $\,x=1\,$: $$ T=2\sum_{n=1}^{\infty}\frac{(-1)^{n-1}\cos\left(\lambda_n\right)}{\lambda_n}\,{\large e}^{-\lambda_n^2\,t} = \color{red}{0} \quad\text{for all }t\quad\left\{{\small\cos\left((2n-1)\frac{\pi}{2}\right)=0}\right\} $$
Noticing the series is rapid convergent, exploiting Mathematica defining functions capabilities,
Perhaps it will be better to define a function $\,f(x,t,l)\,$ As shown below,
And start plotting multiple graphs for different values of $\,t\,$ at the same time. Enjoy!

f[x_, t_, l_] := 2 Sum[((-1)^(n - 1)) Cos[(((2 n - 1) Pi)/2) x] Exp[-((((2 n - 1) Pi)/2)^2) t]/(((2 n - 1) Pi)/2), {n, 1, l}];
Plot[{f[x, 0/4, 100], f[x, 1/4, 100], f[x, 2/4, 100], f[x, 3/4, 100], f[x, 4/4, 100], f[x, 5/4, 100]}, {x, -1, +1}]

enter image description here