For machine-precision computations, lots of coefficients $\sim 10^{-15}$ may be a sign that machine precision is actually not sufficient (and, yes, such results can be different in different versions or even on different platforms). The standard trick in such cases is to Rationalize[]
the input or use a higher precision, at the expense of slower, but more reliable computations.
For instance, this is reproducible in V8 and V9 on my machine:
In[48]:= OutputResponse[
Rationalize[
TransferFunctionModel[{{{12265.875860667435 +
15863.964729950849*s + 5000.*s^2}},
12265.875860667435 + 15986.623488557521*s +
5132.222766045224*s^2 + 81.0807167110999*s^3 +
16.908502769264427*s^4 + 1.*s^5}, s,
SystemsModelLabels -> {{None}, {None}}], 0], 1, t] // N // Chop
Out[48]= {0. +
6.3706*10^-7 (0. -
784856. (0.00285107 E^(-22.2373 t) - 4.59391 E^(-1.88023 t) +
6.60436 E^(-1.30805 t) - (0.00664625 -
0.00421948 I) E^((4.25855 - 14.3576 I) t) - (0.00664625 +
0.00421948 I) E^((4.25855 + 14.3576 I) t)))}
(I replaced UnitStep[t] -> 1
, which is equivalent in this case, but avoids a lot of unnecessary symbolic work and runs much faster.)
Or, in V9, you can try:
In[50]:= OutputResponse[
SetPrecision[
TransferFunctionModel[{{{12265.875860667435 +
15863.964729950849*s + 5000.*s^2}},
12265.875860667435 + 15986.623488557521*s +
5132.222766045224*s^2 + 81.0807167110999*s^3 +
16.908502769264427*s^4 + 1.*s^5}, s,
SystemsModelLabels -> {{None}, {None}}], 20], 1, t] //
Simplify // Chop
Out[50]= {0.2452185003 - 0.2477786589 E^(-22.2373307055086 t) +
0.02140659510 E^(-1.8802349880252 t) -
0.01884643653 E^(-1.3080450008032 t) -
0.7547814997 E^(4.2585539625363 t) Cos[14.3575707114421 t] +
0.7547814993 Cos[14.3575707114421 t]^2 -
0.1588054718 E^(4.2585539625363 t) Sin[14.3575707114421 t] +
0.7547814997 Sin[14.3575707114421 t]^2}
And finally, when you only need to plot an output response, or do something similar, you may want to use the numeric syntax OutputResponse[sys, u, {t, 0, tmax}]
rather than the symbolic one, OutputResponse[sys, u, t]
. The numeric route (in this case, via NDSolve
) can be faster, avoids many pitfalls, and is also reproducible between V8 and V9:
In[54]:= OutputResponse[
TransferFunctionModel[{{{12265.875860667435 + 15863.964729950849*s +
5000.*s^2}},
12265.875860667435 + 15986.623488557521*s +
5132.222766045224*s^2 + 81.0807167110999*s^3 +
16.908502769264427*s^4 + 1.*s^5}, s,
SystemsModelLabels -> {{None}, {None}}], UnitStep[t], {t, 0, 1}]
Out[54]= {12265.875860667435*InterpolatingFunction[][t] +
15863.964729950849*InterpolatingFunction[][t] +
5000.*InterpolatingFunction[][t]}
In[55]:= Plot[%, {t, 0, 1}]
...
Expand
before you useChop
so that these will collapse to numbers of reasonable size. And hope you don't get bitten hard by cancellation or truncation error. $\endgroup$