A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 4 years ago

Trying to solve Bessel function with C++. http://www.twiddla.com/738376

  • This Question is Closed
  1. asnaseer
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

  2. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Source Code: http://ideone.com/Wju5T

  3. asnaseer
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    you erased the formula from twiddla?

  4. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    yep, let me draw it again

  5. asnaseer
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    ok - I'm reviewing the code now...

  6. asnaseer
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    where is it going wrong?

  7. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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).

  8. asnaseer
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    it may be fruitful to insert some trace statements in your BESSEL function. trace out the values of each component being constructed.

  9. asnaseer
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    you can use std::cout to trace the values out

  10. asnaseer
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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; }

  11. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  12. asnaseer
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

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

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.