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}]
0
, in your example code you have not definedPxi[0]
,Pyf[0]
,Pxf[0]
; define them and you will get rid of the$RecursionLimit
error. $\endgroup$