FAQ Database Discussion Community

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

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

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...

Best way to integrate user defined function

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...

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

Integral of piecewise function gives incorrect result

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)

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...

Trapezoidal Integration is not accurate enough in Clojure

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) (*...

How do I print out Integeral values in haskell without warning using show?

When I run the following haskell code with warnings enabled module Main where main :: IO() main = interact (unlines.strout.calc.extinps.words) --calculates factorial factorial :: Integral a=> a->a factorial n = product [1..n] --Extracts numbers from the input extinps ::(Read b)=>[String]->[b] extinps x=map read x --Calculates the factorial calc :: (Integral...

scipy.integrate.quad on arrays of limits

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...

Matlab how define an integral function and find best coefficients

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...

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

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...

Integrate histogram in python?

Is there a simple command in matplotlib that let's me take the integral of histogram over a certain range? If I plot a histogram with: fig = plt.hist(x, bins) Then, is there a command like fig.integral(bin1, bin2)? That will return the integral of the histogram from bin1 to bin2?

Does reinterpret_casting an integral to a pointer type and back yield the same value?

According to http://en.cppreference.com/w/cpp/language/reinterpret_cast, it is known that reinterpret_cast a pointer to an integral of sufficient size and back yield the same value. I'm wondering whether the converse is also true by the standards. That is, does reinterpret_cast an integral to a pointer type of sufficient size and back yield the...