Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 $$

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

1 Answer 1

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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