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
3
votes
1 answer

Get polynomial coefficients from interpolation splines in R

I have a set of measured values that I'd liked to interpolate in R using cubic splines. Since these are just piecewise polynomials I'd subsequently like to integrate the interpolation function algebraically. Therefore I need the coefficients. Is…
Thomas Neitmann
  • 2,552
  • 1
  • 16
  • 31
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
2 answers

Error using integral: A and B must be floating-point scalars

I want to evaluate the simple example of integral a = max(solve(x^3 - 2*x^2 + x ==0 , x)); fun = @(x) exp(-x.^2).*log(x).^2; q = integral(fun,0,a) and the error is Error using integral (line 85) A and B must be floating-point scalars. Any tips?…
3
votes
1 answer

Output integral to ostringstream as binary?

I just realized that one can use bitset to output binary data to a stream based on the (fixed) size of the bitset. What's the least-extra-syntax way to output binary data to a stream using integrals? To show what I mean, here's a program and its…
plong
  • 1,723
  • 3
  • 14
  • 14
3
votes
1 answer

Boole's rule for N intervals (C)

I am attempting to implement Boole's rule over n intervals using this formula So far I have developed this code: //f = function on the range [a,b] n = number of intervals long double booles(long double (*f) (long double), double…
CodeMonkey
  • 268
  • 5
  • 16
3
votes
1 answer

Integrate function in R returns error

I have a function defined as tail <- function(x) {585.1961*x^-2.592484} When I tried to get the integral of it from 5000 to Inf, it returns an error: > integrate(tail, 5000, Inf) Error in integrate(tail, 5000, Inf) : the integral is probably…
Zebra Propulsion Lab
  • 1,736
  • 1
  • 17
  • 28
3
votes
1 answer

Speed up Matlab integral calculation using either symbolic or numeric methods?

I'm a Matlab beginner as of two months ago. I used it for my summer project to process MRI images. Recently, I wrote code for the integration shown below. However, both methods are extremely slow. It took a day to run them. How can I improve them to…
Paul Cai
  • 33
  • 1
  • 3
3
votes
3 answers

Computing integral of a line plot in R

I have two positive-valued vectors x,y of the same length in R. Using plot(x, y, "l",...), gives me a continuous line plot in 2 dimensions out of my finite vectors x and y. Is there a way to compute a definite integral over some range of this line…
mt88
  • 2,855
  • 8
  • 24
  • 42
3
votes
1 answer

calculate an integral in python

I need to calculate an integral in python. I have imported sympy. g(a,z) = integral_from_z_to_inf of ( t^(a-1) * e^(-1)) in python: x,a,z = symbols('x a z') g = integrate(x**(a-1) * exp(-x), z, oo) I got error: ValueError: Invalid limits…
user3440244
  • 371
  • 1
  • 3
  • 15
3
votes
1 answer

How to numerically calculate value of complex function given derivative of this function in Haskell?

Given: Haskell Complex-valued function df/dz defined on complex plane U (let's say z is a Complex Double). Point z1 from the U on which df/dz is defined. Question: How to get value of function f(z) for which df/dz is a derivative, in point z1? I.…
hijarian
  • 2,159
  • 1
  • 28
  • 34
3
votes
2 answers

Integration of 0-th order Bessel function using MATLAB

I have simple question. I'm trying to evaluate improper integral of 0th order Bessel function using Matlab R2012a: v = integral(@(x)(besselj(0, x), 0, Inf) which gives me v = 3.7573e+09. However this should be v = 1 in theory. When I'm trying to do…
3
votes
3 answers

LaTeX puts too much space next to integrals

Integrals with limits take up width horizontally that includes their limits. In other words, if you have an integral with large limits below (or above) the integral \int\limits_{-\infty < x < c} (c - x) \ dP(x) you are left with a large amount of…
Dan
  • 528
  • 2
  • 6
  • 14
3
votes
1 answer

Benchmark integral vs. Double integral procedure

I've got a question about the implementation of a double integral in MATLAB. It's known that Making use of k1 = 1E-04:0.001:1E+04; k2 = 1E-04:0.001:1E+04; k3 = 1E-04:0.001:1E+04; the above procedure(calling the formula of F11,F22 and F33) leads to…
fpe
  • 2,700
  • 2
  • 23
  • 47
3
votes
1 answer

How to use MATLAB to numerically solve equation with unknown embedded in integral?

I've been trying to use MATLAB to solve equations like this: B = alpha*Y0*sqrt(epsilon)/(pi*ln(b/a)*sqrt(epsilon_t))*integral from 0 to pi of …
user1880273
  • 31
  • 1
  • 2
3
votes
2 answers

Integral Calculation

I would like to perform what follows: where The parameters shown in the latter figure can be obtained as follows: %% Inizialization time = 614.4; % Analysis Time Uhub = 11; HubHt = 90; alpha = 0.14; TI = 'A'; % Turbulent Intensity (A,B,C as in the…
fpe
  • 2,700
  • 2
  • 23
  • 47