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

Why can't Mathematica solve this definite integral?

When I try to calculate the following integral in Mathematica 8, I get this strange result: In[1]:= Integrate[y/((1 + x^2 + y^2)^(3/2)), {y, 0, 1}] Maple 14 can solve this one easily: Why is Mathematica giving me a different result?
Martin Koller
  • 115
  • 1
  • 5
8
votes
1 answer

Sympy definite integral

I want to integrate the equation: f(x) = integral(E^(-i * omega * t)), from -a to a. I wrote the following code: from sympy import * from sympy.abc import a, omega, t init_printing(use_unicode=False, wrap_line=False, no_global=True) f = E**(-I…
John28
  • 723
  • 3
  • 8
  • 12
7
votes
5 answers

Best way to write a Python function that integrates a gaussian?

In attempting to use scipy's quad method to integrate a gaussian (lets say there's a gaussian method named gauss), I was having problems passing needed parameters to gauss and leaving quad to do the integration over the correct variable. Does anyone…
physicsmichael
  • 4,793
  • 11
  • 35
  • 54
6
votes
2 answers

Simpson's Rule Integration Negative Area

I am having a problem when using simpson's rule from scipy.integrate library. The Area calculated sometimes is negative even if all the numbers are positive and the values on the x-axis are increasing from left to right. For example: from…
Marco
  • 1,195
  • 3
  • 18
  • 30
6
votes
2 answers

Sympy step by step solution of integrals

In doc of sympy http://docs.sympy.org/latest/modules/integrals/integrals.html we can read: The manualintegrate module has functions that return the steps used (see the module docstring for more information). but calling…
asv
  • 3,332
  • 7
  • 24
  • 47
6
votes
3 answers

Converting hard integral to lambda function with lambdify

I would like to lambdify the function Integral(t**t,(t,0,x)). It works, but my new function, which was returned by lambdify, doesn't return a number but only sympy.integrals.integrals.Integral class. But I don't want that, I want it to return a…
lukas kiss
  • 381
  • 2
  • 15
6
votes
1 answer

What causes this error (AttributeError: 'Mul' object has no attribute 'cos') in Python?

I am getting the following error code when trying to evaluate a definite integral in Python. AttributeError Traceback (most recent call last) in () 7 x, n = symbols('x n') …
BMid
  • 61
  • 1
  • 1
  • 2
6
votes
1 answer

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 =…
Lars Melchior
  • 292
  • 1
  • 9
6
votes
2 answers

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.…
Lingxi
  • 14,579
  • 2
  • 37
  • 93
5
votes
2 answers

Most Efficient way to calculate integrals/derivatives of inputted functions in Java?

I now have an idea, that I use the function as a string, and I calculate the real integral by hand, and ask a question to the user what the definite integral is, but that isn't a real solution. I was wondering if there was a way to input a function…
user1162715
5
votes
2 answers

Numerical Triple Integration in R

Is it possible to do triple integration in R without using the cubature package? based on the answer in this post InnerFunc = function(x) { x + 0.805 } InnerIntegral = function(y) { sapply(y, function(z) { integrate(InnerFunc, 15, z)$value })…
maddie
  • 1,854
  • 4
  • 30
  • 66
5
votes
2 answers

Integrate over an integral in R

I want to solve the following in R: ∫0H [π(t) ∫tH A(x) dx ] dt Where π(t) is the prior and A(x) is the A function defined below. prior <- function(t) dbeta(t, 1, 24) A <- function(x) dbeta(x, 1, 4) expected_loss <- function(H){ integrand …
LJB
  • 353
  • 4
  • 10
5
votes
1 answer

Integrating/Integral in R: Find the catch

Ok, so this has me stumped for over more then 3 days and after still not being one step closer to the solution, I'm gonna try my luck here. In the past, I've written some code for one sorted dataset in specific and it goes like this: n <-…
querty
  • 105
  • 4
5
votes
3 answers

Infinite Summation in Python

I have a function for with i need to do an infinite summation on (over all the integers) numerically. The summation doesn't always need to converge as I can change internal parameters. The function looks like, m(g, x, q0) = sum(abs(g(x - n*q0))^2…
user3002273
5
votes
2 answers

Need help plotting this function in Matlab

I recently started using Matlab and I am trying to plot Imaginary part of a function. I can see I am making a mistake somewhere because I have the graph showing what I need to get and I am getting something else. Here is the link of the graph that I…
1
2
3
54 55