Ask Your Question
1

integral not simplifying

asked 2021-10-24 20:46:45 +0100

zahar gravatar image

updated 2021-10-24 21:32:44 +0100

hello, can anyone please explain why the first integral works but the second doesnt? even thought that they are both the same (only minus in different places):

sage: x = var('x')
sage: f = -(x - 1)*((x - 1)^2/((x - 1)^2 + 1)^2 + 1/((x - 1)^2 + 1)^2)/sqrt((x - 1)^2 + 1)
sage: integrate(f, x)
-integrate((x - 1)*((x - 1)^2/((x - 1)^2 + 1)^2 + 1/((x - 1)^2 + 1)^2)/sqrt((x - 1)^2 + 1), x)
sage: f = (x - 1)*((x - 1)^2/((x - 1)^2 + 1)^2 + 1/((x - 1)^2 + 1)^2)/sqrt((x - 1)^2 + 1)
sage: -integrate(f, x)
1/sqrt((x - 1)^2 + 1)

only full simplify somehow helps:

sage: f = -(x - 1)*((x - 1)^2/((x - 1)^2 + 1)^2 + 1/((x - 1)^2 + 1)^2)/sqrt((x - 1)^2 + 1)
sage: f.simplify()
-(x - 1)*((x - 1)^2/((x - 1)^2 + 1)^2 + 1/((x - 1)^2 + 1)^2)/sqrt((x - 1)^2 + 1)
sage: f.full_simplify()
-(x - 1)/(x^2 - 2*x + 2)^(3/2)
sage: integrate(f.full_simplify(), x)
1/sqrt(x^2 - 2*x + 2)

so basically the answer is to do full simplify, but i cant do full simplify on a vector (my original problem is to do this integral on vector):

sage: v = vector([x , 1 , 2])
sage: v.full_simplify()
... 'FreeModule_ambient_field_with_category.element_class' object has no attribute 'full_simplify'

so how can i avoid sagemath from returning me the "integrate(...)" thing and just do the integral?

edit retag flag offensive close merge delete

Comments

Both works fine for me in sage 9.5.beta4. Which version of sage do you use ?

FrédéricC gravatar imageFrédéricC ( 2021-10-24 21:16:23 +0100 )edit

SageMath version 9.2, Release Date: 2020-10-24 Using Python 3.7.7

zahar gravatar imagezahar ( 2021-10-25 07:35:15 +0100 )edit
1

You should use a more recent version of sage. For the second point :

sage: v = vector(SR,[x,cos(x)**2+sin(x)**2,(x**3-1)/(x-1)]); v
(x, cos(x)^2 + sin(x)^2, (x^3 - 1)/(x - 1))
sage: v.apply_map(lambda c:c.simplify_full())
(x, 1, x^2 + x + 1)
FrédéricC gravatar imageFrédéricC ( 2021-10-25 13:06:12 +0100 )edit

thank you for the simplifying method! i upgraded to sage 9.4 (latest that i found for linux), and now i dont have that problem anymore! my first issue is solved and everything works, but now i have a new problem which is very familiar:

sage: a,b = var('a,b')
sage: integrate((((a - b)^2/(abs(-a + b)^2 + 1) - 1)^2 + (a - b)^2/(abs(-a + b)^2 + 1)^2)/(abs(-a + b)^2 + 1)^(3/2), b)
integrate((a^4 - 4*a^3*b + 6*a^2*b^2 - 4*a*b^3 + b^4 - 2*a^2*abs(a - b)^2 + 4*a*b*abs(a - b)^2 - 2*b^2*abs(a - b)^2 + abs(a - b)^4 - a^2 + 2*a*b - b^2 + 2*abs(a - b)^2 + 1)/(abs(a - b)^2 + 1)^(7/2), b)
sage: (previous output)
(some long good ...
(more)
zahar gravatar imagezahar ( 2021-10-25 20:40:16 +0100 )edit

In sage 9.5.beta4, this works fine. But you would need to compile from source. Or wait for the release of sage 9.5.

sage: sage: a,b = var('a,b')
sage: integrate((((a - b)^2/(abs(-a + b)^2 + 1) - 1)^2 + (a - b)^2/(abs(-a + b)^2 + 1)^2)/(abs(-a + b)^2 + 1)^(3/2), b)
-1/3*(2*a^3 - (6*a^2 - 2*(3*a - b)*b + 3)*b + 3*a)/((a - b)^2 + 1)^(3/2)
FrédéricC gravatar imageFrédéricC ( 2021-10-25 20:52:50 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2021-11-02 20:05:26 +0100

zahar gravatar image

upgrading to SageMath version 9.5.beta5 really solved the problems. thank very much to FrédéricC for the help !

edit flag offensive delete link more

Comments

Thanks for flagging your answer to your own question for future users !

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-11-03 10:27:56 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-10-24 20:46:45 +0100

Seen: 774 times

Last updated: Nov 02 '21