Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.2K Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Plotting a numerical integral?

Posted 4 years ago

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:
POSTED BY: Alex L
4 Replies
Posted 4 years ago

Thank you so much!! I just learned so much from this.

Alex

POSTED BY: Alex L

Hello Alex, Here is a working version. Some parts of your numerical integral could be done symbolically which speeds up the computation considerably. You will want to check my steps: I didn't do a proof read.

I find it easier to put only one or two expressions in a cell--that way you can take a look at intermediate results easier.

I recommend not using upper case letters for your own symbols. I redefined K as k.

Because you are working with Exps of Exps, rescaling your problem may make things better behaved. In any case, something does plot in the attached.

Attachments:
POSTED BY: W. Craig Carter
Posted 4 years 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:
POSTED BY: Alex L
POSTED BY: W. Craig Carter
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard