I'm plotting a solution to a PDE using surf but the graph turns out wrong?
8 views (last 30 days)
I'm trying to plot the solution to a PDE, which is an infinite series:
So far this is my code, I can't see what's wrong with it. I've attached the graph i got below.
edit: the sin part is part of the summation, and the original pde is:
xRange = 0:0.1:6;
tRange = 0:0.1:6;
[x,t] = meshgrid(xRange,tRange);
u = zeros(size(x));
u = u+(4/(n^3*pi^3)+(4/(n*pi)-4/(n^3*pi^3))*exp(-n^2*pi^2.*t)).*sin(n*pi/2*x);
John D'Errico on 10 Jun 2021
Edited: John D'Errico on 10 Jun 2021
Do you understand that the series you show is not the same as what you wrote in code?
Where did the sin term go in your code? Without it, you get something VERY different.
ARGH. We seem to be chasing a moving problem.
Along at least one edge, you have a problem that the series is poorly convergent, and taking only 10 terms is inadequate. You would need many more terms in the series, when t==0. In fact, as I look, your series, it is divergent when t == 0. Why is that the case? When t == 0, the exponential goes away. So now you have an infinite sum of the terms
And since this sub-series is divergent, you have a problem along that edge.
More Answers (2)
KSSV on 10 Jun 2021
MAy be you are looking for this:
tRange = 0:0.05:1;
[n,t] = meshgrid(n,tRange);
u = (4./(n.^3*pi^3)+(4./(n*pi)-4./(n.^3*pi^3)).*exp(-n.^2*pi^2.*t));