anonymous
  • anonymous
Trying to solve Bessel function with C++. http://www.twiddla.com/738376
Computer Science
jamiebookeater
  • jamiebookeater
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

asnaseer
  • asnaseer
you can post your source code at http://ideone.com/ and then post a link to it here. I think that would be easier to read than at twiddla.
anonymous
  • anonymous
Source Code: http://ideone.com/Wju5T
asnaseer
  • asnaseer
you erased the formula from twiddla?

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
yep, let me draw it again
asnaseer
  • asnaseer
ok - I'm reviewing the code now...
asnaseer
  • asnaseer
where is it going wrong?
anonymous
  • anonymous
in the BESSEL function, it seems i get an infinite loop. I want the loop to stop when the absolute number of a part of the sum is less than 10^(-12).
asnaseer
  • asnaseer
it may be fruitful to insert some trace statements in your BESSEL function. trace out the values of each component being constructed.
asnaseer
  • asnaseer
you can use std::cout to trace the values out
asnaseer
  • asnaseer
on a separate note, the function could be made more efficient by not computing \((-1)^{m}\) but instead having an integer that just toggles between 1 and -1, e.g.: int numerator =1 while (...) { sm = ... numerator = -numerator; }
anonymous
  • anonymous
I changed \[(-1)^m\] with num and that seems to solve the infinite loop problem. I don't know why. But stills the BESSEL function doesn't work for n=2.
asnaseer
  • asnaseer
What you should try and do is write some unit tests for each of the methods you have created to ensure they are working as expected. Also, as I suggested above, tracing out the values while looping in the BESSEL function might help you spot where the problem is.

Looking for something else?

Not the answer you are looking for? Search for more explanations.