Approximation for Unknown Variable

AI Thread Summary
The discussion revolves around solving for the angle theta in a physics equation using Bisection of successive approximations. The user seeks more efficient methods for this problem, having already completed the assignment. Concerns are raised about a units mismatch in the provided equation, suggesting it may be incorrect. A participant advises the user to explore the Bisection method for improved efficiency over their current trial-and-error approach. The conversation emphasizes the importance of accurate equations and efficient problem-solving techniques in computational tasks.
KingBigness
Messages
94
Reaction score
0

Homework Statement


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.


Homework Equations


d = \frac{vcos(\theta)}{g}(vsin(\theta)+\sqrt{v^{2}sin^{2}(\theta)-2gh}

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

Thanks for any ideas =D
 
Physics news on Phys.org
What are the values of those 4 variables?
 
NascentOxygen said:
What are the values of those 4 variables?

Inputted by the user.

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

arctan(\frac{v^{2}}{g*d})\le \theta \le 90 degrees
 
KingBigness said:

Homework Statement


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.


Homework Equations


d = \frac{vcos(\theta)}{g}(vsin(\theta)+\sqrt{v^{2}sin^{2}(\theta)-2gh}

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

Thanks for any ideas =D

Could you please post your solution? We need to see that before we can be of much help.
 
berkeman said:
Could you please post your solution? We need to see that before we can be of much help.

Assumed you meant my code.

http://pastebin.com/X0Ni4ebz
 
KingBigness said:

Homework Equations


d = \frac{vcos(\theta)}{g}(vsin(\theta)+\sqrt{v^{2}sin^{2}(\theta)-2gh}

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

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.
 
gneill said:
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.

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.
 
KingBigness said:
The equation was written by a computer scientist and it producing a real world value is beside the point.
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.
 
KingBigness said:
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.

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.
 

Similar threads

Replies
1
Views
2K
Replies
8
Views
3K
Replies
3
Views
2K
Replies
13
Views
5K
Replies
4
Views
2K
Replies
4
Views
1K
Back
Top