Questions tagged [simpsons-rule]

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.

63 questions
1
vote
1 answer

Why is my approximation too large using Composite Simpson's rule in R (numerical integration)?

I am trying to approximate the following integral, using numerical integration in R: , where the function mu is defined by this formula: To do this, I have implemented the Composite Simpson's rule as a function in R, which takes as parameters a…
1
vote
2 answers

Composite Simpson's Rule in C++

I've been trying to write a function to approximate an the value of an integral using the Composite Simpson's Rule. template double simp_rule(double a, double b, int n, func_type f){ int i = 1; double area = 0; double…
AJ09
  • 37
  • 1
  • 5
1
vote
1 answer

Simpson's Rule using for loops (numerical integration)

I am trying to code Simpson's Rule in python using for loops and I keep getting an assertion error and cant find out why. def integrate_numeric(xmin, xmax, N): xsum = 0 msum = 0 h = (xmax-xmin)//N for i in range(0, N): xsum…
1
vote
1 answer

Numerical Integration Using Fortran 90

I'm trying to use Simpson's rule to evaluate the integral of sqrt(1-x^2) in the interval from -1 to 1. However, the sum represented by the variable "s", in the code that I developed, doesn't converge at all to pi over 2. I'm an absolute novice to…
1
vote
1 answer

What do I need to change to my Simpson's Rule Fortran code to get the correct results?

I am trying to implement a piece of code to get the area under a curve by getting the integral using Simpson's Rule. !(file:///D:/1-%20TUD/Semester%201/Numerical%20Methods%20BIWO-04/Lectures/simpson's%20rule.JPG) I have already tried it using…
1
vote
1 answer

Problem using Simpson's integration rule in GAMS

I have made a simple code using GAMS which determines the maximum reach of a glider using trapeziod integration. I want to recreate the same program with SImpson's integration, however, I cannot understand the results. This is the functional code…
slow_learner
  • 337
  • 1
  • 2
  • 15
1
vote
1 answer

How to integrate Simpsons rule using Scipy to plot a 1D graph

i need some help, i have an assignment to code an integration of a function using simpsons rule. I need to use the inbuilt scipy integratesimps function to plot a 1D graph. I just don't know where to start. I think i have to get a list/array of each…
M.B
  • 13
  • 4
1
vote
1 answer

Simpson's Rule Takes Forever to Run in Python

I've written the following function for estimating the definite integral of a function with Simpson's Rule: def fnInt(func, a, b): if callable(func) and type(a) in [float] and type(b) in [float]: if a > b: return -1 *…
1
vote
1 answer

Simpson's method integration scipy.integrate.simps

I'm learning about using simpson's method for integration. I've been reading material to learn the basis of using it but I am still having trouble even getting it to work import numpy as np import scipy.integrate as integrate x = np.array[0.1,50]…
0
votes
0 answers

Scipy Simpsons Function - Output not matching expectations

I am attempting to use the scipy Simpson function to integrate timeseries data, but I am having doubts about the value it returns as it doesn't match up with what I am expecting to get. Here is my data. It's just one column of timestamps and one…
0
votes
1 answer

How do I use nested integral functions to find a double integral in fortran?

I am trying to find the volume under a shape defined by h(x,y) I have the following function which uses the Simpson Rule to integrate a one-dimensional function !---------------------------------------------------------------------------- double…
0
votes
1 answer

Why cant I find the sin of a function with arange in python (jupyter notebook)

Hey! I'm trying to solve an integration question but I keep on getting a long error. from numpy import * from sympy import * from scipy.integrate import simps a = 0 #bottom bound b = pi/2 #upper bound n = 200 #interval dx = (b-a)/n #given in the…
0
votes
2 answers

I receive three different warnings in scipy integration in python

I have the code structure below. I would like to get some numerical results here. import numpy as np import scipy from scipy import integrate alpha = .99 t = np.linspace(0, .85, 5) s = np.empty_like(t) f = np.power(t - s, -alpha) Int =…
Nurdan
  • 9
  • 4
0
votes
0 answers

Cant exit while loop on Simpson's Rule

I am trying to calculate an integral using Simpson's Rule formula.The catch is that the value of the integral is the one that satisfies the following condition:You find the Ih and Ih/2.If the absolute of (Ih-Ih/2)
Magnus2211
  • 47
  • 6
0
votes
1 answer

Why is my Simpson's modelling not giving the correct answer?

I've been trying to do some Simpson's modelling to approximate integrals and although my code runs fine, it doesn't seem to give the correct answer. I'm new-ish to coding so I understand it's probably a dumb mistake but I can't figure out what's…
Adam P
  • 1
  • 1