# Plotting a numerical integral?

Posted 4 months ago
676 Views
|
4 Replies
|
3 Total Likes
|
 Hello,I am trying to solve a numerical integral that is a function of two other numerical integrals and subsequently plot the result as a function of a parameter. When I try this, I do not get an explicit error, but the kernel quits and the plot does not appear. Any help would be greatly appreciated!Also, moderators please note: this is not a duplicate of my previous question on this forum. My previous question pertains to the "Solve" function and this question pertains to a plotting issue. So please do not remove this post!Thank you,Alex Attachments:
4 Replies
Sort By:
Posted 4 months ago
 Hello Alex, You will tend to get a quicker response if you post a bit of code instead of a notebook.In any case, I took a quick look at your code. You had values of g inside the inner Numerical integrate. You need to make that explicit, with something like B[T,g] instead of B[T]. If it inside a numerical function, then it is better to do this: B[T_,?NumericQ, g_?NumericQ]:= B[J_, g_] := (2/(1 + nIntegrate[ Exp[-B[J]]*(b*h/G*(1 - c*g) + b*(1 - h/G)*(1 - c*g)*g + d*x/K), {J, T, 505 - T}])) I put a dummy function in there "nIntegrate" so you can make sure that the integrand evaluates to a numeric quantify for values of J. If it does, replace the nIntegrate with NIntegrate.Also, note that capital K is a symbol already defined in the WL.Your plot will take a long time as you have to do nested numerical integrals.
Posted 4 months ago
 Hello Craig, thank you for your response! I tried the code you suggested but it is giving me the error seen in the attached notebook. Based on what you said about making g explicit, I tried this code: B[J_?NumericQ, g_?NumericQ] := NIntegrate[ b*(1 - c*g)*H/G + b*g*(1 - c*g)*(1 - H/G) - d*X/K, {t, J, 500}] h = Exp[-q*J]*G x = (b E^((b h J)/G) h K)/(-d G + d E^((b h J)/G) G + b h) B[T_?NumericQ, g_?NumericQ] := (2/(1 + NIntegrate[ Exp[-B[J, g]]*(b*h/G*(1 - c*g) + b*(1 - h/G)*(1 - c*g)*g + d*x/K), {J, T, 500}])) w = Exp[-q*T]*G W = (b E^((b w T)/G) w K)/(-d G + d E^((b w T)/G) G + b w) Plot[NIntegrate[W*B[T, g], {T, 0, 330}], {g, 0, 1}] But this code again results in the Kernel automatically quitting. Any further help would be greatly appreciated but I completely understand if it can not be given!Alex Attachments: