FAQ Database Discussion Community

## Trapezoidal Integration is not accurate enough in Clojure

clojure,integral
So currently, I wrote a Clojure code to do Trapezoidal integration of a polynomial function in HackerRank.com: https://www.hackerrank.com/challenges/area-under-curves-and-volume-of-revolving-a-curv (defn abs[x] (max x (- 0 x)) ) (defn exp[x n] (if (> n 0) (* x (exp x (- n 1))) 1 ) ) (defn fact[x] (if (> x 0) (*...

## Integral of piecewise function gives incorrect result

python,sympy,integral
Using the recent version of sympy (0.7.6) I get the following bad result when determining the integral of a function with support [0,y): from sympy import * a,b,c,x,z = symbols("a,b,c,x,z",real = True) y = Symbol("y",real=True,positive=True) inner = Piecewise((0,(x>=y)|(x<0)|(b>c)),(a,True)) I = Integral(inner,(x,0,z)) Eq(I,I.doit()) This is incorrect as the actual result should...

## Volume of a part of a sphere cutted using 3 planes using R-Language (integral)

r,volume,integral
I want to calculate the volume (V) of a part of sphere, which is the result of intersetion of the sphere with three palnes (x=0, y=0 and z=1.5). I am using R-Language and this is my code. I tried 2 different methods using cartesian and polar coordinates. Both of them...

## SymPy integration, constant term

python,python-2.x,sympy,integral
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 following: f(t1) + Integral(0, (t, 0, t1)) But I expect to see just f(t). Calling...

## C++: How to compute an integral with interval bounds?

c++,algorithm,integral,polynomials
I am both tired, new to C++ and real bad at dealing with polynomials. That's a bad combo for my assignment. Nevertheless I am trying to solve it. Please note that I might have misunderstood certain parts both mathematically and language-wise. Maybe even terminology. The first task of my assignment...

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

python,scipy,sympy,integral
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 with scipy.integrate.nquad. I would like to...

## Matlab how define an integral function and find best coefficients

matlab,integral,best-fit-curve
I would like to find coefficients to best fit the nonlinear functions, and the nonlinear functions was an integral function. So the first step was to define an function: function dT = km(x,sT) [email protected](temp)((-x(1)*x(2)*(temp).^(x(2)-1.0))./ ... ((x(3)^x(2))*((1+(temp./x(3)).^x(2)).^2))); dT=integral(fun,0,sT); % x is a array containing three coefficients; % sT is a array...

## scipy.integrate.quad on arrays of limits

python,arrays,numpy,scipy,integral
quad from scipy.integrate needs the arguments func, a, b. Where func is a function to integrate and a and b is the lower and upper integration limits, respectively. a and b has to be numbers. I have a situation where I need to evaluate the integral of a function for...

## Best way to integrate user defined function

matlab,integral
I would like to evaluate an expression which requires an integral of a user defined function. I have 3 inputs to the integral expression, E,F and B. F and B are values stored in separate arrays. E is the parameter I would like to integrate over, from a value of...

## Fit an integral function with parametric limit to data with Python (Debye Model)

python,python-2.7,python-2.x,integral,data-fitting
I am trying to fit resistivity vs temperature data to Bloch-Gruneisen formula for resistivity in metals: function as you can see there is an integral function with a parametric limit. I don't know how to implement an algorithm to run a least squares fit. I came up with: import matplotlib.pyplot...