Message Boards Message Boards

Numerical integration and the Plot of a function give different results?

Posted 9 years ago

The attached worksheet describes the issue.

The numerical integrated value does not match the values in the plotted graphic over the same range.

I am likely making a novice mistake, but any help would be appreciated.

Attachments:
POSTED BY: Luther Nayhm
4 Replies
Posted 9 years ago

y1 = 0; y2 = 1; n = 50; y = Range[y1,y2, (y2-y1)/(n-1.)]; f[x, y] := y Sin[x] If your function is Listable you can do this

points = {y, NIntegrate[f[x, y], {x, 0, Pi}]} // Transpose; ListLinePlot[points] If your function is not Listable:

points = Map[{#, NIntegrate[f[x, #], {x, 0, Pi}]} &, y] ListLinePlot[points] enter image description here

POSTED BY: xavi pirlo
Posted 9 years ago

Not sure what you are repling to.

If I integrate my expression, I get an analytical function that has a value of 3 when the variable goes to zero, but the ListPlotTable[NIntegrate]] for that same integrated function shows the correct value....0....when the variable goes to zero. The analytical function is biased upward by 3 units...and the curve that is generated is the same as the ListPlot only biased upward by 3 units.

My conclusion is that Mathematica has incorrectly performed the integration on the function and has given me an incorrect analytical expression. I can live with the numerical integration but the disconnect with the analytical expression was unexpected.

POSTED BY: Luther Nayhm

You may have forgotten to subtract the value of f1 at b=0:

Clear[f1];
f1[b_] = Integrate[(b Sqrt[1 - b^2])/(1 - b)^2, b];
ListPlot[Table[f1[b], {b, 0, .13, .01}]]
ListPlot[Table[f1[b] - f1[0], {b, 0, .13, .01}]]
POSTED BY: Gianluca Gorni
Posted 9 years ago

You are absolutely correct! See, I told you I probably did something stupid.

Thanks for your help. I get in a hurry and skip steps I know not to skip.

POSTED BY: Luther Nayhm
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract