NSolve fails to solve a nonlinear equation

Mathematica can not solve this:

g = 9.82;
ω = 0.5;
h = 5;
y0 = 1;
v = 0;
τ = 0;

NSolve[h + v t – (g t^2)/2 == y0 Sin[ω t], t];

The error code is:

NSolve::nsmet: This system cannot be solved with the methods available to NSolve.

Any suggestions how to solve this equation ?

Background

I need to calculate when and where the jumping ball and sinusoidal ground will collide.
For the first one we know it is falling like:

h = h0 + v0 t – g t^2 / 2

For the ground we know it is moving as:

y = y0 Sin(omega t)

If we calculate h = y, extract t we get the time of the collision.
Finally I need to plot the movement of the ball and the points of collision versus real time.

=================

  

 

FindRoot[h + v t – (g t^2)/2 == y0 Sin[\[Omega] t], {t, 0}]
– Dr. belisarius
Feb 4 ’15 at 16:59

1

 

Tell it to solve over the real numbers: NSolve[h + v t – (g t^2)/2 == y0 Sin[\[Omega] t], t, Reals].
– Chip Hurst
Feb 4 ’15 at 22:53

=================

1 Answer
1

=================

Update: reply to comment to display the move of the ball. Here is a quick Manipulate. You can make improvement as needed

Manipulate[
tick;

g = 9.82; y0 = 1; v = 0;
h = h + v*t – g t^2/2;
ymin = y0 Sin[w t];
If[h – radius > ymin + thick, tick = Not[tick]; t = t + delT];
Grid[{
{“time”, “h”},
{t, h},
{
Graphics[
{
{Black, Disk[{0, h}, radius]},
{Blue, Rectangle[{-1, ymin}, {1, ymin + .2}]},
If[h – radius <= (ymin + thick), {Red, Style[Text["Crash!", {1.5 radius, ymin + 2 thick}], 14]} ] }, PlotRange -> {{-1, 1}, {0, 5.5}}, AspectRatio -> Automatic, Axes -> True,
ImageSize -> 200], SpanFromLeft
}
}, Spacings -> {.1, .2}, Frame -> All, FrameStyle -> LightGray]
,
Button[“Run”, h = 5; t = 0; ymin = 0; tick = Not[tick]],
{{w, 1, “omega?”}, 0, 10, .1, ImageSize -> Small, Appearance -> “Labeled”},
{{delT, 0.001, “animation speed?”}, 0.0001, 0.01, .0001, ImageSize -> Small,
Appearance -> “Labeled”},
{{tick, True}, None},
{{h, 5}, None},
{{t, 0}, None},
{{ymin, 0}, None},
{{thick, 0.2}, None},
{{radius, 0.1}, None},
TrackedSymbols :> {tick}
]

Original answer

If you tell NSolve that time is positive (which it is), it can solve it

g = 9.82;
w = 0.5;
h = 5;
y0 = 1;
v = 0;

NSolve[h + v t – (g t^2)/2 == y0 Sin[w t] && t > 0, t]

  

 

Haha, thats funny. Thanks! 😉
– Vito
Feb 4 ’15 at 18:53

  

 

What would be the best way to plot the movement of the ball?
– Vito
Feb 4 ’15 at 19:28

  

 

@Vito I do not know how to play the movement of the ball, since it falls down. I made quick manipulate, easier.
– Nasser
Feb 4 ’15 at 21:20