Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.3K Views
|
4 Replies
|
1 Total Like
View groups...
Share
Share this post:

Perform a numerical integration using trapezoid method?

POSTED BY: Nio Totté
4 Replies

I figured that when I decrease the amount of partitions, I'd get a less accurate result and therefore less/no chance on rounding errors. No idea if that's correct though. I tried it with n going from 1 to 10, and it still shows the same type of stuff. If it's rounding, how could I fix it? I think I recall my prof saying Mathematica remembers everything exactly?

POSTED BY: Nio Totté

It looks like numerical noise due to rounding errors in the last digits. The plot amplifies it out of proportion.

POSTED BY: Gianluca Gorni
POSTED BY: Nio Totté
Posted 6 years ago

Hi Nio,

Use exact values

intsom[f_, n_, a_, b_] := 
 Module[{t = 0, fen = {}},
  While[t < n + 1, c = f[a + ((b - a)/n)*t]; fen = Append[fen, c]; t++];
  T = ((b - a)/n)*(Total[fen] - 1/2*(f[a] + f[b]))]

list1 = {};
list2 = {};

Do[list1 = 
  Append[list1, 
   Abs[39 - intsom[g, 20*n, 2, 5] - (intsom[g, 20*n, 2, 5] - intsom[g, 10*n, 2, 5])/3]], {n, 10, 100}]
ListPlot[list1]

enter image description here

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