0

my problem is that I have a rather large function which I'm trying to plot, which looks something like this:

Plot[NIntegrate[f[x,y],{x,0,pole,xmax},Method->"LocalAdaptive"],{y,ymin,ymax}]

This works fine, but when I try to change it to LogLinearPlot, I get a lot of error messages. Any idea what I should do?

Thanks, Dan

Dan Goldwater
  • 360
  • 1
  • 2
  • 8
  • I have trouble guessing what error messages you get :D Joking aside you are trying to numerically integrate a function of two variables over the first one. That's not possible - you have to supply NIntegrate with values for every parameter or you will end up with a lot of error messages. – Sektor Feb 13 '15 at 11:57
  • 2
    @Sektor The y values comes from Plot, except when it attempts symbolic evaluation. – Mr.Wizard Feb 13 '15 at 12:28

1 Answers1

1

This should probably be closed as a duplicate of one of the the many NumericQ questions on this site.

The problem is that LogLinearPlot attempts a symbolic evaluation, meaning that y is not given a value, and NIntegrate doesn't like this! You can use a wrapper function to prevent non-numeric y values being passed its way:

f[x_, y_] := x + y^2

fint[y_?NumericQ] :=
 NIntegrate[f[x, y], {x, 0, 1.2, 3}, Method -> "LocalAdaptive"]

LogLinearPlot[fint[y], {y, 1, 3}]

enter image description here

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371