2
$\begingroup$

I have tried using maple and matlab to plot this question but it seems to be unable to plot, would to ask if there is any ideas on plotting this question using maple or matlab?enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ What is the $\mid$ doing at the end? Do you want a matching one at the start? $\endgroup$ – Robert Israel May 15 '19 at 14:24
  • $\begingroup$ sorry, the | was just a typo $\endgroup$ – Thanks for answering May 15 '19 at 15:35
5
$\begingroup$

Here is Maple. Note that (although the sum does converge at $t=0$) there seem to be numerical difficulties when $t$ is very close to $0$, so I started at $t=0.01$.

u:= Sum((1+(-1)^n)/(n*Pi)*sin(n*Pi*x)*exp(-n^2*Pi^2*t),n=1..infinity) +x+1:
plot3d(u,x=0..1,t=0.01..0.2);

enter image description here

EDIT: $u(x,0)$ should be a step function: essentially $3/2 + \lfloor x \rfloor$ ($x+1$ when $x$ is exactly an integer, but I'll ignore that). So here is a better picture.

U:= proc(x,t) if t = 0 then 3/2 + floor(x)
  else Sum((1+(-1)^n)/(n*Pi)*sin(n*Pi*x)*exp(-n^2*Pi^2*t),n=1..infinity) +x+1 fi 
 end proc;
plot3d(U,-0.5 .. 1.5,0.. 0.2);

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ There seems to be Gibbs phenomenon at work for $t=0$. $\endgroup$ – Fabio Somenzi May 15 '19 at 14:46
  • $\begingroup$ Yes, the Gibbs phenomenon affects partial sums of the series at $t=0$, which is the Fourier series of a discontinuous function. $\endgroup$ – Robert Israel May 15 '19 at 14:55
1
$\begingroup$

Here's a MATLAB solution.

px = 2000;
pt = 1000;
niter = 100;
u = zeros(px,pt);
x = linspace(0,2,px);
t = linspace(0,1,pt);

for p = 1:px
  for q = 1:pt
    v = 0;
    for n = 2:2:niter
      v = v + 2/(n*pi) * sin(n*pi*x(p)) * exp(-n.^2*pi^2*t(q));
    end
    u(p,q) = v + x(p) + 1;
  end
end

[X,T] = meshgrid(t,x);

mesh(X,T,u)

enter image description here

Another solution, based on symbolic MATLAB,

syms x t n

u = symsum((1+(-1)^n)/(n*sym(pi)) * sin(n*sym(pi)*x) * exp(-n^2*sym(pi)^2*t),n,1,500) + x + 1;

fsurf(u,[0,0.2,0,2])
xlabel('t')
ylabel('x')

produces this plot

enter image description here

$\endgroup$
0
$\begingroup$

I obtained this graphic with Mathematica in a few seconds...3D Plot truncating the sum to 50 terms

The plot is for $t \in [0,1]$ and $x\in [0,2]$.

In matlab I suppose you can start by building a matrix with the function values at a given grid. Each function values is calculated by a finite sum (the exponential makes the series converge rather fast). That matrix can then be used to obtain the surface plot.

$\endgroup$
3
  • 1
    $\begingroup$ I would like to ask is it possible to plot using matlab or maple? $\endgroup$ – Thanks for answering May 15 '19 at 14:23
  • $\begingroup$ @Thanksforanswering it is possible, you just need discover what are the plot commands in matlab expecting to receive, and produce it. Computing function values can be achieved simply by working with a fixed number of terms in the series. $\endgroup$ – PierreCarre May 15 '19 at 14:27
  • $\begingroup$ ok thank you, will try out using your idea $\endgroup$ – Thanks for answering May 15 '19 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.