MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: About the error message Indeterminate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91375] Re: About the error message Indeterminate
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 19 Aug 2008 07:14:06 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <g88v76$guj$1@smc.vnet.net>

MarvelousTau wrote:
> I think you all might have been check the example the bouncer in the
> entry Dynamic. But it is on a flat ground. So I want to make some
> change to let it bounce on hills, which formed by Sine function. The
> collisional consummation and reflection angle have been taken
> considered, but when the point touches the ground, it doesn't move any
> longer and the velocity shows indeterminate. I know indeterminate
> means such an issue like 0/0, but I replace my reflecting function
> with the colliding position and get a certain answer. I don't know if
> is there any other issues will cause indeterminate.
> 
> Anyway, check the code first.
> 
> function[x_] := Sin[x] + 0.5 Sin[6 x];
> Reflection[{{x_, y_}, {vx_, vy_}}] := {{x, y},
>   0.8 Sqrt[vx^2 + vy^2] {Cos[2 ArcTan[function'[x]] - ArcTan[vy/vx]],
>     Sin[2 ArcTan[function'[x]] - ArcTan[vy/vx]]}}
> 
> (* where function[] means the ground and Reflection[] shows how the
> ball bounces up, where x, y means position and vx, vy means velocity.
> 0.8 Is the consummation of collision, Sqrt is the norm of speed and
> the latter stuff is the new velocity in x and y direction. *)
> 
> PointSet = {{4, 6}, {0, -0.01}};
> Plot[function[x], {x, -5, 5}, Axes -> None, Filling -> Bottom,
>  PlotRange -> {{-5, 5}, {-2, 8}}, AspectRatio -> 1,
>  Epilog ->
>   Point[Dynamic[
>     PointSet =
>      If[PointSet[[1, 2]] >=
>        function[PointSet[[1, 1]]], {PointSet[[1]] + PointSet[[2]],
>        PointSet[[2]] + {0, -0.001}}, Reflection[PointSet]];
>     PointSet[[1]]]]]
> Dynamic[PointSet]
> 
> (*I used Epilog to draw the point. I didn't use Mouseclick because it
> will cause a dump*)

The function ArcTan[] has two forms: ArcTan[y/x], which does not trap 
division by zero or indeterminate forms, and ArcTan[x, y], which does 
handle such cases.

Note that the second form may return an *Interval[]* object rather than 
a value.

In[1]:= {ArcTan[y/x], ArcTan[x, y]} /. {x -> 0, y -> 0}

During evaluation of In[1]:= Power::infy:Infinite expression 1/0 
encountered.

During evaluation of In[1]:= \[Infinity]::indet:Indeterminate expression 
0 ComplexInfinity encountered.

During evaluation of In[1]:= ArcTan::indet:Indeterminate expression 
ArcTan[0,0] encountered.

Out[1]= {Indeterminate, Interval[{-Pi, Pi}]}

In[2]:= {ArcTan[y/x], ArcTan[x, y]} /. {x -> 0, y -> 1}

During evaluation of In[2]:= Power::infy:Infinite expression 1/0 
encountered.

Out[2]= {Indeterminate, Pi/2}


So you could write your function as follows:


In[1]:= function[x_] := Sin[x] + 0.5 Sin[6 x];
Reflection[{{x_, y_}, {vx_, vy_}}] := {{x, y},
   0.8 Sqrt[vx^2 + vy^2] {Cos[2 ArcTan[function'[x]] - ArcTan[vx, vy]],
      Sin[2 ArcTan[function'[x]] - ArcTan[vx, vy]]}}

PointSet = {{4, 6}, {0, -0.01}};
Plot[function[x], {x, -5, 5}, Axes -> None, Filling -> Bottom,
  PlotRange -> {{-5, 5}, {-2, 8}}, AspectRatio -> 1,
  Epilog ->
   Point[Dynamic[
     PointSet =
      If[PointSet[[1, 2]] >=
        function[PointSet[[1, 1]]], {PointSet[[1]] + PointSet[[2]],
        PointSet[[2]] + {0, -0.001}}, Reflection[PointSet]];
     PointSet[[1]]]]]
Dynamic[PointSet]


Regards,
-- Jean-Marc



  • Prev by Date: Re: Re: Solving nonlinear inequality constraints
  • Next by Date: Possible Bug with Specific Combination of Integrate and Assumptions
  • Previous by thread: Re: About the error message Indeterminate
  • Next by thread: Equations system with zero