Plotting multiple instances of a function defined with NIntegrate

I have a function that involves an NIntegrate, for example something like this:

f[x_, z_] := NIntegrate[z*x*y^2, {y, 0, x}];

I want to plot this function for a large number of different values of z, and all on the same graph. The naive attempt:

Plot[Evaluate@Table[f[x, t], {t, 1, 15}],{x, 30, 70}]

This gives the error

NIntegrate::nlim: y = x is not a valid limit of integration.

I’ve tried various combinations of hold and activate and inactivate, but haven’t stumbled upon anything that works. How can I do this?

=================

  

 

It returns the errors for me in Version 10.2 on Windows 8.1 64-bit, but still generates the plot. Taking out the Evaluate and just executing Plot[Table[f[x, t], {t, 1, 15}],{x, 30, 70}] returns the plot with no errors (although with a notably longer execution time).
– IPoiler
Sep 4 ’15 at 2:23

  

 

Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– Michael E2
Sep 4 ’15 at 2:33

=================

1 Answer
1

=================

f[x_?NumericQ, z_?NumericQ] := NIntegrate[z*x*y^2, {y, 0, x}]
Plot[Evaluate@Table[f[x, t], {t, 1, 15}], {x, 30, 70}]

1

 

Of course you could get z out of the integral. I assume that’s because you posted a toy example
– Dr. belisarius
Sep 4 ’15 at 3:19