# How to solve a problem in relative motion?

I have a project due tomorrow that I have been struggling with for a month. I am utterly stumped, any help would be appreciated. The problem is:

There is a ferris wheel, 30m in radius, set 80m above water level. There is a boat 150m away from the center of the ferris wheel, and is moving toward the wheel at 10m/s. The wheel is turning at 0.2rad/s. Assuming no initial velocity and no friction, write a Mathematica program that will give the range for a person to successfully jump off the wheel and land in a boat, which is 1m in length.

I solved this analytically, but the assignment requires recursive programming. What I want to do is output the range of X coordinates when the person lands in the water and the corresponding location of the boat, and if they match, output the time value; otherwise go to the next increment. Here's what I have:

Clear[n, h];
Vx[0] = 0; Pyi[0] = 110; h = 300; t[0] = 0; Vyf[0] = 0;
t[n_] := t[n] = t[n - 1] + h
Vx[n_] := Vx[n] = 6 Cos[-0.2 t[n]]
Vy[n_] := Vy[n] = 6 Sin[-0.2 t[n]]
Pxi[n_] := Pxi[n] = 30 Cos[0.5 Pi - 0.2 t[n]]
Pyi[n_] := Pyi[n] = 80 + 30 Sin[0.5 Pi - 0.2 t[n]]
Pyf[n_] := Pyf[n] = Pyi[n - 1] + Vy[n] h - 4.9 h^2
Pxf[n_] := Pxf[n] = Pxi[n - 1] + Vx[n] h
Sxf[n_] := Sxf[n] = 150 - 10 t[n]
Do[If[Pxf[n] == Sxf[n], Print[t[n]*0.2], " "], {n, 0, 10}]


Execution yields no output. What should I do?

For reference:

t - time
Vx - initial x velocity (yielded from Vi Cos[theta])
Vy - initial y velocity
Pxi - location at which the person leaves the wheel (x)
Pyi - the same as above, y direction
Pyf - final location, y direction (should equal 0, don't know if I need to set that)
Pxf - final location, x direction
Sxf - location of boat


I executed t[14] and got 0.0014. I'm not sure why.

EDIT:

I've fixed the Do[If[Pxf[n] == Sxf[n], Print[t[n]*0.2], " "], {n, 0, 10}] to Do[If[Pxf[n] - Sxf[n] < 0.1, Print[t[n]*0.2], " "], {n, 0, 20}]. It produces an output now, but the answer is wrong (does not output the range of 9.6 to 9.91). I think I'm having two problems:

-I don't know when to put [n-1] and when to just use t[n]

-Since the velocity equations for initial velocity and the free-fall velocity are different, I don't get how to tie them in. Here is my new code:

Clear[Vx, Vy, Pxi, Pyi, n, h, Sxf];
Vx[0] = 0; Pyi[0] = 110; h = 0.001; t[0] = 0; Vyf[0] = 0;
t[n_] := t[n] = n h
Vx[n_] := Vx[n] = 6 Cos[-0.2 t[n]]
Vy[n_] := Vy[n] = 6 Sin[-0.2 t[n]]
Pxi[n_] := Pxi[n] = 30 Cos[0.5 Pi - 0.2 t[n]]
Pyi[n_] := Pyi[n] = 80 + 30 Sin[0.5 Pi - 0.2 t[n]]
Pyf[n_] := Pyf[n] = Pyi[n - 1] + Vy[n] h - 4.9 h^2
Pxf[n_] := Pxf[n] = Pxi[n - 1] + Vx[n] h
Sxf[n_] := Sxf[n] = 150 - 10 t[n]

Do[If[Pxf[n] - Sxf[n] < 0.1, Print[t[n]*0.2], " "], {n, 0, 20}]

-
The range of what? (boat distance, ferris wheel angle ...) –  belisarius Apr 23 '12 at 2:37
What I'm trying to do is: calculate the landing point for the person at each increment, then calculate the location of the boat at that time. If the person's location=boat location, then output the time the person left the wheel, if not, go to the next increment. –  GabrielleduVent Apr 23 '12 at 2:49
That is what YOU are trying to do, but it is not what they are asking for. They ask for a range. What range? –  belisarius Apr 23 '12 at 3:38
The range of angle that the person can jump off and land in the boat, or the time when the person can jump off and land. If I can get one, then I can get the other. –  GabrielleduVent Apr 23 '12 at 3:44
When you use recursion in that way, you need to define everything for the case 0, in your example code you have not defined Pxi[0], Pyf[0], Pxf[0]; define them and you will get rid of the $RecursionLimit error. – FJRA Apr 23 '12 at 14:05 ## 1 Answer One of the nice things about Mathematica is that it supports many different styles of programming. I think your code has the aspect of more "traditional" code that one might write in a different programming language. Perhaps your code is correct in spirit, but it seems to me overly complicated and as written obviously is not okay because it throws a recursion error. You could increase the $RecursionLimit and depending on what exactly is wrong that might help, but I think in this case it is better to rewrite.

This is more along the lines of what you need perhaps,

 Clear[Vx, Vy, Pxi, Pyi];
Pxi = 30 Cos[0.5 Pi - 0.2 t];
Pyi = 80 + 30 Sin[0.5 Pi - 0.2 t];
Vx = D[Pxi, t];
Vy = D[Pyi, t];
Sxf = 150 - 10*t;
Table[({Pxi /. t -> u + Vx*u, Sxf} /. u -> T) /.
Solve[Pxi + Vx*T - (9.8/2)*T^2 == 0, T][[2]], {t, 0, 15, 0.1}]


Given expressions for position on the ferris wheel over time, it computes the components of the velocity vector. Then for a range of values of time, it prints out the pairs you requested. Needless to say this code is still not as elegant as it could be, I suspect, and I'm not sure the physics of the situation is correctly represented here, but you should be able to check against your analytical solution (this code produces an intersect of the boat and the jumpers at a position of around 10).

Note that you will run into trouble using == to check for equality since you are using discrete time steps and inexact numbers. You may need to use FindRoot or NSolve.

-
The instructions are to use recursive programming, which is the root of all evils in this problem. I can reduce the problem to series of equations and solve them analytically, but I can't use analytical commands. I'm not sure if Solve[] is analytical... But your version is certainly better than what I could come up with. Thank you for your help. –  GabrielleduVent Apr 23 '12 at 2:52
Are you allowed to manually do any calculations? Is the expression Pxi + Vx*T - (9.8/2)*T^2 == 0 allowed or must you also solve the equations of motion using a numerical technique (e.g. Euler's method or the like)? –  JOwen Apr 23 '12 at 2:57
From the looks of the previous assignments, I can use numerical techniques but I'm not sure if I can use the quadratic equation. Here is what he said: "For this project, use recursion techniques to find your solution. You may use analytical equations to check your answer, but your program must find the solutions through recursion techniques." Which brings up the question, how would I solve for 0 without using quadratic solving? I can't think up of a way. –  GabrielleduVent Apr 23 '12 at 3:00
@MomokoTakahashi For example: en.wikipedia.org/wiki/Newton's_method –  nibot Apr 23 '12 at 10:09
I know how to do recursive by hand, and I've programmed Euler before. I can't figure out how to do this particular recursive. –  GabrielleduVent Apr 23 '12 at 11:49