sympy / sympy

A computer algebra system written in pure Python
https://sympy.org/
Other
12.78k stars 4.39k forks source link

Integration of a function of a function #22921

Open fabpan opened 2 years ago

fabpan commented 2 years ago

Hi, I report some results obtained by integrating a function of a function. In this case the result is correct,

import sympy as sy
t,x=sy.symbols('t x',real=True)
a=sy.Function('a', real=True)(t)
I=sy.Integral(a**2,a)
display(sy.Eq(I,I.doit()))
I=sy.Integral(x**2,x)
sy.Eq(I,I.doit())

in these others the results are wrong.

I=sy.Integral(sy.cos(a),a)              
display(sy.Eq(I,I.doit()))                
I=sy.Integral(sy.cos(x),x)              
sy.Eq(I,I.doit())              
I=sy.Integral(1/a,a)
display(sy.Eq(I,I.doit()))                
I=sy.Integral(1/x,x)              
sy.Eq(I,I.doit())              
I=sy.Integral(sy.ln(a),a)
display(sy.Eq(I,I.doit()))                
I=sy.Integral(sy.ln(x),x)              
sy.Eq(I,I.doit())           
oscarbenjamin commented 2 years ago

Current master gives:

In [1]: import sympy as sy
   ...: 
   ...: t, x = sy.symbols("t x", real=True)
   ...: a = sy.Function("a", real=True)(t)

In [2]: sy.Integral(a ** 2, a).doit()
Out[2]: 
 3   
a (t)
─────
  3  

In [3]: sy.Integral(sy.cos(a), a).doit()
Out[3]: sin(a(t))

In [4]: sy.Integral(1 / a, a).doit()
Out[4]: log(a(t))

In [5]: sy.Integral(sy.ln(a), a).doit()
Out[5]: a(t)⋅log(a(t)) - a(t)

I think that this was fixed in #22539