MHB Constructing a Contour Plot for Solving a PDE with a Summation Formula

  • Thread starter Thread starter Dustinsfl
  • Start date Start date
  • Tags Tags
    Pde Plotting sol
AI Thread Summary
The discussion revolves around constructing a contour plot for the given function u(x,y) defined by a series involving sine and hyperbolic sine functions. The user initially attempts to create a contour plot in MATLAB using a symbolic summation, but encounters freezing issues with the code provided. Suggestions are made to explore alternative software, specifically Maxima, which successfully generates both 3D and contour plots of the function. Additionally, there is a query about plotting a vector field, but it is clarified that since u is not a vector-valued function, a vector field cannot be directly derived from it. The conversation highlights the challenges of numerical computation in MATLAB and the potential of using other tools for visualizing complex functions.
Dustinsfl
Messages
2,217
Reaction score
5
$$
u(x,y) = \frac{4}{\pi}\sum_{n = 1}^{\infty}\left[\frac{\sin(2n - 1)\pi x\sinh\left[(2n - 1)\pi (1 - y)\right]}{(2n - 1)\sinh(2n - 1)\pi} + \frac{\sin(2n - 1)\pi y\sinh\left[(2n - 1)\pi(1 - x)\right]}{(2n - 1)\sinh(2n - 1)\pi}\right].
$$

How do I construct a contour plot of this?
 
Physics news on Phys.org
Code:
>> [x,y]=meshgrid(-10:0.1:10, -10:0.1:10);
>> syms n;
>> z=symsum(4/pi*(sin((2*n-1)*pi*x)*sinh((2*n-1)*pi*(1-y))/((2*n-1)*sinh((2*n-1)*pi))+sin((2*n-1)*pi*y)*sinh((2*n-1)*pi*(1-x))/((2*n-1)*sinh((2*n-1)*pi))),0,20);
contour3(x,y,z)
I just tried this code but Matlab froze.

Any thoughts or suggestions?
 
dwsmith said:
Code:
>> [x,y]=meshgrid(-10:0.1:10, -10:0.1:10);
>> syms n;
>> z=symsum(4/pi*(sin((2*n-1)*pi*x)*sinh((2*n-1)*pi*(1-y))/((2*n-1)*sinh((2*n-1)*pi))+sin((2*n-1)*pi*y)*sinh((2*n-1)*pi*(1-x))/((2*n-1)*sinh((2*n-1)*pi))),0,20);
contour3(x,y,z)
I just tried this code but Matlab froze.

Any thoughts or suggestions?

I tried this using Maxima. The code I used and the plots are given below.

Code:
expr:sum(4/%pi*(sin((2*n-1)*%pi*x)*sinh((2*n-1)*%pi*(1-y))/((2*n-1)*sinh((2*n-1)*%pi))+sin((2*n-1)*%pi*y)*sinh((2*n-1)*%pi*(1-x))/((2*n-1)*sinh((2*n-1)*%pi))),n,0,20)$

plot3d(expr, [x,-10,10],[y,-10,10],[grid, 150, 150]);

contour_plot(expr,[x,-15,15],[y,-10,10],[grid, 300, 300]);
3D Plot

14ccift.png


Contour Plot

2v1no6a.png
 
Is there anyway to plot the vector field of this?
 

Similar threads

Replies
2
Views
1K
Replies
2
Views
2K
Replies
3
Views
2K
Replies
2
Views
2K
Replies
3
Views
3K
Replies
2
Views
2K
Replies
10
Views
12K
Replies
3
Views
2K
Replies
3
Views
1K
Back
Top