Plotting an infinite domain PDE

Click For Summary

Discussion Overview

The discussion revolves around the challenges of plotting a solution to a partial differential equation (PDE) defined over an infinite domain, where the solution involves an integral. Participants explore various computational approaches using Mathematica, Matlab, and Python, while addressing issues related to computational efficiency and accuracy.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant presents a specific integral solution for the PDE and seeks assistance in plotting it using different programming environments.
  • Another participant requests the Mathematica code used by the original poster to understand the implementation better.
  • A participant shares their Mathematica code, noting that it only integrates over a limited range for the variable \(u\) and \(\xi\), expressing a desire for more accurate plotting through broader integration.
  • A participant provides Python code that attempts to handle larger integration bounds but reports issues with accuracy in the resulting plot.
  • One participant suggests a potential optimization by factoring out parts of the integral to reduce computational load, while also noting that the inner integral does not converge and referencing the Riemann-Lebesgue Lemma as a possible consideration.

Areas of Agreement / Disagreement

Participants express various approaches and concerns regarding computational efficiency and accuracy, but no consensus is reached on the best method to plot the PDE or resolve the issues raised.

Contextual Notes

Participants highlight limitations in their current implementations, including the convergence of integrals and the computational time required for larger integration bounds. There are unresolved questions about the accuracy of the plots generated by the different programming languages.

Dustinsfl
Messages
2,217
Reaction score
5
Is anyone familiar with plotting an infinite domain PDE where the solution is an integral.

Take the solution
\[
T(x,t) = \frac{100}{\pi}\int_0^{\infty}\int_{-\infty}^{\infty} \frac{\sinh(u(10-y)}{\sinh(10u)} \cos(u(\xi-x))d\xi du
\]
How could I plot this in Matlab, Mathematica, or Python?

As a note, Mathematica is slow because I have code that does it, but when I increase u, the time to complete goes up exponentially. I am talking hours.

Everything I tried in Matlab failed.
 
Physics news on Phys.org
I'm curious: can you post your Mathematica code?
 
Ackbach said:
I'm curious: can you post your Mathematica code?

Code:
f[x_, y_, u_, \[Xi]_] =  Sinh[u*(5 - y)]/Sinh[u*5]*100/\[Pi]*Cos[u*(\[Xi] - x)];
 
g[x_?NumericQ, y_?NumericQ] := NIntegrate[f[x, y, u, \[Xi]], {u, 1, 10}, {\[Xi], -5, 5}];

DensityPlot[g[x, y], {x, -5, 5}, {y, 0, 5}, PlotPoints -> 5]

This code only integrate u from 1 to 10 and \(\xi\) from -5 to 5. However, I would like to increase the integration to have a more accurate plot.

Here is Python code that takes a long time but can handle a bigger integration bounds in the same time Mathematica can but the code isn't producing an accurately plot either so there must be something wrong as well.

Code:
import numpy as np
import pylab as pl 
from scipy.integrate import dblquad  

b = 50.0  
x = np.linspace(-10, 10, 1000) 
y = np.linspace(0, 10, 1000)  def f(xx, u, xi, yj):     
    return ((np.exp(u * (b - yj)) - np.exp(-u * (b - yj))) / 
              (np.exp(u * b) - np.exp(-u * b)) * np.cos(u * (xx - xi)))  T = np.zeros([len(x), len(y)])

 
for i, xi in enumerate(x):     
    for j, yj in enumerate(y):         
        T[i, j] += dblquad(             
                   f, -10, 10, lambda x: 0.1, lambda x: 10, args=(xi, yj))[0]fig = pl.figure()
ax = fig.add_subplot(111)
pax = ax.pcolormesh(y, x, T)
fig.colorbar(pax)
pl.xlim((-X, X))
pl.ylim((0, b))
pl.grid(True)

pl.show()
 
You might save some computational time if you pull everything out of the inner integral that you can:
$$T(x,t)= \frac{100}{ \pi} \int_{0}^{ \infty} \frac{ \sinh(u(10-y))}{ \sinh(10u)}
\underbrace{ \int_{- \infty}^{ \infty} \cos(u( \xi-x)) \, d \xi}_{ \text{define this as }f(u,x)} \, du.$$
This way, the ratio on sinh's isn't evaluated for every inner loop. I should point out, however, that the inner integral, which is $f(u,x)$, doesn't converge. The Riemann-Lebesgue Lemma might come in handy here, depending on where you want to look at things.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
Replies
4
Views
2K
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K