Skip to content
New issue

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

Integral that should have closed form is not evaluating #13608

Open
jacluff1 opened this issue Nov 15, 2017 · 6 comments
Open

Integral that should have closed form is not evaluating #13608

jacluff1 opened this issue Nov 15, 2017 · 6 comments

Comments

@jacluff1
Copy link

I have an integral of the form:
t / sy.sqrt( At**2 + Bt + C ),

where:
t = sy.symbols('t', real=True, positive=True)
A,B,C = sy.symbols('A B C', real=True)

when I try to integrate in sympy, it does not evaluate; when I integrate in wolfram alpha, it does. I am writing code in Jupyter Notebook at http://localhost:8888/notebooks/meeting3.ipynb

@Dirivian
Copy link
Contributor

  1. This doesn't evaluate for integrals even when I replace A,B and C with 1.

  2. You linked the local path of your notebook (accessible only to you). If the notebook is important, put it up on github and link it,

@oscarbenjamin
Copy link
Contributor

I get this on master for that general form:

In [3]: A, B, C = symbols('A B C')                                                                                                

In [4]: integrate(t / (A*t**2 + B*t + C), t)                                                                                      
Out[4]: 
                                ⎛            ⎛       _____________      ⎞      ⎛       _____________      ⎞      ⎞              
                                ⎜            ⎜      ╱           2       ⎟      ⎜      ╱           2       ⎟      ⎟              
                                ⎜            ⎜  B╲╱  -4AC + B      12 ⎜  B╲╱  -4AC + B      1 ⎟      ⎟              
⎛       _____________      ⎞    ⎜    - 4AC- ────────────────── + ───⎟ + B - ────────────────── + ───⎟ + 2C⎟   ⎛     _____
⎜      ╱           2       ⎟    ⎜            ⎜       ⎛         22A⎟      ⎜       ⎛         22A⎟      ⎟   ⎜    ╱     
⎜  B╲╱  -4AC + B      1 ⎟    ⎜            ⎝   2A4AC - B ⎠       ⎠      ⎝   2A4AC - B ⎠       ⎠      ⎟   ⎜B╲╱  -4A
⎜- ────────────────── + ───⎟log⎜t + ────────────────────────────────────────────────────────────────────────────⎟ + ⎜──────────
⎜       ⎛         22A⎟    ⎝                                         B                                      ⎠   ⎜     ⎛    
⎝   2A4AC - B ⎠       ⎠                                                                                         ⎝ 2A4A

                   ⎛            ⎛     _____________      ⎞      ⎛     _____________      ⎞      ⎞
                   ⎜            ⎜    ╱           2       ⎟      ⎜    ╱           2       ⎟      ⎟
                   ⎜            ⎜B╲╱  -4AC + B      12 ⎜B╲╱  -4AC + B      1 ⎟      ⎟
________      ⎞    ⎜    - 4AC⎜────────────────── + ───⎟ + B ⎜────────────────── + ───⎟ + 2C⎟
      2       ⎟    ⎜            ⎜     ⎛         22A⎟      ⎜     ⎛         22A⎟      ⎟
C + B      1 ⎟    ⎜            ⎝ 2A4AC - B ⎠       ⎠      ⎝ 2A4AC - B ⎠       ⎠      ⎟
──────── + ───⎟log⎜t + ────────────────────────────────────────────────────────────────────────⎟
     22A⎟    ⎝                                       B                                    ⎠
C - B ⎠       ⎠                                                                                  

Probably a simpler output is possible if you say what A, B and C should be.

Is this still an issue or should I close it?

@asmeurer
Copy link
Member

I get the same. And simplify(integrate(t / (A*t**2 + B*t + C), t).diff(t)) produces the original expression. I think it can be closed, unless we want to add a test for it.

@oscarbenjamin
Copy link
Contributor

It's possible that @jacluff1 had a particular combination of coefficients that caused trouble. We should allow time to respond.

I'm going to create a label "could-close" for this situation - after some time if there is no response it can be closed.

@jksuom
Copy link
Member

jksuom commented Feb 28, 2019

I think that there is currently no support for completing the square in sqrt(A*t**2 + B*t + C). With B = 0, manualintegrate will find an antiderivative.

@oscarbenjamin
Copy link
Contributor

Good point @jksuom :)

I missed off the square root:

In [31]: A, B, C = symbols('A B C')                                                                                               

In [32]: integrate(t / sqrt(A*t**2 + B*t + C), t)                                                                                 
Out[32]: 
⌠                       
⎮          t            
⎮ ─────────────────── dt
⎮    ________________   
⎮   ╱    2              
⎮ ╲╱  At  + Bt + C    
⌡  

With B=0 it does work:

In [33]: integrate(t / sqrt(A*t**2 + C), t)                                                                                       
Out[33]: 
⎧   __________           
⎪  ╱    2                
⎪╲╱  At  + C            
⎪─────────────  for A  0
⎪      A                 
⎨                        
⎪      2                 
⎪     t                  
⎪    ────       otherwise
⎪    2⋅√C                
⎩   

So I guess the issue is adding support for completing the square inside the square root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants