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

In summary, the conversation discusses constructing a contour plot of a given function, and the attempts to do so using Matlab and Maxima. However, there are issues with the code freezing and difficulties with plotting a vector field.
  • #1
Dustinsfl
2,281
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
  • #3
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?
 
  • #4
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
 
  • #5
Is there anyway to plot the vector field of this?
 
  • #6

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

What is a contour plot and how does it help solve PDEs?

A contour plot is a graphical representation of a PDE (partial differential equation) that shows the variation of a quantity over a given domain. It is constructed by plotting level curves, or lines of equal value, for the dependent variable in the equation. This visualization helps identify regions of interest, such as areas of high or low values, and can aid in understanding the behavior of the PDE.

What is a summation formula and how is it used in constructing a contour plot?

A summation formula is a mathematical expression that allows us to calculate the value of a dependent variable at any point in the domain by summing the contributions from all other points in the domain. It is used in constructing a contour plot by providing a way to calculate the values of the dependent variable at each point on the plot, which can then be used to draw the contour lines.

How do you choose the values for the contour lines on a plot?

The values for the contour lines are typically chosen based on the range of values that the dependent variable can take on. It is important to choose a range that includes the minimum and maximum values of the dependent variable, as well as any significant values in between. It may also be helpful to choose values that are evenly spaced to aid in visualizing the behavior of the PDE.

Are there any limitations to using contour plots for solving PDEs?

While contour plots can provide valuable insights into the behavior of PDEs, they do have some limitations. For example, they may not accurately represent the behavior of highly nonlinear or discontinuous PDEs. Additionally, contour plots can become difficult to interpret if there are too many contour lines or if the values of the dependent variable vary greatly over the domain.

Are there any software tools available for constructing contour plots for PDEs?

Yes, there are many software tools available for constructing contour plots for PDEs. Some common options include MATLAB, Mathematica, and Python with libraries such as NumPy and Matplotlib. These tools often have built-in functions for solving PDEs and constructing contour plots, making it easier to visualize and analyze the results.

Similar threads

Replies
2
Views
1K
Replies
2
Views
700
Replies
3
Views
1K
Replies
2
Views
471
Replies
10
Views
12K
Replies
4
Views
2K
Replies
3
Views
968
Replies
1
Views
994
Back
Top