Git Product home page Git Product logo

numint's Introduction

Numerical Integration

Compares the results of the trapezoid method with a simple summation.

For N+1 evenly spaced data points (i.e., N equal segments), the definite integral can be approximated by:

Here (b-a)/N is the spacing between data points.

Note that this equates to a simple summation multiplied by the data point spacing, minus a correction term:
( f(1) + f(end) )/2

If the spacing between the data points is not constant, the formula generalizes to:

Sample output:



Test code:

for N = logspace(1, 4, 4)
    x = pi*linspace(0, 1, N+1);
    y = sin(x);
    fprintf('N = %-6d \tTrapz = %.6f\n', N, trapz(x, y))
end
N = 10     	Trapz = 1.983524
N = 100    	Trapz = 1.999836
N = 1000   	Trapz = 1.999998
N = 10000  	Trapz = 2.000000

Resources:

https://www.mathworks.com/help/matlab/ref/trapz.html

https://web.engr.oregonstate.edu/~webbky/MAE4020_5020_files/Section%208%20Integration.pdf

numint's People

Contributors

bdubs-astro avatar bdwissman avatar

Watchers

 avatar

numint's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.