First time here? Check out the FAQ!

Ask Your Question
1

numerically integrating an expression containing 'i'

asked 11 years ago

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?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
2

answered 11 years ago

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)
Preview: (hide)
link
1

answered 11 years ago

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
Preview: (hide)
link

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: 11 years ago

Seen: 518 times

Last updated: Mar 06 '13