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
31
votes
5 answers

Split decimal variable into integral and fraction parts

I am trying to extract the integral and fractional parts from a decimal value (both parts should be integers): decimal decimalValue = 12.34m; int integral = (int) decimal.Truncate(decimalValue); int fraction = (int) ((decimalValue -…
invarbrass
  • 2,023
  • 4
  • 20
  • 23
29
votes
4 answers

Why is numeric_limits::max() > numeric_limits::infinity()?

I was reading Setting an int to Infinity in C++. I understand that when one needs true infinity, one is supposed to use numeric_limits::infinity(); I guess the rationale behind it is that usually integral types have no values designated for…
legends2k
  • 31,634
  • 25
  • 118
  • 222
19
votes
2 answers

calculating double integrals in R quickly

I'm looking for a solution for a double integral that is faster than integrate(function(y) { sapply(y, function(y) { integrate(function(x) myfun(x,y), llim, ulim)$value }) }, llim, ulim) with eg myfun <- function(x,y) cos(x+y) llim <-…
Joris Meys
  • 106,551
  • 31
  • 221
  • 263
17
votes
2 answers

How can I increase the number of subdivisions for functions in `scipy.integrate.dblquad`?

I'm using scipy.integrate.dblquad, and I get this error: UserWarning: The maximum number of subdivisions (50) has been achieved. If increasing the limit yields no improvement ... I want to increase this limit to see if the integral is…
Dan
  • 12,157
  • 12
  • 50
  • 84
16
votes
2 answers

double integral in R

I'm wondering how to code that takes double integrals in R. I already referred two similar questions. calculating double integrals in R quickly double integration in R with additional argument But I'm still confused how I can get my question from…
moggirio
  • 161
  • 1
  • 1
  • 4
15
votes
4 answers

Python function to find the numeric volume integral?

Goal I would like to compute the 3D volume integral of a numeric scalar field. Code For this post, I will use an example of which the integral can be exactly computed. I have therefore chosen the following function: In Python, I define the…
henry
  • 875
  • 1
  • 18
  • 48
14
votes
2 answers

Double integral with variable boundaries in python Scipy + sympy (?)

The full mathematical problem is here. Briefly I want to integrate a function with a double integral. The inner integral has boundaries 20 and x-2, while the outer has boundaries 22 and 30. I know that with Scipy I can compute the double integral…
gc5
  • 9,468
  • 24
  • 90
  • 151
13
votes
1 answer

Closest integer to floating-point value in C++03

For some integer type, how can I find the value that is closest to some value of a floating-point type even when the floating point value is far outside the representable range of the integer. Or more precisely: Let F be a floating-point type…
Kristian Spangsege
  • 2,903
  • 1
  • 20
  • 43
12
votes
2 answers

Fitting data with integral function

When using curve_fit from scipy.optimize to fit a some data in python, one first defines the fitting function (e.g. a 2nd order polynomial) as follows: def f(x, a, b): return a*x**2+b*x And then proceeds with the fitting popt, pcov =…
user4587874
12
votes
6 answers

I don't understand Integral part of PID controller

I dont understand integral part of PID controller. Let's assume this pseudocode from Wikipedia: previous_error = 0 integral = 0 start: error = setpoint - measured_value integral = integral + error*dt derivative = (error - previous_error)/dt …
user561838
  • 331
  • 1
  • 4
  • 8
12
votes
2 answers

Haskell Converting Int to Float

I'm having some problem with one of the functions which I'm new at, it's the fromIntegral function. Basically I need to take in two Int arguments and return the percentage of the numbers but when I run my code, it keeps giving me this…
11
votes
3 answers

How to keep fractions in your equation output

I've been using Python to calculate math equations. For example: from sympy import Symbol, Derivative, Integral x = Symbol('x') d = Symbol('d') Integral(8*x**(6/5)-7*x**(3/2),x).doit() Which results in the output: 3.63636363636364*x**2.2 -…
d84_n1nj4
  • 1,712
  • 6
  • 23
  • 40
11
votes
4 answers

Having problems implementing mathematical equations in programming

I am implementing an algorithm for school and am having problems understanding how a definite integral is represented in programming. For example I know that the Summation equation can be implemented as the following example: assuming…
user1327159
  • 151
  • 1
  • 8
10
votes
2 answers

How to speed up symbolic derivatives of long functions using SymPy?

I am writing a program in Python to solve the Schrödinger equation using the Free ICI Method (well, SICI method right now... but Free ICI is what it will turn into). If this does not sound familiar, that is because there is very little information…
Shrodinger149
  • 123
  • 1
  • 7
9
votes
2 answers

Using scipy to perform discrete integration of the sample

I am trying to port from labview to python. In labview there is a function "Integral x(t) VI" that takes a set of samples as input, performs a discrete integration of the samples and returns a list of values (the areas under the curve) according to…
user1425750
  • 93
  • 1
  • 1
  • 3
1
2 3
54 55