sage: (integrate(exp(-x^2)*cos(x),(x,-pi,pi))/pi).n()
complains that "Unable to convert 3.14159265358979 - 0.500000000000000*I
to float". Which is odd, given that I'm integrating a real-valued
function. But it gets weirder: if I try to use .abs(), it *still* complains:
sage: (integrate(exp(-x^2)*cos(x),(x,-pi,pi))/pi).abs().n()
...same error.
Meanwhile:
sage: numerical_integral(exp(-x^2)*cos(x), (-pi,pi))
(1.3804038617166086, 1.5567746861731315e-14)
I'm guessing this is a Maxima problem. Any ideas what's going on?
Dan
--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------
Hrm...but I get:
(erf(pi - 1/2*I) + erf(pi + 1/2*I)).n()
resulting in "TypeError: Unable to convert 3.14159265358979 -
0.500000000000000*I", which, as I've figured out, comes from the first
erf(). It seems like .n() should return CC values when necessary, but
the obvious workaround doesn't, well, work around the problem:
erf(pi - 1/2*I).real_part().n()
gives the same TypeError -- and suggests I use real_part()! Neither
CC(erf(pi - 1/2*I))
nor
CC(erf(pi - 1/2*I).real_part(), erf(pi - 1/2*I).imag_part())
work. We need to work on the numerical approximation stuff for the error
function!
Ticket #11948:
http://trac.sagemath.org/sage_trac/ticket/11948
(I have a preliminary but not properly tested patch)