A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • one year ago

Help me out!! Question is when I try to solve the assignment my answer is not perfect compared to the solution. Should I try again to close to get perfect answer without looking at the solution even if it takes a lot of time? or should I check solution code even though my result doesn't match. For example, using the bisection method to payoff outstanding debt within a year my answer is too overpaid. It takes a lot of time to get even my imperfect code. MY question is how do you guys study? I know it is not good check the solution first, but sometimes it takes a lot of time.

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

    I am stuck in problem set 1-c using bisection thing.

  2. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 3

    Post your code here, or ona code paste site. If you do so here, putting a ``` above and below the code will turn on code quoting. For example: \(\text{```}\) x = 0 while (x < 10): print 'X is:', x count = x + 1 \(\text{```}\) becomes: ``` x = 0 while (x < 10): print 'X is:', x count = x + 1 ``` Then we can go over it any any issues you are having.

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

    Here is my code below ------------ ----------------------------------------------- #Enter the input outstandingBalance = float(raw_input("Enter the outstanding balance on your credit card: ")) ann_interestRate = float(raw_input("Enter the annual credit card interest rate as a decimal: ")) #initiaialize variable monthly_IR = ann_interestRate / 12.0 balance = (outstandingBalance * (1 + monthly_IR)**12.0) numOfMonth = 0 monthly_low = outstandingBalance / 12.0 monthly_upp = (outstandingBalance * (1 + monthly_IR)**12.0) / 12.0 midpoint = (monthly_low + monthly_upp) / 2 while balance > 0: numOfMonth = 0 balance = (outstandingBalance * (1 + monthly_IR)**12.0) while balance > 0 and numOfMonth < 12: numOfMonth += 1 balance = balance - midpoint midpoint = (midpoint + monthly_upp) /2 midpoint = round(midpoint, 2) balance = round(balance, 2) print "RESULT" print "Monthly payment to pay off debt in 1 year: " , midpoint print "Number of months needed: " , numOfMonth print "Balance: " , balance

  4. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 3

    OK, so this is for bisection search. I see you only adjust things in one direction: balance = balance - midpoint midpoint = (midpoint + monthly_upp) /2 I can understand breaking out of the loop if you pay thing off... but I think you need to change your adjust ments for both directions. |dw:1440830761437:dw|

  5. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 3

    With this sort of goal, you need to be able to go back up if you go too low. |dw:1440830811380:dw| If you can only reduce something, you get wors rather than corrrecting up.

  6. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 3

    Now, in contrast, here is something that corrects up and down by half each time. Step 5 gets close enough for it to be considered good. |dw:1440830894985:dw|

  7. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 3

    This is the basic flaw in your method of looping. You have a way to make your payment get larger, but not really a way for it to get smaller. You need to evaluate if it has gotten close enough. So if you pay it off in 12 months with say a 1% margin for error, then you call it good. This is an epsilon-delta type idea. In calculus, there is this idea that by setting a close enough output, eplsilon, you can use it to find a close enough input, delta. So you can pick a value, like $1 or 10 cents... or you can use a percentage, like 1%. epsilon = outstandingBalance * .01 while abs(balance) > epsilon and numOfMonth < 12: do stuff to get closer test to see if you went too far etc.

  8. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 3

    If you start with payoing off half, obiously the interest would need to be huge for it to take more than 2 months. So it should reliably chop to 1/4th, then 1/8th... but then it is up for grabs. It will pribably go to 1/16th, but that will be too low, so it needs to adust up to half way beteween 1/8th and 1/16th... which is 3/32 an so on. Each step up or down it should jump half the distance back until what it does in 12 months is within epsilon of the answer.

  9. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thank you very much !! very helpful indeed

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