Sunday, 1 June 2014

integration - complex result in numerical integral

I'm in a contradiction that I open the topic is here because it is also related to programming. I try to calculate definite integral using Simpson's Rule. However, after some tries, I have encountered a problem referred as nan meaning not a number. How can I know ? I checked some equations. I get that my program shows nan when result of the equation is complex number. The interesting point is that I discussed the result with my lecturer, he said if you find complex number from numerical integral calculation I will give you two prizes(no pun intended). At the first glance, I acknowledged him to be right. However, I found complex number. How is it possible? For example, when I try to calculate $$ \sin^{t}(2t) + \cos^{t}(\frac{t}{9}) = pow(sin(2*t), t ) + pow( cos(t / 9), t ) $$



.
.
29) 1.066912
30) pow(sin(2*1.525000), 1.525000 ) + pow( cos(1.525000 / 9), 1.525000 )
30) 1.004298
31) pow(sin(2*1.575000), 1.575000 ) + pow( cos(1.575000 / 9), 1.575000 )
31) nan
32) pow(sin(2*1.625000), 1.625000 ) + pow( cos(1.625000 / 9), 1.625000 )

32) nan
.
.
.


enter image description here

No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...