Questions tagged [integral]

This tag should be used for questions related to coding solutions for integrals.

In numerical analysis field, algorithms for integration are a typical example of use for this tag. See also:

819 questions
4
votes
1 answer

SymPy integration, constant term

I can't understand behavior of sympy.integrate() function. The simplest example, integrate and differentiate: t = sy.Symbol('t') t1 = sy.Symbol('t1') f = sy.Function('f')(t) I = sy.integrate(f, (t, 0, t1)) f1 = I.diff(t1) print f1 prints the…
Maksim Surov
  • 603
  • 6
  • 22
4
votes
3 answers

Integral of Intensity function in python

There is a function which determine the intensity of the Fraunhofer diffraction pattern of a circular aperture... (more information) Integral of the function in distance x= [-3.8317 , 3.8317] must be about 83.8% ( If assume that I0 is 100) and when…
Saeed
  • 141
  • 2
  • 13
4
votes
1 answer

How to compute integration of a function in apache commons math3 library?

I am trying to integrate a very simple function. integral(x.dx). Instead of getting an answer of 1, I am getting an answer as 0, or 0.5 when I include limits from 0 to 1. Is there something I misunderstand about the implementation of the integration…
mtleis
  • 712
  • 1
  • 9
  • 28
4
votes
2 answers

Accuracy of numerical integration in Matlab

I am trying to integrate an analytic function (a composite of sqrt and trig function) on a rectangle area. It has no singularity point in the area and seems to be a perfect candidate to use dblquad. My question is how to evaluate the accuracy of the…
4
votes
2 answers

C# integral types inconsistency

I just started reading up on the C# language, and one of the first sections in my reading material is, naturally, variables and types. In short order I came across the integral types table, which listed sbyte, byte, short, ushort, int, uint, long,…
grimman
  • 170
  • 4
3
votes
2 answers

Best method of calculating the integral of a function in PHP?

I am making a normal distribution calculator in PHP, but I can't figure out how to calculate the integral of a function using PHP. I've searched the web and stackoverflow, but I can't find anything on the topic. The closest I've come is via…
Simon
  • 171
  • 3
  • 13
3
votes
3 answers

Indefinite integral of 1/(L-x) dx in sympy python

I tried to calculate the indefinite integral of 1/(L-x)dx in sympy: from sympy import * x, L = symbols('x L') f = 1/(L-x) integrate(f, x) it returned: -log(-L + x) while it should be: -log(L-x) Is it related to sympy or I missed something,…
Hadi Pourbagher
  • 151
  • 1
  • 5
3
votes
1 answer

Double integral in R with variable in the bound

How can the below integral be calculated in R? : The difficulty is that in the inner integral the upper bound contains one of the variables. Anyone knows ? The result must be : 0.0104166666666667
Homer Jay Simpson
  • 1,043
  • 6
  • 19
3
votes
1 answer

Double integrate in R

I would like to ask if any of you guys can help me find how can I compute a double integral of a given joint distribution e.g. dnorm(x,m1,s1)*dnorm(y,m2,s2)*CopulaDensity with Ymin=-inf, Ymax=inf, and Xmin= x and Xmax = inf? I want to do this in…
Giorgos
  • 31
  • 2
3
votes
3 answers

How to solve "non-numeric argument.." error in numerical integration?

I want to calculate the following integral in R. I tried to use Vectorize and integrate functions but I got error Error in (log(z)) * (InIntegl2) : non-numeric argument to binary operator fxyz= function(x,y,z) { (x*y*z)+z+x+2*y} InIntegl1 =…
Adam
  • 131
  • 6
3
votes
0 answers

Integrating 2D data with nans using numpy trapz

I have a 2D matrix U of data that looks something like this: 0 0.5 0.1 0.3 0 nan 0.4 0.1 nan nan 0.2 nan The rows index corresponds to height axis data points zz = [0, 2, 10] and the columns are the horizontal axis data points yy =…
ValientProcess
  • 1,699
  • 5
  • 27
  • 43
3
votes
1 answer

How to reduce integration time for integration over 2D connected domains

I need to compute many 2D integrations over domains that are simply connected (and convex most of the time). I'm using python function scipy.integrate.nquad to do this integration. However, the time required by this operation is significantly large…
SMA.D
  • 161
  • 1
  • 11
3
votes
1 answer

Double Integral implementation in R

I've working on double integrals using mosaicCalc package in R. I'm having trouble getting the correct result of the second double integral. This is the code of the first double integral which yields to the correct result (pi). one = makeFun(1 ~ y…
Dessel
  • 33
  • 4
3
votes
5 answers

Python (SymPy, SciPy), create symbol lambda from string

I've struggling to take text inputs of an equation and evaluate it as a definite integral. I need a callable function to pass to scipy.integrate. eq = "x**2" func = lambda x: eq func(2) # outputs: # x**2 # but if I: func = lambda x:…
Nona Urbiz
  • 4,873
  • 16
  • 57
  • 84
3
votes
2 answers

Calculating area under curve from x, y coordinates

Say I have two lists called x and y, both which contain numbers (coordinates), say that: x = [0, 1, 2, 3, 4, 4, 5] y = [0, 1, 3, 3, 5, 6, 7] I would need to calculate the area under the curve that is formed when combining these two lists to (x, y)…