Ask Your Question

numerically integrating an expression containing 'i'

asked 2013-03-06 12:45:59 +0200

ebs gravatar image

This is example of an integral that can't be evaluated using

sage: numerical_integral(i*sin(i*x), x, 0, 0.2)

Traceback (click to the left of this block for traceback)
TypeError: unable to coerce to a real number

even though the integrand is real (in disguse). How can I get around this problem?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-03-06 13:08:32 +0200

calc314 gravatar image

Your integrand is -sinh(x) and so you can do this using integrate.

print f(x).simplify()
integrate(f(x), x, 0, 0.2)


edit flag offensive delete link more

answered 2013-03-06 13:09:49 +0200

benjaminfjones gravatar image

The integrand isn't a real for all (complex) values of x, though. If you wrap the symbolic part in an anonymous function that just does the evaluation (at real values of x in this integral) it will work:

sage: numerical_integral(lambda x: i*sin(i*x), 0, 0.2)
(-0.020066755619075848, 2.2278574117824245e-16)
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2013-03-06 12:45:59 +0200

Seen: 443 times

Last updated: Mar 06 '13