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

a faster way of implementing the nested loop with gamma function

I am trying to evaluate the following integral: I can find the area for the following polynomial as follows: pn = -0.0250 0.0667 0.2500 -0.6000 0 First using the integration by Simpson's rule fn=@(x)…
jkt
  • 2,538
  • 3
  • 26
  • 28
3
votes
2 answers

infinite integration with matlab

I want to compute the following type of integrals in Matlab. It is the integral of function e^-(u)*u and the boundaries are zero and infinity. This integral should return 1. How can I do this in Matlab?
emper
  • 401
  • 1
  • 7
  • 14
3
votes
1 answer

Solving for unknown upper bound of the integral

I am trying to implement an algorithm in R that involves solving for the boundary limit of the integral. For example, I want to find a given the following integral: integral_0^a exp(x) = 1/2 I have a rough idea how to do it in matlab. But how would…
notrockstar
  • 833
  • 3
  • 15
  • 28
3
votes
0 answers

Not nested double integral java library

I am looking for a java library that computes a double integral without having to nest them. I already found a library that allows me to do the following: Integral of x*x*{integral of y*y} for x between 0 and 1 and for y between x and 5 Where i…
shachem
  • 31
  • 3
2
votes
1 answer

calculating integral image(summed area table) for a pixel

In the wikipedia article ,the formula for integral image (summed area table) is given as . Why the negative fourth term? I got a bit confused by this ..Can someone illustrate with an example?
Damon Julian
  • 3,829
  • 4
  • 29
  • 34
2
votes
2 answers

Initialise static const, non-integral, class member with a private member

Im am attempting to initialise a static const non-integral. However it requires parameters which are private. If it was of integral type you could place it in the class body and allow allow one variable to take the value of another ie static const…
McP
  • 813
  • 1
  • 8
  • 16
2
votes
2 answers

Integrating over a min() function gives different result than the function inside

Shouldn't these two results be the same? Why are they not? integrate(\(x) {x * min(-x+10, 10)},lower = 0, upper = 10)$value > [1] 1.085709 integrate(\(x) {x * (-x+10)},lower = 0, upper = 10)$value > [1] 166.6667 Keep in mind that from x values 0…
Victor Nielsen
  • 443
  • 2
  • 14
2
votes
0 answers

Is there a way to get Maxima to show its steps of integration?

I am modeling the methods used by integral-calculator to implement an API that runs maxima commands on a server. So far, setting up integrate(), diff(), and limit() have all gone relatively smoothly, however the end goal is to create a teaching aid…
2
votes
1 answer

Reverse gradient: Integrate two 2d arrays

I have two 2d arrays of electric field components: Ex with (256, 512) and Ez with (256, 512) sizes. I need to calculate scalar potential. Gradient of scalar potential is the electric field vector. So I need the reverse of the gradient. I tried using…
Tara
  • 21
  • 2
2
votes
1 answer

R: double integral with dependencies

My goal is to compute the following double integral in R. I looked at the previous solutions, such as double integral in R. Following the solution by G5W, I came up with the code inner_func <- function(x) { alpha=23 beta=14 …
2
votes
0 answers

How can one obtain more accurate numerical approximations to an integral involving the floor function in Wolfram Alpha?

After reading sections of the following book by Furdui and a page on the AoPS forum, I got interested in the integral                                                                   Let's denote the value of this integral by A. Then we have that…
2
votes
1 answer

Solve optimisation with double integral equation in R

I have an optimisation problem that has a objective function in the form of a double integral. The objective function is: # define objective function fun_obj <- function(a) pracma::integral2(function(x,y) exp(-a[1]*(x - 1/2) - a[2]*(x^2 -…
Pedro Alencar
  • 1,049
  • 7
  • 20
2
votes
1 answer

Julia - double integral

I have two functions written in Julia that I want to integrate and both should give a value very close to 1. They both produce the same type of variables but one integral works and the other doesn't. Can someone help me? The one that works using…
maria96
  • 51
  • 2
2
votes
1 answer

Why does the larger of two curves have the lower integrated value using trapz from numpy?

Using trapz from numpy I get the following: lewis_result_outer = np.trapz(lewis_few_elements_outer_y, x=lewis_few_elements_outer_x) lewis_result_inner = np.trapz(lewis_few_elements_inner_y, x=lewis_few_elements_inner_x) lewis_result =…
EDRM
  • 23
  • 5
2
votes
3 answers

Difference between char in C and C++?

I know that C and C++ are different languages. Code - C #include int main() { printf("%zu",sizeof('a')); return 0; } Output 4 Code- C++ #include int main() { std::cout<
Abhishek Mane
  • 619
  • 7
  • 20