# Complex OutputResponse?

I have the following dynamical system in state space form, yet defined with a transfer function:

    sysbeta =
StateSpaceModel[
TransferFunctionModel[{{(1.07868*^12 +
3.03*^9*s)/(1.0781151104934349*^12 +
2.3941625151720203*^10*s + 3.215341962707181*^8*s^2 +
1.1917457990193355*^6*s^3 + 1697.1476160000002*s^4 + s^5)}},
s]];


I would like to see the dynamical response of such a system to an sinusoidal input. I have proceeded as follows:

OutputResponse[sysbeta, 10^3 Sin[t], t]


Yet my output is complex!

(*{1.07868*10^12 E^(-1046.72 t) ((2.0276*10^-13 + 3.88698*10^-27 I) E^(
650.424 t) - (2.0276*10^-13 - 1.0048*10^-28 I) E^(1046.72 t)
Cos[t] + (2.03879*10^-11 - 1.33471*10^-26 I) E^(1004.81 t)
Cos[54.9614 t] + (8.07794*10^-28 - 1.01472*10^-26 I) E^(
692.338 t)
Cos[t] Cos[54.9614 t] - (4.03897*10^-28 + 1.62291*10^-29 I) E^(
1401.11 t)
Cos[t] Cos[54.9614 t] - (2.03879*10^-11 - 1.88501*10^-26 I) E^(
1046.72 t)
Cos[t] Cos[
54.9614 t]^2 + (8.37218*10^-15 + 8.08949*10^-28 I) E^(
438.214 t)
Cos[446.248 t] - (4.73317*10^-30 + 6.1457*10^-30 I) E^(
834.514 t)
Cos[t] Cos[446.248 t] - (2.09521*10^-27 - 6.15978*10^-27 I) E^(
1258.93 t) Cos[t] Cos[446.248 t] + (0. + 7.44628*10^-29 I) E^(
480.129 t)
Cos[t] Cos[54.9614 t] Cos[
446.248 t] + (1.21169*10^-27 - 5.4868*10^-27 I) E^(1613.32 t)
Cos[t] Cos[54.9614 t] Cos[
446.248 t] - (8.37218*10^-15 + 8.77266*10^-28 I) E^(1046.72 t)
Cos[t] Cos[
446.248 t]^2 + (8.03537*10^-11 - 3.98203*10^-26 I) E^(
1046.72 t) Sin[t] - (0. + 1.0205*10^-26 I) E^(692.338 t)
Cos[54.9614 t] Sin[t] + (7.75482*10^-26 + 6.4316*10^-27 I) E^(
1401.11 t)
Cos[54.9614 t] Sin[t] + (8.47625*10^-10 - 2.49046*10^-25 I) E^(
1046.72 t) Cos[54.9614 t]^2 Sin[t] + (0. + 2.43554*10^-27 I) E^(
834.514 t)
Cos[446.248 t] Sin[t] + (2.58494*10^-26 - 2.22772*10^-26 I) E^(
1258.93 t)
Cos[446.248 t] Sin[t] + (2.01948*10^-28 - 2.00356*10^-28 I) E^(
480.129 t)
Cos[54.9614 t] Cos[446.248 t] Sin[
t] + (0. + 5.39657*10^-27 I) E^(1613.32 t)
Cos[54.9614 t] Cos[446.248 t] Sin[
t] - (6.14726*10^-13 - 1.08391*10^-27 I) E^(1046.72 t)
Cos[446.248 t]^2 Sin[
t] + (1.25918*10^-13 + 6.97886*10^-26 I) E^(1004.81 t)
Sin[54.9614 t] - (0. + 7.26569*10^-27 I) E^(692.338 t)
Cos[t] Sin[54.9614 t] + (8.07794*10^-28 + 7.6348*10^-29 I) E^(
1401.11 t)
Cos[t] Sin[54.9614 t] + (3.23117*10^-27 + 2.34446*10^-27 I) E^(
1046.72 t)
Cos[t] Cos[54.9614 t] Sin[
54.9614 t] - (6.31089*10^-30 - 1.93811*10^-28 I) E^(480.129 t)
Cos[t] Cos[446.248 t] Sin[
54.9614 t] + (1.71656*10^-27 + 1.62535*10^-26 I) E^(1613.32 t)
Cos[t] Cos[446.248 t] Sin[
54.9614 t] + (5.16988*10^-26 - 1.95702*10^-27 I) E^(692.338 t)
Sin[t] Sin[54.9614 t] - (4.1359*10^-25 + 3.02567*10^-26 I) E^(
1401.11 t)
Sin[t] Sin[54.9614 t] + (1.03398*10^-25 - 2.57411*10^-25 I) E^(
1046.72 t)
Cos[54.9614 t] Sin[t] Sin[
54.9614 t] + (2.01948*10^-28 - 6.76857*10^-28 I) E^(480.129 t)
Cos[446.248 t] Sin[t] Sin[
54.9614 t] - (2.06795*10^-25 + 1.39318*10^-25 I) E^(1613.32 t)
Cos[446.248 t] Sin[t] Sin[
54.9614 t] - (2.03879*10^-11 + 1.10708*10^-25 I) E^(1046.72 t)
Cos[t] Sin[
54.9614 t]^2 + (8.47625*10^-10 - 2.09836*10^-25 I) E^(
1046.72 t)
Sin[t] Sin[
54.9614 t]^2 + (1.2794*10^-14 - 3.09039*10^-28 I) E^(438.214 t)
Sin[446.248 t] + (5.04871*10^-29 + 1.57759*10^-29 I) E^(
834.514 t)
Cos[t] Sin[446.248 t] + (4.46811*10^-27 + 1.01567*10^-26 I) E^(
1258.93 t)
Cos[t] Sin[446.248 t] + (2.01948*10^-28 - 1.47831*10^-27 I) E^(
480.129 t)
Cos[t] Cos[54.9614 t] Sin[
446.248 t] - (4.01372*10^-27 + 8.35015*10^-27 I) E^(1613.32 t)
Cos[t] Cos[54.9614 t] Sin[
446.248 t] - (9.43478*10^-28 - 3.69488*10^-28 I) E^(1046.72 t)
Cos[t] Cos[446.248 t] Sin[
446.248 t] - (0. + 6.25199*10^-27 I) E^(834.514 t)
Sin[t] Sin[446.248 t] - (6.46235*10^-27 + 7.60663*10^-27 I) E^(
1258.93 t)
Sin[t] Sin[446.248 t] - (4.84676*10^-27 + 8.2361*10^-28 I) E^(
480.129 t)
Cos[54.9614 t] Sin[t] Sin[
446.248 t] + (4.20053*10^-26 + 1.8197*10^-26 I) E^(1613.32 t)
Cos[54.9614 t] Sin[t] Sin[
446.248 t] - (1.9387*10^-26 + 3.39858*10^-27 I) E^(1046.72 t)
Cos[446.248 t] Sin[t] Sin[
446.248 t] + (5.04871*10^-29 - 1.25659*10^-27 I) E^(480.129 t)
Cos[t] Sin[54.9614 t] Sin[
446.248 t] + (9.89547*10^-27 + 2.99374*10^-26 I) E^(1613.32 t)
Cos[t] Sin[54.9614 t] Sin[
446.248 t] + (6.46235*10^-27 - 9.91882*10^-28 I) E^(480.129 t)
Sin[t] Sin[54.9614 t] Sin[
446.248 t] - (2.58494*10^-26 - 7.44671*10^-26 I) E^(1613.32 t)
Sin[t] Sin[54.9614 t] Sin[
446.248 t] - (8.37218*10^-15 - 2.15764*10^-27 I) E^(1046.72 t)
Cos[t] Sin[
446.248 t]^2 - (6.14726*10^-13 + 1.33247*10^-27 I) E^(
1046.72 t) Sin[t] Sin[446.248 t]^2) +
3.03*10^9 E^(-1046.72 t) ((-8.03537*10^-11 - 1.39303*10^-24 I) E^(
650.424 t) + (8.03537*10^-11 - 8.05385*10^-26 I) E^(1046.72 t)
Cos[t] - (8.47625*10^-10 - 4.29708*10^-24 I) E^(1004.81 t)
Cos[54.9614 t] - (4.1359*10^-25 - 3.9074*10^-24 I) E^(
692.338 t)
Cos[t] Cos[54.9614 t] + (1.03398*10^-25 + 3.5992*10^-27 I) E^(
1401.11 t)
Cos[t] Cos[54.9614 t] + (8.47625*10^-10 - 5.41913*10^-24 I) E^(
1046.72 t)
Cos[t] Cos[
54.9614 t]^2 + (6.14725*10^-13 - 6.10798*10^-25 I) E^(
438.214 t)
Cos[446.248 t] + (3.23117*10^-26 + 5.01052*10^-27 I) E^(
834.514 t)
Cos[t] Cos[446.248 t] + (7.81944*10^-25 - 2.43384*10^-24 I) E^(
1258.93 t)
Cos[t] Cos[446.248 t] + (6.46235*10^-26 - 7.19904*10^-25 I) E^(
480.129 t)
Cos[t] Cos[54.9614 t] Cos[
446.248 t] + (3.87741*10^-26 + 1.11845*10^-24 I) E^(1613.32 t)
Cos[t] Cos[54.9614 t] Cos[
446.248 t] - (6.14725*10^-13 - 1.32569*10^-24 I) E^(1046.72 t)
Cos[t] Cos[
446.248 t]^2 - (3.18442*10^-8 - 3.19174*10^-23 I) E^(1046.72 t)
Sin[t] + (4.96308*10^-23 + 4.02033*10^-25 I) E^(692.338 t)
Cos[54.9614 t] Sin[t] - (2.64698*10^-23 + 1.42636*10^-24 I) E^(
1401.11 t)
Cos[54.9614 t] Sin[t] + (2.63493*10^-8 - 2.86444*10^-23 I) E^(
1046.72 t)
Cos[54.9614 t]^2 Sin[
t] - (6.61744*10^-24 + 1.98567*10^-24 I) E^(834.514 t)
Cos[446.248 t] Sin[t] + (2.64698*10^-23 + 5.45367*10^-26 I) E^(
1258.93 t)
Cos[446.248 t] Sin[t] - (8.27181*10^-25 + 4.3665*10^-25 I) E^(
480.129 t)
Cos[54.9614 t] Cos[446.248 t] Sin[
t] - (6.61744*10^-24 + 5.84152*10^-24 I) E^(1613.32 t)
Cos[54.9614 t] Cos[446.248 t] Sin[
t] + (5.51543*10^-9 - 4.05411*10^-24 I) E^(1046.72 t)
Cos[446.248 t]^2 Sin[
t] - (1.12583*10^-9 + 2.02982*10^-24 I) E^(1004.81 t)
Sin[54.9614 t] - (7.23783*10^-25 - 3.03256*10^-24 I) E^(
692.338 t)
Cos[t] Sin[54.9614 t] - (5.16988*10^-26 + 9.77524*10^-27 I) E^(
1401.11 t)
Cos[t] Sin[54.9614 t] - (4.1359*10^-25 + 7.33553*10^-24 I) E^(
1046.72 t)
Cos[t] Cos[54.9614 t] Sin[
54.9614 t] - (0. + 6.63849*10^-25 I) E^(480.129 t)
Cos[t] Cos[446.248 t] Sin[
54.9614 t] - (1.32478*10^-25 + 3.82606*10^-25 I) E^(1613.32 t)
Cos[t] Cos[446.248 t] Sin[
54.9614 t] - (0. + 1.19073*10^-23 I) E^(692.338 t)
Sin[t] Sin[54.9614 t] + (0. + 3.87393*10^-24 I) E^(1401.11 t)
Sin[t] Sin[54.9614 t] - (2.64698*10^-23 - 1.27376*10^-23 I) E^(
1046.72 t)
Cos[54.9614 t] Sin[t] Sin[
54.9614 t] + (3.30872*10^-24 - 1.47153*10^-24 I) E^(480.129 t)
Cos[446.248 t] Sin[t] Sin[
54.9614 t] + (6.61744*10^-24 + 6.74386*10^-24 I) E^(1613.32 t)
Cos[446.248 t] Sin[t] Sin[
54.9614 t] + (8.47625*10^-10 - 2.49913*10^-26 I) E^(1046.72 t)
Cos[t] Sin[54.9614 t]^2 + (2.63493*10^-8 - 2.6428*10^-23 I) E^(
1046.72 t)
Sin[t] Sin[
54.9614 t]^2 - (1.15213*10^-11 + 1.71487*10^-25 I) E^(
438.214 t)
Sin[446.248 t] - (5.16988*10^-26 + 8.97226*10^-28 I) E^(
834.514 t)
Cos[t] Sin[446.248 t] - (1.79007*10^-24 + 4.01536*10^-24 I) E^(
1258.93 t)
Cos[t] Sin[446.248 t] - (7.75482*10^-26 - 8.63458*10^-25 I) E^(
480.129 t)
Cos[t] Cos[54.9614 t] Sin[
446.248 t] + (7.04396*10^-25 + 1.99742*10^-24 I) E^(1613.32 t)
Cos[t] Cos[54.9614 t] Sin[
446.248 t] + (1.00025*10^-24 + 1.12622*10^-24 I) E^(1046.72 t)
Cos[t] Cos[446.248 t] Sin[
446.248 t] + (1.32349*10^-23 + 3.55571*10^-25 I) E^(834.514 t)
Sin[t] Sin[446.248 t] + (3.30872*10^-24 + 3.4226*10^-25 I) E^(
1258.93 t)
Sin[t] Sin[446.248 t] - (8.27181*10^-25 - 4.12791*10^-25 I) E^(
480.129 t)
Cos[54.9614 t] Sin[t] Sin[
446.248 t] - (6.61744*10^-24 + 6.7023*10^-26 I) E^(1613.32 t)
Cos[54.9614 t] Sin[t] Sin[
446.248 t] + (0. + 3.19102*10^-24 I) E^(1046.72 t)
Cos[446.248 t] Sin[t] Sin[
446.248 t] + (2.58494*10^-26 + 6.83589*10^-25 I) E^(480.129 t)
Cos[t] Sin[54.9614 t] Sin[
446.248 t] - (1.90639*10^-25 + 7.9459*10^-25 I) E^(1613.32 t)
Cos[t] Sin[54.9614 t] Sin[
446.248 t] - (4.96308*10^-24 - 5.19765*10^-25 I) E^(480.129 t)
Sin[t] Sin[54.9614 t] Sin[
446.248 t] - (0. + 6.20149*10^-24 I) E^(1613.32 t)
Sin[t] Sin[54.9614 t] Sin[
446.248 t] - (6.14725*10^-13 + 6.86446*10^-25 I) E^(1046.72 t)
Cos[t] Sin[
446.248 t]^2 + (5.51543*10^-9 - 2.22967*10^-24 I) E^(1046.72 t)
Sin[t] Sin[446.248 t]^2)}*)


Why? Am I doing this wrongly? Is there something I'm missing?

• You seem to have a lot of numerical errors, Chop[] them away. Commented Dec 21, 2016 at 16:29

This is a 5 order lowpass filter.

tf = TransferFunctionModel[{{(1.07868*^12 +
3.03*^9*s)/(1.0781151104934349*^12 +
2.3941625151720203*^10*s + 3.215341962707181*^8*s^2 +
1.1917457990193355*^6*s^3 + 1697.1476160000002*s^4 + s^5)}}, s]


To show how this filter works:

 Plot[Abs[tf[I 2 π f]], {f, 0, 50}, PlotRange -> All,
GridLines -> Automatic, AxesLabel -> {"f", "Abs[tf]"}]


It is advisable to set the precision to a higher value.

sysbeta = StateSpaceModel@SetPrecision[tf, 50];
out = OutputResponse[sysbeta, 1000 Sin[t], t, WorkingPrecision -> 50];


This is just a small section. One can see that the imaginary parts are orders of magnitude smaller than the real values.

Plot[out, {t, 0, 20}, GridLines -> Automatic]


It is not recommended to use the procedure "Chop" here!

out2 = OutputResponse[sysbeta, 1000 Sin[t], t, WorkingPrecision -> 50] // Chop;
Plot[out2, {t, 0, 20}, GridLines -> Automatic]


• But if you used Expand before Chop, then the issue does not arise. out2 = out // Expand // Chop. Commented Dec 23, 2016 at 16:42
• @Suba Thomas Yes, that's right, but who is whispering to me before the calculation?
– user36273
Commented Dec 23, 2016 at 17:53
• Thanks @rewi for helping. I realized that Chop[] by itself didn't fit to my needs too. I anyhow learned how to use WorkingPrecision in OutputResponse in your answer! Commented Dec 23, 2016 at 17:57
• rewi, I don't know. But it better not be the ghosts of Runge or Kutta. :) Commented Dec 23, 2016 at 18:56