# Get x range and print it of throw trajectory

here is code of my program

g := 9.81
p := 30
kat := p*(Pi/180) (* ok 45 stopni*)

(*    \
y=x*Tan[kat]-g/(2*vXpocz^2)*x^2   *)
Manipulate[
Plot[x*Tan[p * (Pi/180)] -
g/(2*(Vstart*Sin[p * (Pi/180)])^2)*x^2, {x, 0, 700},
AxesLabel -> {x [m], h [m]}, PlotLabel -> "Throw trajectory plot",
PlotRange -> {0, 300}],

{Vstart, 10, 50}, {p, 30, 60},
Button["Print", {Print["Max height: ",
FindMaximum[
x*Tan[p * (Pi/180)] - g/(2*(Vstart*Sin[p * (Pi/180)])^2)*x^2, {x,
0, 700}]],
Print["Range: ", Vstart^2/g*Sin[2*(p * (Pi/180))]]}
]]


And here is output I want that my program will gave me height and range after clicking button. It work but range value is't correct. Is there any function that check when there instersection on x axis ?

• The problem is not the calculation of range, the problem is your plot: Notice the weird behaviour when you vary p- that doesn't seem like a proper inclined throw. You can fix this by replacing Sin with Cos in the argument to plot (the second term should be $-\frac g2 t^2=-\frac g2 \left(\frac x{v_x}\right)^2$ with $v_x=v\cos p$, not $v_x=v\sin p$) – Lukas Lang Jan 10 at 17:25
• @LukasLang oh I see now :D thank you – marczin Jan 10 at 17:32