Please find error in this 1-line code: I'm using the <int> function for integration.
1 view (last 30 days)
Show older comments
>> syms k
>> int(exp(-k)*cos(k),0,1)
This works, but...
>> syms k
>> int(exp(-k^2)*cos(k),0,1)
this does not work... I don't know what is wrong with this... I'm so frustrated...
Please help me.
1 Comment
Mischa Kim
on 5 May 2014
Edited: Mischa Kim
on 5 May 2014
Do you need a symbolic solution or would numeric suffice?
Accepted Answer
Star Strider
on 5 May 2014
The problem is that int(exp(-k^2)) is essentially the ‘error function’. To the best of my knowledge, it has no closed-form analytic solution. Taking the Taylor series of the integrand and then integrating it seems to work:
syms k
f = exp(-k^2)*cos(k);
ft = taylor(f, k, 'Order',11)
ift = int(ft, k, 0, 1)
produces:
ift =
26172299/39916800
Experiment with it until you get the result you want.
0 Comments
More Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!