2
$\begingroup$

I am trying to plot my solution to a Laplace equation on an infinite domain. However, when I try to plot it, Mathematica just runs with nothing happening.

f[x_, y_] = Sinh[u*(5 - y)]/Sinh[u*5]*100/π*Cos[u*(ξ - x)]; 
DensityPlot[Integrate[f[x, y], {u, 1, 10}, {ξ, -5, 5}], {x, -5, 5}, {y, 0, 5}]

The code I have tried is above. The solution is $$ f(x, y) = \frac{100}{\pi}\int_0^{\infty}\int_{-\infty}^{\infty}\frac{\sinh(u(5-y))}{\sinh(5u)}\cos(u(\xi - x))d\xi du $$

$\endgroup$
  • $\begingroup$ In general, if your integral is time consuming to calculate, it would be better to first evaluate it and then feed it to DensityPlot. $\endgroup$ – b.gates.you.know.what Oct 16 '13 at 12:33
  • $\begingroup$ @b.gatessucks that didn't work either. $\endgroup$ – dustin Oct 16 '13 at 12:36
  • $\begingroup$ I have checked that this works, though it's not very fast : 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]. $\endgroup$ – b.gates.you.know.what Oct 16 '13 at 12:50
  • $\begingroup$ @b.gatessucks I have been running the code for 12mins and still nothing though. $\endgroup$ – dustin Oct 16 '13 at 13:06
  • $\begingroup$ Perhaps you want to rephrase your question to be about performance-tuning (how to speed up the process). $\endgroup$ – István Zachar Oct 16 '13 at 16:42
1
$\begingroup$

This is what I get in under 5 minutes :

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]

5 min

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.