# Wednesday Evening Physics

Nick George

Ranch Hand

Posts: 815

posted 10 years ago

A particle is fired from ( 0 , 0 ) with velocity v at angle theta. It is to hit an object at ( x , y ).

in the x direction we have:

x = v * cos( theta ) * t

in the y direction we have:

y = v * sin( theta ) * t - 1/2 * g * t^2

The question is this: solve for theta.

It seems like the first thing an artilleryman ought to know, but I can't manage to do it. (The TI-89 couldn't hack it either, so I feel a little better).

If I solve for t in the x equation, I get a nightmare of trig.

If I solve for theta, and then use a right triangle to get rid of all the trig, I get a mess of sqare roots and squares that I can't simplify. I'd love for any help I can find around the 'ranch. I'm hoping I can get Jim on the job...

in the x direction we have:

x = v * cos( theta ) * t

in the y direction we have:

y = v * sin( theta ) * t - 1/2 * g * t^2

The question is this: solve for theta.

It seems like the first thing an artilleryman ought to know, but I can't manage to do it. (The TI-89 couldn't hack it either, so I feel a little better).

If I solve for t in the x equation, I get a nightmare of trig.

If I solve for theta, and then use a right triangle to get rid of all the trig, I get a mess of sqare roots and squares that I can't simplify. I'd love for any help I can find around the 'ranch. I'm hoping I can get Jim on the job...

I've heard it takes forever to grow a woman from the ground

Nick George

Ranch Hand

Posts: 815

Jim Yingst

Wanderer

Sheriff

Sheriff

Posts: 18671

posted 10 years ago

That seems... doubtful...

Ah, but your answer does depend on t, which was not part of the initial conditions, and which will depend on x, y, v, and of course g. So by the time you fully eliminate t, the answer will again depend on v.

Unfortunately, I think that's the best route to take here. Eliminate t by solving for it in one equation and substituting into the other. After that - it's pretty icky. The half-angle formulas from trigonometry are probably useful here - you can rewrite the various trig functions so they're all in terms of cos 2θ (or possibly cos 4θ, depending how you do it) then make some substitution like u = cos 2θ (if only to cut down on writing) and keep simplifying.

Alternately, I expect there's a complete formula and derivation in most university intro Physics textbooks (for the calculus-based intro courses, at least - the solution doesn't require calc but it's of comparable complexity). Or it's probably online somewhere, though it didn't jump out in a few quick googles. I worked through it once, but as I recall it's one of the more complex derivations in [supposedly] "basic" projectile motion.

Yeah, but most of them just memorized the final formulas. Actually working them out on the spot would've been a bit much to expect, especially in the midst of battle. For extra fun, throw in centrifugal forces, Coriolis forces, and air resistance.

[ January 12, 2006: Message edited by: Jim Yingst ]

**[Paul]: Did your picture get worse between when you posted it and now?**

That seems... doubtful...

**The answer doesn't depend on v? I find that a bit odd.**

Ah, but your answer does depend on t, which was not part of the initial conditions, and which will depend on x, y, v, and of course g. So by the time you fully eliminate t, the answer will again depend on v.

**[Nick]: If I solve for t in the x equation, I get a nightmare of trig.**

Unfortunately, I think that's the best route to take here. Eliminate t by solving for it in one equation and substituting into the other. After that - it's pretty icky. The half-angle formulas from trigonometry are probably useful here - you can rewrite the various trig functions so they're all in terms of cos 2θ (or possibly cos 4θ, depending how you do it) then make some substitution like u = cos 2θ (if only to cut down on writing) and keep simplifying.

Alternately, I expect there's a complete formula and derivation in most university intro Physics textbooks (for the calculus-based intro courses, at least - the solution doesn't require calc but it's of comparable complexity). Or it's probably online somewhere, though it didn't jump out in a few quick googles. I worked through it once, but as I recall it's one of the more complex derivations in [supposedly] "basic" projectile motion.

**it seems like the first thing an artilleryman ought to know**

Yeah, but most of them just memorized the final formulas. Actually working them out on the spot would've been a bit much to expect, especially in the midst of battle. For extra fun, throw in centrifugal forces, Coriolis forces, and air resistance.

[ January 12, 2006: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, *Twister*

Nick George

Ranch Hand

Posts: 815

Stan James

(instanceof Sidekick)

Ranch Hand

Ranch Hand

Posts: 8791

posted 10 years ago

This problem was one of the great early motivators for military funding of computing research. Killing people with math. Shudder.

it seems like the first thing an artilleryman ought to know

Yeah, but most of them just memorized the final formulas. Actually working them out on the spot would've been a bit much to expect, especially in the midst of battle. For extra fun, throw in centrifugal forces, Coriolis forces, and air resistance.

This problem was one of the great early motivators for military funding of computing research. Killing people with math. Shudder.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi

Jim Yingst

Wanderer

Sheriff

Sheriff

Posts: 18671

posted 10 years ago

The spaces are there, but whether or not they're rendered in monospace font is the issue. UBB has some bugs in this area, rendering nonstandard HTML which is interpreted differently by different browsers. I believe IE, Safari and Opera render the monospace consistently, while Firefox may not. Since the font tags are nested incorrectly to begin with, I'm not sure this is can be called a Firefox bug. The rendering also seems to depend on the content of other posts on the page, in a way I don't understand.

Most of the time this isn't a big issue - in code for example, it doesn't matter if the initial spaces are monospace or not, as long as all the indentation is done in spaces. The relative indentation of the beginning of each line of code works out the same. But in an ASCII diagram where we depend on the relative position of characters not at the beginning of a line, the problem becomes more noticeable.

To be fair, it's not unheard of for variables to drop out unexpectedly. The fact that the period of a simple pendulum is unaffected by its length, for example. So I think I can see where you were coming from...

**[Nick]: I thought 'code' tags preserved spacing.**

The spaces are there, but whether or not they're rendered in monospace font is the issue. UBB has some bugs in this area, rendering nonstandard HTML which is interpreted differently by different browsers. I believe IE, Safari and Opera render the monospace consistently, while Firefox may not. Since the font tags are nested incorrectly to begin with, I'm not sure this is can be called a Firefox bug. The rendering also seems to depend on the content of other posts on the page, in a way I don't understand.

Most of the time this isn't a big issue - in code for example, it doesn't matter if the initial spaces are monospace or not, as long as all the indentation is done in spaces. The relative indentation of the beginning of each line of code works out the same. But in an ASCII diagram where we depend on the relative position of characters not at the beginning of a line, the problem becomes more noticeable.

**[Paul C]: And yeah, the answer not depending on v wasn't just "a bit odd", it should have been a big red flag.**

To be fair, it's not unheard of for variables to drop out unexpectedly. The fact that the period of a simple pendulum is unaffected by its length, for example. So I think I can see where you were coming from...

"I'm not back." - Bill Harding, *Twister*

Bert Bates

author

Sheriff

Sheriff

Posts: 8900

5

posted 10 years ago

At the risk of stepping into a big one...

I thought that the length was the ONLY factor that affected a pendulum's period? (In other words the weight of the bob, the angle of the swing, etc. don't affect the period.)

The fact that the period of a simple pendulum is unaffected by its length

At the risk of stepping into a big one...

I thought that the length was the ONLY factor that affected a pendulum's period? (In other words the weight of the bob, the angle of the swing, etc. don't affect the period.)

Spot false dilemmas now, ask me how!

(If you're not on the edge, you're taking up too much room.)

Jim Yingst

Wanderer

Sheriff

Sheriff

Posts: 18671

Nick George

Ranch Hand

Posts: 815

Jon Pincott

Greenhorn

Posts: 17

Nick George

Ranch Hand

Posts: 815

posted 10 years ago

Ok!

So!

Now, I know that t > 0, so I can just take the principle square root of t² to get t. If I want the projectile to hit at the earliest possible time (i.e. on the way up), do I want the discriminant in the t² to be plus or minus? My preliminary investigations suggest it depends on what's bigger than what and by how much.

So!

Now, I know that t > 0, so I can just take the principle square root of t² to get t. If I want the projectile to hit at the earliest possible time (i.e. on the way up), do I want the discriminant in the t² to be plus or minus? My preliminary investigations suggest it depends on what's bigger than what and by how much.

I've heard it takes forever to grow a woman from the ground

Nick George

Ranch Hand

Posts: 815

posted 10 years ago

Wow...

just saw that.

That works brilliantly, no half angles or nuthin'.

Thanks.

Originally posted by Jon Pincott:

The nasty looking trig you get when you eliminate t can be turned into a quadratic in tan theta using:

1) sin / cos = tan

2) 1 / cos^2 = 1 + tan^2

You can then just calculate your coefficients and plug into the normal quadratic formula to get two values for tan theta.

Wow...

just saw that.

That works brilliantly, no half angles or nuthin'.

Thanks.

I've heard it takes forever to grow a woman from the ground

Nick George

Ranch Hand

Posts: 815

posted 10 years ago

I'm hoping I can get my math checked now.

I get a = gx/v^2, b = vx, and c = gx/v^2 - y. If

tan theta = -b +/- root(b^2- 4ac)

...........---------------------

....................2a,

here are the results:

the plus one is garbage- my guy always shoots straight up. Don't know why it's garbage, but it is.

the minus one is not quite garbage, but almost. First off, for some reason it's in the wrong direction, so I say pi - that. Then, it always under shoots by a bit. I'm beginning to think it's the fault of my program and not the math, but I hope someone will look over my math.

Thanks,

Nick.

I get a = gx/v^2, b = vx, and c = gx/v^2 - y. If

tan theta = -b +/- root(b^2- 4ac)

...........---------------------

....................2a,

here are the results:

the plus one is garbage- my guy always shoots straight up. Don't know why it's garbage, but it is.

the minus one is not quite garbage, but almost. First off, for some reason it's in the wrong direction, so I say pi - that. Then, it always under shoots by a bit. I'm beginning to think it's the fault of my program and not the math, but I hope someone will look over my math.

Thanks,

Nick.

I've heard it takes forever to grow a woman from the ground

Jon Pincott

Greenhorn

Posts: 17

posted 10 years ago

Nick, I get something different for my coefficients:

[CODE]import java.util.Arrays;

public class Projectile {

private static final double GRAVITY = 9.80665;

public static void main(String[] args) {

double x = 100;

double y = 10;

double v = 35;

double[] thetas = solve(x, y, v);

System.out.println(Arrays.toString(toDegrees(thetas)));

}

private static double[] solve(double x, double y, double v) {

/*

* Eqn's of motion:

*

* x = v.cos th.t

* y = v.sin th.t - g.t^2/2

*

* Eliminate t:

*

* y = x.tan th -(g.x^2)/(2.v^2).(1 + tan^2 th)

*

* Collect terms for quadratic in theta:

*

* a = (g.x^2)/(2.v^2)

* b = -x

* c = a + y

*

* Solve quadratic eqn and calculate arctan

*/

double a, b, c;

a = x / v;

a *= a;

a /= 2;

a *= GRAVITY;

b = -x;

c = a + y;

double[] roots = getRoots(a, b, c);

return new double[] {

Math.atan(roots[0]),

Math.atan(roots[1])

};

}

private static double[] getRoots(double a, double b, double c) {

double t1, t2;

t1 = -b / a / 2;

t2 = t1 * t1;

t2 -= (c / a);

t2 = Math.sqrt(t2);

return new double[] {

t1 - t2,

t1 + t2

};

}

private static double[] toDegrees(double[] radians) {

double[] degrees = new double[radians.length];

for (int i = 0; i < degrees.length; i++) {

degrees[i] = Math.toDegrees(radians[i]);

}

return degrees;

}

}[CODE]

[CODE]import java.util.Arrays;

public class Projectile {

private static final double GRAVITY = 9.80665;

public static void main(String[] args) {

double x = 100;

double y = 10;

double v = 35;

double[] thetas = solve(x, y, v);

System.out.println(Arrays.toString(toDegrees(thetas)));

}

private static double[] solve(double x, double y, double v) {

/*

* Eqn's of motion:

*

* x = v.cos th.t

* y = v.sin th.t - g.t^2/2

*

* Eliminate t:

*

* y = x.tan th -(g.x^2)/(2.v^2).(1 + tan^2 th)

*

* Collect terms for quadratic in theta:

*

* a = (g.x^2)/(2.v^2)

* b = -x

* c = a + y

*

* Solve quadratic eqn and calculate arctan

*/

double a, b, c;

a = x / v;

a *= a;

a /= 2;

a *= GRAVITY;

b = -x;

c = a + y;

double[] roots = getRoots(a, b, c);

return new double[] {

Math.atan(roots[0]),

Math.atan(roots[1])

};

}

private static double[] getRoots(double a, double b, double c) {

double t1, t2;

t1 = -b / a / 2;

t2 = t1 * t1;

t2 -= (c / a);

t2 = Math.sqrt(t2);

return new double[] {

t1 - t2,

t1 + t2

};

}

private static double[] toDegrees(double[] radians) {

double[] degrees = new double[radians.length];

for (int i = 0; i < degrees.length; i++) {

degrees[i] = Math.toDegrees(radians[i]);

}

return degrees;

}

}[CODE]

SCJP SCWCD

Nick George

Ranch Hand

Posts: 815

samantha hewamanage

Greenhorn

Posts: 4

posted 10 years ago

ok here is what u do

this need little trig. math

x = v * cos( theta ) * t ---------(A)

y = v * sin( theta ) * t - 1/2 * g * t^2 -------------(B)

first: solve (A) for t;

t = x /(v*cos(theta))

plug this into (B) and simplify

y = x*tan(theta) - 1/2*g*(1+(tan(theta))^2)--------------(C)

{used these trig. relations

tan(theta) = sin(theta)/cos(theta)

sec(theta) = 1/cos(theta)

(sec(theta))^2 = 1 + (tan(theta))^2

}

now u have a quadratic equation in terms of tan(theta)

solve it using

{

a*X^2+b*X +c = 0

roots:

X1 = (-b + sqrt(b^2 - 4*a*c))/(2*a)

X2 = (-b - sqrt(b^2 - 4*a*c))/(2*a)

}

take X= tan(theta)

then (C) becomes

y = x*X - 1/2*g*(1+X^2)

1/2*g*X^2 -x*X + (y+1/2*g) --------------(D)

now your a = 1/2*g b = -x c = y+1/2*g

now get X1 and X2

then

theta1 = ArcTan(X1)

theta2 = ArcTan(X2)

u can eliminate one of these by some argument like:

if it is negative or > 90 degrees

this need little trig. math

x = v * cos( theta ) * t ---------(A)

y = v * sin( theta ) * t - 1/2 * g * t^2 -------------(B)

first: solve (A) for t;

t = x /(v*cos(theta))

plug this into (B) and simplify

y = x*tan(theta) - 1/2*g*(1+(tan(theta))^2)--------------(C)

{used these trig. relations

tan(theta) = sin(theta)/cos(theta)

sec(theta) = 1/cos(theta)

(sec(theta))^2 = 1 + (tan(theta))^2

}

now u have a quadratic equation in terms of tan(theta)

solve it using

{

a*X^2+b*X +c = 0

roots:

X1 = (-b + sqrt(b^2 - 4*a*c))/(2*a)

X2 = (-b - sqrt(b^2 - 4*a*c))/(2*a)

}

take X= tan(theta)

then (C) becomes

y = x*X - 1/2*g*(1+X^2)

1/2*g*X^2 -x*X + (y+1/2*g) --------------(D)

now your a = 1/2*g b = -x c = y+1/2*g

now get X1 and X2

then

theta1 = ArcTan(X1)

theta2 = ArcTan(X2)

u can eliminate one of these by some argument like:

if it is negative or > 90 degrees

Jim Yingst

Wanderer

Sheriff

Sheriff

Posts: 18671

posted 10 years ago

That seems unlikely, as there will generally be two solutions in the range 0-90 degrees. One represents a more direct shot, the other represents a high lob. Usually you'd want the direct shot unless there are mountains or other impediments in the way.

**[Sam]u can eliminate one of these by some argument like:**

if it is negative or > 90 degrees

if it is negative or > 90 degrees

That seems unlikely, as there will generally be two solutions in the range 0-90 degrees. One represents a more direct shot, the other represents a high lob. Usually you'd want the direct shot unless there are mountains or other impediments in the way.

"I'm not back." - Bill Harding, *Twister*