Reputation: 67
I'm trying to obtain a numerical solution to the following integral:
The correct answer is -0.324 + 0.382i but as seen below I am not getting a numerical answer and would appreciate help with the Maxima syntax.
2
Perhaps related to why I am not getting a numerical output are two specific questions:
Thank you!
Upvotes: 3
Views: 714
Reputation: 17573
Looks to me like your input is okay, however, the function to compute approximations to integrals is named quad_qags
. (There are actually several related functions. See ?? quad_
for more info.) Also, a wrinkle here is that the integrand is a complex-valued function (of a real variable), and quad_qags
can only work on real-valued integrands, so we'll have to work around it. Here's how I would arrange it.
myintegrand: exp(%i*(1 + %i*y))/(1 + %i*y + 1/(1 + %i*y));
result_realpart: quad_qags (realpart (myintegrand), y, 0, 6);
result_imagpart: quad_qags (imagpart (myintegrand), y, 0, 6);
result: result_realpart[1] + %i*result_imagpart[1];
I get 0.3243496676292901*%i + 0.3820529930785175
as the final result. That's a little different from what you said; maybe a minus sign went missing? or there's a missing or extra factor of %i
?
A quick approximation
0.1 * lsum (x, x, float (rectform (makelist (ev (myintegrand, y = k/10), k, 0, 60))));
seems to show the result from quad_qags
is reasonable.
Upvotes: 3