A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

In ps 4.4 (function testFindMaxExpenses) why is my answer 1229.95297872 and not 1229.95548986? Help greatly appreciated! http://dpaste.com/533442/

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

    Hi, As far as I can tell the problem specifies that your answer should be *close* to 1229.95548986, so your numbers look ok. The reason *why* your answer is not the same stems from the fact that floating point representation of numbers (and that's what you get if you use decimal-dot notation in Python) cannot express any number with full precision. As a consequence small errors can accumulate over multiple operations and the final result can be different depending on the number of operations, their order, relative magnitude of numbers and so on. Numerical analysis deals with this kind of problems. That's why floating point numbers are not used for any serious calculations involving money.

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

    Thanks for your response!

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

    Hello, Changing the line in user mmapplebeck code: while test[-1] < 0 or test[-1] > epsilon: To this: while abs(test[-1]) > epsilon: Gave me exact answer as stated in ps4.py: 1229.95548986.

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