1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Approximation for Unknown Variable

  1. Aug 2, 2012 #1
    1. The problem statement, all variables and given/known data
    Firstly sorry if this is in the wrong place. I have never submitted a question on this forum about a comp sci question.

    I got an assignment that asked me to solve for a variable using Bisection of successive approximations. This however is not why I am here as I know you do not give answers to assignments.

    I have done the assignment properly and submitted it so this is just for general knowledge. I was wondering if anyone could come up with a more efficient solution to this problem using other techniques that I may not have heard of before.


    2. Relevant equations
    [itex]d = \frac{vcos(\theta)}{g}(vsin(\theta)+\sqrt{v^{2}sin^{2}(\theta)-2gh}[/itex]

    Given v, g, h and d solve for theta.

    Thanks for any ideas =D
     
  2. jcsd
  3. Aug 2, 2012 #2

    NascentOxygen

    User Avatar

    Staff: Mentor

    What are the values of those 4 variables?
     
  4. Aug 2, 2012 #3
    Inputted by the user.

    I forgot to to say that theta will lie in the range

    [itex]arctan(\frac{v^{2}}{g*d})\le \theta \le 90 degrees[/itex]
     
  5. Aug 3, 2012 #4

    berkeman

    User Avatar

    Staff: Mentor

    Could you please post your solution? We need to see that before we can be of much help.
     
  6. Aug 5, 2012 #5
    Assumed you meant my code.

    http://pastebin.com/X0Ni4ebz
     
  7. Aug 5, 2012 #6

    gneill

    User Avatar

    Staff: Mentor

    There's something fishy with the given equation... given the usual physical interpretation of the variables there is a units mismatch in the expression. Since the trig functions yield unitless results (so we can ignore them for purposes of unit analysis), both "d" and "v2/g" terms yield meters, but the radical term yields m/s.
     
  8. Aug 5, 2012 #7
    The equation was written by a computer scientist and it producing a real world value is beside the point.

    The way I wrote my program to solve for theta was start with the lower limit of theta, trial it and see how much it deviated from d and if this deviation was more than 0.0001 then increment theta and try again until the deviation is less than 0.0001.
    To me this doesn't seem very accurate in a real world situation (fine here because the answer only needs to be to two decimal places).

    That's why I am here to ask you guys if you can think of a better method of solving it eg monte carlo etc.
     
  9. Aug 5, 2012 #8

    NascentOxygen

    User Avatar

    Staff: Mentor

    On the contrary, if you wish for help here then the onus rests with you to ensure you are not a cavalier waste of other's time.

    The equation you provided is wrong. That's indisputable. Even blind Freddie can see it has mismatched brackets. So before you make yourself look a complete goose, go back and fix it to how it should be.

    A lesson you should take from this is to learn to better proof-read your own posts.

    Thanks to gneill for taking the time to highlight your oversight.
     
  10. Aug 5, 2012 #9

    gneill

    User Avatar

    Staff: Mentor

    There is a significant hint in the problem statement as you've written it: Bisection.

    Do a search on "Bisection method". It'll be a lot more efficient than creeping up on the solution by fixed steps as you're doing.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Approximation for Unknown Variable
  1. Unknown Resistors (Replies: 1)

Loading...