Skip to main content
1-Visitor
July 20, 2018
Solved

Programming of Simpson's rule

  • July 20, 2018
  • 3 replies
  • 8140 views

Team,

 

Hope you can help me with one more question. 

 

I was solving on-bottom stability and I'm stucked on aproximation of the integral of the function. There are many ways how to solve this Trapezoidal rule, SImpson's rule etc.. so any of those would be great (but not sure how to program any of them). 


Can you please check this spreadsheet and help me. Basicly I'm not sure how to call for even/uneven numbers based on the defined gamma. 


Thank you 

 

AS

Best answer by Werner_E

Here for comparison the results with the same value of h using the functional approach.

What you can see is twofold:

1) The approxamation  by simply summing up the rectangles is pretty acurate

2) The 284 special values of omega which you provide have no influence on the outcome - they don't matter.

B2.jpg

3 replies

23-Emerald IV
July 20, 2018

Why try to write your own numeric integration approximation (Simpson), when you can have Prime do it for you?

Example:

LM_20180720_Integrate.png

Success!
Luc

 

23-Emerald IV
July 20, 2018

Ah, I see. You don't have functions, you have discrete data/vectors (although I guess that's just your doing, you might as well have omega as a running variable and use the Suu function).

Anyway, in case of vector data, integration becomes summation. See if this helps:

LM_20180720_Integrate1.png

Note! It's not complete, I left it for you to finish. But at least it gives you a clue how to get to even and uneven indexed values...

 

Success!
Luc

25-Diamond I
July 20, 2018

It wouldn't be hard to implement Simpson but as Luc said its not necessary as Prime would do the job of numeric integration for you if possible.

Unfortunately its not possible with the functions an limits you provide.

You have to evaluate an improper integral (the upper limit is infinity), but the function g(omega), which is part of the integrand, will fail for values of omega greater than  21.8 because of numerical limitation.

Here is a possible workaround using an auxiliary function g_ which is set to zero for omega>21.

B.jpg

B2.jpg

AdoS1-VisitorAuthor
1-Visitor
July 20, 2018

Thank for the answers guys,

So if I use mathcad prime integration, it would be like this. Looks good, or I did something wrong? :=)Capture232.JPG

25-Diamond I
July 20, 2018

@AdoS wrote:

Thank for the answers guys,

So if I use mathcad prime integration, it would be like this. Looks good, or I did something wrong? :=)

Not sure. If S.n in your sheet is the same as what is calles S.uu in your template, than it seem so be OK.

You had defines S.uu differently in your sheet and so I used the S.uu you defined.

 

Do you get a result for M(5) or higher values of n?

 

Are you sure that the function which is called S.uu in the picture you show is the same which you call S.n in your sheet and not a function similar to what you call S.uu in your sheet??