Re: Interpolating Functions

• To: mathgroup at smc.vnet.net
• Subject: [mg81819] Re: Interpolating Functions
• From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
• Date: Thu, 4 Oct 2007 04:23:10 -0400 (EDT)
• Organization: Uni Leipzig
• References: <fdvd39\$sbc\$1@smc.vnet.net>

```Hi,

since you give no example I have to make my own

sol = With[{gamma = 0.25, k = 1},
NDSolve[
{x''[t] + gamma*x'[t] + k*x[t] == 0,
x[0] == 2, x'[0] == 0,
\[ScriptCapitalL]'[t] == x'[t]^2/2 + k*x[t]^2/2,
\[ScriptCapitalL][0] == 0}, {\[ScriptCapitalL][t], x[t]}, {t, 0,
20}][[1]]
]

The energy loss is
d\[ScriptCapitalE] = D[\[ScriptCapitalL][t] /. sol, t]

and a plot of it is

Plot[d\[ScriptCapitalE], {t, 0, 20}]

Why you wish to integrate over time *after* you solve the
equations of motion because NDSolve[] does nothing
else than a time integration and in the worst case you get
a waring that NDSolve[] will try to solve a differential
algebraic equation.

Regards
Jens

James Ransley wrote:
> I am trying to calculate the total energy dissipated in the damper in
> the damped harmonic oscillator problem with arbitraty forcing (in the
> form of numerical data), for a range of spring constants and damping
> factors (and for unit mass). Using Green's functions, I can get a
> solution with analytic forcing functions, but I have problems when I
> try to implement the same thing with a numberical forcing function.
>
> I can get as far as deriving (& plotting) the response of the system
> in time for a given damping factor and spring constant, but I cannot
> seem to differentiate this data - Mathematica complains that the
> function being differentiated is not numeric. I think this is because
> the function is a mix of time dependant interpolating functions and
> anlaytic functions. It may be because I'm getting confused about the
> definitions of differentiation for functions and
> InterpolatingFunctions... What I want to do is differentiate the
> response, square it and then integrate over time to get the energy
> dissipated in the damper. It's kind of frustrating when you can plot
> the response but you can't do this!
>
> It's rather a long notebook to post here - but if anyone thinks they
> can help I'm happy to send the file.
>
> Thanks,
>
> Dr James Ransley
> james.ransley at gmail.com
>

```

• Prev by Date: Optional arguments & FilterRules
• Next by Date: Re: Re: Equivalent functionality to colorbar in Mathematica?
• Previous by thread: Interpolating Functions
• Next by thread: Mathematica Special Interest Group (Northern VA and Washington DC)