Here's one way to do it using mpmath; there might be better ways:

sage: from mpmath import *
sage: mp.dps = 15; mp.pretty = True
sage: f = lambda x: sqrt(sec(x)-1)
sage: quad(f, [pi/2, pi])
(1.43051518370573e-8 + 3.14159264808335j)

To get back to a sage type you could do:

sage: ans=quad(f, [pi/2, pi])
sage: CC([ans.real, ans.imag])

-Marshall

On Oct 13, 11:01 pm, Oscar Gerardo Lazo Arjona
<algebraicame...@gmail.com> wrote:
> Hello people!
>
> I've been trying to solve this integral:
>
> sage: integrate(sqrt(sec(x)-1),x,pi/2,pi)
> integrate(sqrt(sec(x) - 1), x, 1/2*pi, pi)
>
> Since sage failed to produce a symbolic result, I tried with
> numerical_integral
>
> sage: numerical_integral(sqrt(sec(x)-1),pi/2,pi)
> (nan, nan)
>
> But that failed also... So I tried with mathematica:
>
> sage: mathematica_console()
>          Mathematica 7.0 for Linux x86 (32-bit)
> Copyright 1988-2008 Wolfram Research, Inc.
>
> In[1]:= Integrate[Sqrt[Sec[x]-1],{x,Pi/2,Pi}]
>
> Out[1]= I Pi
>
> So mathematica says it's a pure imaginary number, which I know to be true.
>
> I know that symbolic integration is quite complicated to develop, but
> numerical integration should be fairly easy to extend to complex
> numbers. Am I missing something? Why does numerical_integral return NaN?
> Perhaps i'ts not because of the complex result, in which case how could
> I solve the integral without recurring to mathematica?
>
> thanks!
>
> Oscar.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to