integral of 1/x, tan x

i like this post (click again to cancel)
i dont like this post (click again to cancel)

why integral ($ $$1/x$, $x$) returns $log(x)$? Shouldn't it return $log(|x|)$. Similarly, integral$(tan(x),x)$ returns $log(sec(x))$ shouldn't it return $log(|sec(x)|)$. Can anyone explain?

After previous post, I dig a little bit and find:

 sage: equation=integral(1/x+x,x).real()
 sage: equation
 1/2*real_part(x)^2 - 1/2*imag_part(x)^2 + log(abs(x))

Now, anyway to set real_part(x)=x and imag_part(x)=0 in "eq" and get the resultant "eq"?


sage: integral(1/(x^3-1),x).real()
-1/3*sqrt(3)*real_part(arctan(1/3*(2*x + 1)*sqrt(3))) + 1/3*log(abs(x - 1)) - 1/6*log(abs(x^2 + x + 1))

Everything is fine in the above computation except the word "real_part". Anyway to get rid of that?

asked Mar 16 '11

Shu gravatar image Shu
153 4 9 19

updated Apr 28 '11

Kelvin Li gravatar image Kelvin Li
453 1 10 17
i like this answer (click again to cancel)
i dont like this answer (click again to cancel)

The default backend for symbolic integration is Maxima. You can find out more about the Maxima interface here:

In Maxima, there is a global flag called logabs which changes the default behavior when integrating functions like 1/x or tan(x). Here is how you can get Maxima (via Sage) to return the anti-derivative of 1/x on its full natural domain:

sage: x=var('x')
sage: maxima.eval('logabs:true')
sage: maxima.integrate(1/x,x)
sage: maxima.integrate(tan(x),x)

I don't know if there is currently a way to accomplish this through the Sage integrate function directly. I do know that for definite integrals, log(abs(x)) is used as an anti-derivative of 1/x:

sage: integrate(1/x, x)
sage: integrate(1/x, x, -2, -1)

which is correct.


posted Mar 16 '11

benjaminfjones gravatar image benjaminfjones
2555 4 36 67
maybe 'logabs:true' should be set by default in Sage's maxima environment -- what do you think? On the other hand, if setting such global flags is an important part of working with maxima, maybe Sage should add functionality for setting and using them natively, rather than trying to find a default setting everyone will like niles (Mar 16 '11)
Ordinarily we try to stay away from that sort of thing unless absolutely (hee-hee) necessary, but this has come up before. See - I don't see any obvious negative side effects. At the same time, this has been the behavior for a LONG time, and it would be worth bringing up on sage-devel if you want to do it. kcrisman (Mar 18 '11)

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
Login/Signup to Post

Question tools



Asked: Mar 16 '11

Seen: 643 times

Last updated: Mar 16 '11

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.