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
6
votes
2 answers

Simpson's Rule Integration Negative Area

I am having a problem when using simpson's rule from scipy.integrate library. The Area calculated sometimes is negative even if all the numbers are positive and the values on the x-axis are increasing from left to right. For example: from…
Marco
  • 1,195
  • 3
  • 18
  • 30
4
votes
1 answer

Python: Simpson's rule, negative answer for positive area under the curve?

I have y1=[ 9.49110000e-004 4.74145420e-004 1.41847155e-008 3.33228420e-028 3.76352289e-081 4.48206815e-193 0.00000000e+000 0.00000000e+000 0.00000000e+000 0.00000000e+000 0.00000000e+000] x=[ 112. 111.97667396 …
HuShu
  • 501
  • 6
  • 19
3
votes
0 answers

How to plot area of the integral in Simpson 1/3 rule corresponding to a given curve using c program?

I would like to plot area of the integral in Simpson 1/3 rule corresponding to a given curve using c program? Here is my codes: /* Simpson's 1/3 Rule Equation: x/(1+x) dx lower limit=0 upper limit=1 number of interval=6 …
Primo Raj
  • 109
  • 1
  • 7
3
votes
1 answer

Python numerical integration with Simpson's rule

I have started to work through this book (Computational Physics Exercise 5.4) and its exercises and I got stuck with the following question: Write a Python function J(m,x) that calculates the value of Jm(x) using Simpson’s rule with N = 1000…
Gabor Bakos
  • 182
  • 1
  • 2
  • 8
3
votes
1 answer

Simpson's Rule error

This code is using Simpson's rule to calculate the integral of x*sin(x) with the bounds of (1,2). The problem I am having is, while its getting very close to the actual value. Even with 999 iterations, it still doesn’t hit the point. While I have a…
user3908631
  • 63
  • 1
  • 5
3
votes
1 answer

Numerical integration for unevenly spaced intervals, Python

I would like to do numerical integration for a given set of samples. Let say I have x unevenly spaced regions and y = f(x) is the function I want to integrate. x y=f(x) 0.1 10.5 1.2 2.0 3.7 11.0 7.0 …
Srivatsan
  • 9,225
  • 13
  • 58
  • 83
2
votes
3 answers

Trying to use Simpson's Law in Python

I am trying to write a program about Simpson's Law.What I am trying to do is use as error as shown in this picture: . In the code i write the Ih is my f1 and Ih/2 is my f2.If the error doesnt happen then the steps get halved. However I get this…
Magnus2211
  • 47
  • 6
2
votes
1 answer

Simpson's double integral won't work in java

So I had to write an algorithm for the Simpson's double integral so I can find the answer in a much faster manner. I had a guide that showed the steps to follow to write this program. After following this guide and running it in netbeans, I found…
2
votes
2 answers

Printing a Variable using matplotlib's ax.text prints a list of values instead of a number?

I'm currently trying to make a program which will plot a function using matplotlib, graph it, shade the area under the curve between two variables, and use Simpson's 3/8th's rule to calculate the shaded area. However, when trying to print the…
hakplay
  • 41
  • 1
  • 5
2
votes
2 answers

Simpson rule integration,Python

I wrote this code,but I not sure if it is right.In Simpson rule there is condition that it has to has even number of intervals.I dont know how to imprint this condition into my code. def simpson(data): data = np.array(data) a =…
2
votes
1 answer

Problems in Numerical Integration through R

I have the following function f(x)∝|x| exp(-1/2 |x| )+1/(1+(x-40)^4 ),xϵR I want to find out E(X) and E(X^3) through Simpson's method (numerical integration), Standard Monte Carlo approach, Acceptance-rejection sampling, Importance sampling,…
1
vote
1 answer

Scipy Simpson integration of a positive quantity comes out negative

The following numerical integration of y values that are positive evaluates to a negative integration value using the builtin provided Simpson integration method of Scipy. This is much to my surprise. I'm a beginner on this. Any help would be…
curious
  • 11
  • 3
1
vote
1 answer

Сonvert the coefficients of the Hermite polynomial into a function

I want to make a function from the output of Matlab Hermite function (for example, if we had an output from Hermite function [8 0 -12 0] it would be 8x^3 - 12x polynomial) and then integrate this function using the Simpson's 3/8 Rule. I have already…
lizsav
  • 75
  • 4
1
vote
0 answers

How to perform a numerical integration (with limits) of discrete data in Python using Scipy?

I have an experimental time signal, and I need to compute some integral out of it. In detail, I need to compute the PSD, and then compute the power in some bands of frequencies. So, it seems that scipy is the best way to compute integrals. But the…
phollox
  • 323
  • 3
  • 13
1
vote
1 answer

Finding the integral between two horizontally overlapping curves

I have a code that plots data from a text file. I have been able to get the integrals under each data curve (although I do not know the functions for any of them, so I just used integral = s = simps(y, x)). Two of the curves overlap horizontally,…
1
2 3 4 5