Message Boards Message Boards

Plot z as a function of "a"?

GROUPS:

How can I plot z as a function of "a"?

z = Table[NIntegrate[Sin[a + b x], {x, -10, 10}], {b, 0, 5, 0.5}, {a, 0, 5,  0.5}];
ListPlot[z, Joined -> True, PlotRange -> All]

enter image description here

POSTED BY: Jose richard
Answer
26 days ago
u = Integrate[Sin[a + b*x], {x, -10, 10}];
{Plot3D[u, {a, 0., 5}, {b, 0.0001, 5}, PlotRange -> All, Mesh -> None,
   ColorFunction -> Hue, AxesLabel -> {"a", "b", ""}], 
 Plot[u /. b -> 1, {a, 0, 5}, AxesLabel -> Automatic]}

fig

POSTED BY: Alexander Trounev
Answer
25 days ago

Hey. Thank you a lot. Why did you replace NIntegrate with Integratre?

POSTED BY: Jose richard
Answer
25 days ago
In[1]:= u = Integrate[Sin[a + b*x], {x, -10, 10}]  
Out[1]= (2 Sin[a] Sin[10 b])/b
POSTED BY: Alexander Trounev
Answer
25 days ago

Yes, but this function is just a simple example. My original function is more complicated, so I need NIntegrate.

POSTED BY: Jose richard
Answer
25 days ago

OK! Let me take a look at the general cases on this particular example:

u = Flatten[
  Table[{a, b, NIntegrate[Sin[x^a - x^b], {x, 1, 2}]}, {a, 1, 
    2, .1}, {b, 3, 4, .1}], 1];
ListPlot3D[u, AxesLabel -> {"a", "b", ""}, Mesh -> None, 
 ColorFunction -> Hue]

fig2

Fu = Interpolation[u]
{Plot[Fu[a, 3.5], {a, 1, 2}, AxesLabel -> Automatic], 
 Plot3D[Fu[a, b], {a, 1, 2}, {b, 3, 4}, Mesh -> None, 
  ColorFunction -> Hue]}

fig3

POSTED BY: Alexander Trounev
Answer
25 days ago

Thank you again. This is exactly equal to

F[a_?NumericQ, b_?NumericQ] := NIntegrate[Sin[x^a - x^b], {x, 1, 2}]
Plot[F[y, 3.5], {y, 1, 2}]

enter image description here

Why that?

POSTED BY: Jose richard
Answer
24 days ago

Group Abstract Group Abstract