# sympy/sympy

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

# integrate(sin(x)**3/x, (x, 0, 1)) can't do it #8945

Closed
opened this Issue Feb 4, 2015 · 14 comments

## Comments

Projects
None yet
3 participants
Member

### certik commented Feb 4, 2015

 But the answer is given below in [15]: ``````In [13]: integrate(sin(x)**3/x, (x, 0, 1)) Out[13]: 1 ⌠ ⎮ 3 ⎮ sin (x) ⎮ ─────── dx ⎮ x ⌡ 0 In [14]: Integral(sin(x)**3/x, (x, 0, 1)).n() Out[14]: 0.247399170775520 In [15]: Si(1)*3/4-Si(3)/4 Out[15]: Si(3) 3⋅Si(1) - ───── + ─────── 4 4 In [16]: _.n() Out[16]: 0.247399170775520 `````` Once this is fixed, try higher powers of `sin(x)^n/x` for integer `n`.

Member

### asmeurer commented Feb 4, 2015

 This is the definite integral: http://www.wolframalpha.com/input/?i=integrate(sin(x)**3%2Fx%2C+x)&dataset=. I would expect the meijerg algorithm to be able to do this.
Member

Contributor

### darkcoderrises commented Feb 9, 2015

 Can i work on this?
Member

### certik commented Feb 9, 2015

 Of course! Sent from my mobile phone. On Feb 9, 2015 4:22 AM, "Harshil Goel" notifications@github.com wrote: Can i work on this? — Reply to this email directly or view it on GitHub #8945 (comment).
Contributor

### darkcoderrises commented Feb 10, 2015

 Is was thinking that we can implement something like, for all undefined defined integrals we have we manually calculate the area i.e. for (x = lowerlimit; x
Member

### certik commented Feb 10, 2015

 Yes, that's implemented by `.n()` (in a much more robust way), see the cell [14] in the issue description for an example of usage.
Contributor

### darkcoderrises commented Feb 10, 2015

 Oh okay,thanks
Contributor

### darkcoderrises commented Feb 11, 2015 • edited by asmeurer

 ``````In [43]: f = sin(x)**3/x In [44]: g =mellin_transform(f, x, s) In [45]: l=inverse_mellin_transform(g[0], s, x, (0, 1)) In [46]: integrate(l,(x,0,1)) Out[46]: Si(3) 3*Si(1) - ----- + ------- 4 4 In [47]: _.n() Out[47]: 0.247399170775520 ``````
Contributor

### darkcoderrises commented Feb 11, 2015

 for the functions which do not have a mellin transform (like e^(x**2)), we can see that type(g) = sympy.integrals.transforms.MellinTransform else type(g) = tuple
Member

### certik commented Feb 11, 2015

 Nice. Essentially you are rewriting the `sin^3(x)` to an equivalent expression.
Contributor

### darkcoderrises commented Feb 11, 2015

 can someone help me in finding where to implement it.

Closed

Member

### certik commented Feb 11, 2015

 I think the integration subroutine needs to be fixed to handle this integral. I don't think it should call the Mellin transform.
Contributor

### darkcoderrises commented Feb 11, 2015

 Okay, Where should i start looking then?
Member

### asmeurer commented Feb 12, 2015

 You're welcome to try extending the meijerg algorithm, but a simpler way to fix this would be to add it to manualintegrate.

Merged

### skirpichev added a commit to skirpichev/diofant that referenced this issue Aug 26, 2018

``` Convert trig products/powers to sums when integration requires ```
```At a final stage of integration, if all methods failed so far, the
expression is currently turned into an Add with `expand`. This PR
amplifies this transformation to Add by also converting products/powers
of sin and cos to their sums. For example, sin(x)**3/x or cos(x)**4/x**3
are now integrated, while they return unevaluated in current master.

To this end, two methods are added to simplify.fu: TRpower, which
implements power reduction formulas, and `sincos_to_sum`, which applies
TRpower followed by expand_mul followed by TR8 (products to sums)

Additionally, a `sincos_to_sum` rewrite is added to the list of rewrites
that meijerint_definite attempts for integrals over (0, oo).

// edited by skirpichev

Closes sympy/sympy#8945
Closes diofant#303```
``` c6ee099 ```

### skirpichev added a commit to skirpichev/diofant that referenced this issue Aug 27, 2018

``` Convert trig products/powers to sums when integration requires ```
```At a final stage of integration, if all methods failed so far, the
expression is currently turned into an Add with `expand`. This PR
amplifies this transformation to Add by also converting products/powers
of sin and cos to their sums. For example, sin(x)**3/x or cos(x)**4/x**3
are now integrated, while they return unevaluated in current master.

To this end, two methods are added to simplify.fu: TRpower, which
implements power reduction formulas, and `sincos_to_sum`, which applies
TRpower followed by expand_mul followed by TR8 (products to sums)

Additionally, a `sincos_to_sum` rewrite is added to the list of rewrites
that meijerint_definite attempts for integrals over (0, oo).

// edited by skirpichev

Closes sympy/sympy#8945
Closes diofant#303```
``` 81b6770 ```
to join this conversation on GitHub. Already have an account? Sign in to comment