Ask Your Question
1

numerically integrating an expression containing 'i'

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

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
2

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

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
1

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

calc314 gravatar image

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

f(x)=i*sin(i*x)
print f(x).simplify()
integrate(f(x), x, 0, 0.2)

gives

-sinh(x)
-0.0200667556191
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

Stats

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

Seen: 487 times

Last updated: Mar 06 '13