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

  • Context: MHB 
  • Thread starter Thread starter Dustinsfl
  • Start date Start date
  • Tags Tags
    Pde Plotting sol
Click For Summary
SUMMARY

This discussion focuses on constructing a contour plot for the solution of a partial differential equation (PDE) represented by the summation formula $$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].

Users attempted to implement this in MATLAB using the code snippet provided, but encountered freezing issues. Alternatives using Maxima were also discussed, with successful contour plotting achieved through the commands plot3d and contour_plot.

PREREQUISITES
  • Understanding of partial differential equations (PDEs)
  • Proficiency in MATLAB for numerical computing
  • Familiarity with symbolic computation in Maxima
  • Knowledge of contour plotting techniques
NEXT STEPS
  • Explore MATLAB's contour3 function for 3D contour plotting
  • Learn about the symsum function in MATLAB for symbolic summation
  • Investigate Maxima's capabilities for plotting vector fields
  • Study techniques for optimizing MATLAB code to prevent freezing during computations
USEFUL FOR

Mathematicians, physicists, and engineers interested in numerical methods for solving PDEs, as well as students learning about contour plotting and symbolic computation.

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 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
13K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K