Ask Your Question
1

integral of 1/x, tan x

asked 2011-03-16 05:13:20 -0500

Shu gravatar image

updated 2011-04-28 11:27:49 -0500

Kelvin Li gravatar image

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))
 sage:

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

More>>

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?

edit retag flag offensive close delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2011-03-16 09:34:05 -0500

benjaminfjones gravatar image

The default backend for symbolic integration is Maxima. You can find out more about the Maxima interface here: http://www.sagemath.org/doc/reference/sage/interfaces/maxima.html

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)
log(abs(x))
sage: maxima.integrate(tan(x),x)
log(sec(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)
log(x)
sage: integrate(1/x, x, -2, -1)
-log(2)

which is correct.

edit flag offensive delete publish link more

Comments

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 ( 2011-03-16 10:36:24 -0500 )edit
Ordinarily we try to stay away from that sort of thing unless absolutely (hee-hee) necessary, but this has come up before. See http://maxima.sourceforge.net/docs/manual/en/maxima_14.html - 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 ( 2011-03-18 15:09:53 -0500 )edit

Your Answer

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

Add Answer

[hide preview]

Stats

Asked: 2011-03-16 05:13:20 -0500

Seen: 669 times

Last updated: Mar 16 '11