It is an arithmetical rule for estimating the area under a curve where the values of an odd number of ordinates, including those at each end, are known.
Questions tagged [simpsons-rule]
63 questions
0
votes
1 answer
Creating function handle from two vectors to pass to an integral function in MATLAB
I'm not sure if I'm being thick here, but I'm not used to function handles etc.
I am trying to find the integral of some raw accelerometer data i have, and was advised by a friend that using Simpsons might be the best way. So i found that MATLAB has…

Ross Hanna
- 25
- 4
0
votes
1 answer
Load Error when trying to pass complicated function into Simpson's rule
I have written a method that approximates a definite integral by the composite Simpson's rule.
#=
f integrand
a lower integration bound
b upper integration bound
n number of iterations or panels
h step size
=#
function simpson(f::Function,…

mooncow
- 413
- 4
- 11
0
votes
1 answer
Question about inputting formulas in Excel
I am creating a worksheet for Simpson's Rule and I would like to make it flexible for different equations.
So I have a cell just for the endpoints, step size and formula, and then a table for my calculations.
I know I can just directly input the…

A. Belrose
- 1
- 4
0
votes
1 answer
MATLAB : Simpson's 1/3 Rule
I've created a code for the Simpson's rule but I think I got the function wrong. I have no other sources to refer to (or they're too difficult to be understood). Here is my code:
function s = simpson(f_str, a, b, h)
f = inline(f_str);
n = (b-a)/h;…

Yvette
- 15
- 1
- 3
0
votes
0 answers
Rewriting trapezoidal to simpson rule in matlab
I'm trying to write a matlab program to calculate an integral by means of trapezoidal and simpsons rule. The program for trapezoidal is as follows:
function [int, flag, stats] = trapComp(f, a, b, tol, hMin)
% Initialise variables
…

M. Hartog
- 1
- 1
0
votes
1 answer
Plotting Fourier Series coefficients in Python using Simpson's Rule
I want to 1. express Simpson's Rule as a general function for integration in python and 2. use it to compute and plot the Fourier Series coefficients of the function .
I've stolen and adapted this code for Simpson's Rule, which seems to work fine…

Aran G
- 135
- 7
0
votes
1 answer
Simpson 1/3 rule
The solution of the problem it is 1.732400451459101 for Simpson 1/3 Rule. Instead the solution that the program give me is 1.73239801
Can anyone help me out? Thanks in advance.
clc
clear
close all
f = @(x) sin(x);
a = 0.1;
g = a;
b = 2.4;
k = 19; …

Antony Velez
- 1
- 1
0
votes
1 answer
Integration by simpson's 1/3rd integration method for any non-linear equation in C language?
Simpson 1/3rd integration method by Linklist.
#include
#include
#include
#include
struct term{
int power;
int coefficient;
struct term *nxt;
};
struct term *start=NULL;
int deg=0;
double…
user8352140
0
votes
1 answer
Accessing the variable of a function within a function
So say I have the lower value and an upper value of an integral that's from the user input. I ask for the lower limit first then I check for its validity. Then in order to compare the value of my upper limit with my lower I made a nested function,…

user3613025
- 373
- 3
- 10
0
votes
0 answers
memory error using scipy.integrate.simps on big-ish (500MB) array on a 64bit machine with enough memory
I am using the scipy simpsons rule in a vectorized way for performance. (I am calculting integrals on a rolling window on a timeseries.)
For some reason I am getting a memory error when using simps on an 500MB array of floats on a 64bit machine…

Mischa Obrecht
- 2,737
- 6
- 21
- 31
0
votes
1 answer
Computing wrong value of integral using simpsons rule
I wrote the following piece of code for Simpson's rule integration to approximate sin. The equation is in this attachment. I wrote separate loops for the even and odd terms, as they are shown grouped in the attachment.
import math…
user8788942
0
votes
1 answer
error in my simpsons rule integration
I have written the following code to use simpson's rule to integrate an arbitrary function, in my case, sin(x):
import math
delta_x=(x2-x1)/N
def simpson(x1,x2,f,N):
sum=0
i=1
for i in range(1,N+1):
sum+=f(x1+i*delta_x)
…
user8788942
0
votes
0 answers
MATLAB Simpson's 1/3 Rule and Romberg
I'm just starting to learn MATLAB.
The purpose of the exercise is to approximate/integrate using Simpson's 1/3 rule and romberg. The problem is to integrate x^(1/2) from 0 to 2
When I execute: simpson(fun,0,2,10)
I get an error on line 2: fun =…

Jean Wong
- 21
- 2
0
votes
0 answers
Write c code to evaluate the integral between 0 and y of (x^2)(e^-x^2)dx using Simpson's rule (use a fixed number of 20,000 steps)
Second part of Q: Then solve the integral between 0 and y of (x^2)(e^(-x^2))dx=0.1 for y using bracketing and bisection.
Here's what I have done so far:
#include
#include
double f(double x, double y);
int main(void) {
int…
0
votes
1 answer
Simpson's Rule returning 0
I coded a function for Simpson's Rule of numerical integration. For values of n more than or equal to 34, the function returns 0.
Here, n is the number of intervals, a is the start point, and b is the end point.
import math
def simpsons(f, a,b,n):
…

fosho
- 1,666
- 6
- 20
- 28