# How to plot a function defined by an expression containing integrals [duplicate]

It seems Mathematica does not like it when it is given a function defined by an integral to plot.

How would one plot a function $F(x)=\int_0^x\int_0^xf(t,s)dtds$ on a given interval?

### Edit

In particular I'd like to see how the graph of the following looks like:

F[x_] :=
2 x^2 ((Log[x])^2 - 3 Log [x] + 7/2) +
2 (1 - x)^2 ((Log[1 - x])^2 - 3 Log[1 - x] + 7/2) +
2 Integrate[(Log[t^2 + s^2])^2, {t, 0, x}, {s, 0, 1 - x}] +
1/2 Integrate[(Log[(1 - x)^2 + (t - s)^2])^2, {t, 0, x}, {s, 0, x}] +
1/2 Integrate  [(Log[x^2 + (t - s)^2])^2, {t, 0, 1 - x}, {s, 0, 1 - x}]

• Would you have a specific example of $F(x)$ in mind? Could you present it in Mathematica code for people to play with? – MarcoB Jul 28 '15 at 17:24
• Welcome to Mathematica.SE! I would use Plot and define F in the form F[x_?NumericQ] := .... See mathematica.stackexchange.com/questions/18393/…. – Michael E2 Jul 28 '15 at 17:32
• As noted, it's hard to say anything useful if we don't see the function concerned; different integrands call for different strategies. At the lowest level, you should follow @Michael's prescription, but otherwise there is nothing to say until you edit. – J. M.'s ennui Jul 28 '15 at 17:39
• People here generally like users to post code as Mathematica code instead of images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this this meta Q&A helpful – Michael E2 Jul 28 '15 at 19:39

Here is a quick modification that uses numerical integration: since you are interested in plotting the function, numerical results should be just as acceptable:

Clear[F]

F[x_?NumericQ] :=
2 x^2 ((Log[x])^2 - 3 Log[x] + 7/2) + 2 (1 - x)^2 ((Log[1 - x])^2 - 3 Log[1 - x] + 7/2) +
2 NIntegrate[(Log[t^2 + s^2])^2, {t, 0, x}, {s, 0, 1 - x}] +
1/2 NIntegrate[(Log[(1 - x)^2 + (t - s)^2])^2, {t, 0, x}, {s, 0, x}] +
1/2 NIntegrate[(Log[x^2 + (t - s)^2])^2, {t, 0, 1 - x}, {s, 0, 1 - x}]

Plot[F[x], {x, 0, 1}, PlotPoints -> 10, MaxRecursion -> 2]


Please note, however, that NIntegrate complains considerably during this calculation; you will want to carefully define the domain over which you want to see the plot of $F(x)$.

• Thanks. Well errors might be caused by mild singularity in one of the integrands. – BigM Jul 28 '15 at 20:46
• @BigM You are very welcome. – MarcoB Jul 28 '15 at 20:47