Re: NDSolve and InterpolatingFunction
- To: mathgroup at smc.vnet.net
- Subject: [mg56129] Re: NDSolve and InterpolatingFunction
- From: Peter Pein <petsie at arcor.de>
- Date: Sat, 16 Apr 2005 03:52:12 -0400 (EDT)
- References: <d3o06i$blo$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Virgil Stokes wrote:
> I am solving the following system of ODE's
>
> g = 9.81 ; (* acceleration of gravity [m/s^2] *)
> d = 0.063; (* diameter of ball [m] *)
> m = 0.05; (* mass in kg *)
> \[Rho] = 1.29; (* air density, [kg/m^3] *)
> \[Alpha] = \[Rho] Pi d^2/(8 m)
>
> h = 1; (* initial height [m] *)
> v0 = 25; (* magnitude of ball velocity [m/s] *)
> \[Theta] = 15 (* initial angle of release [15 degrees] *)
>
> vars = {x[t], vx[t], z[t], vz[t]}
>
> initc = {x[0] == 0, vx[0] == v0*Cos[\[Theta] Degree], z[0] == h,
> vz[0] == v0*Sin[\[Theta] Degree]}
>
> v[t] = Sqrt[vx[t]^2 + vz[t]^2];
>
> eq1 = x'[t] == vx[t];
> eq2 = vx'[t] == -0.508 \[Alpha] vx[t] v[t];
> eq3 = z'[t] == vz[t];
> eq4 = vz'[t] == -g - 0.508 \[Alpha] vz[t] v[t];
> eqns = {eq1, eq2, eq3, eq4}
>
> sol = NDSolve[Join[eqns, initc], vars, {t, 0, 25}]
>
> which works fine; but how can I find (e.g. using Solve) the value of t
> such that z[t] is 0; i.e, where, z[t] (in the
> form of an InterpolatingFunction) is zero.
>
> --V. Stokes
>
Add the following lines:
zz[t_?NumericQ] := Evaluate[z[t] /. First[sol]]
FindRoot[zz[t], {t, 1.5}]
--
Peter Pein
Berlin