0
$\begingroup$

I have a step response function defined as:

response = 1.044871614559231` + 
  188851.40028652488` E^(-0.0008027739947742557` t) - 
  481567.05488752836` E^(-0.0007618214677503482` t) + 
  533421.153826132` E^(-0.0006976033182554547` t) - 
  381881.5025204858` E^(-0.0006157908128333724` t) + 
  210904.71677914335` E^(-0.0005235899247183814` t) - 
  101302.35227639876` E^(-0.0004290764551077835` t) + 
  45982.83099921907` E^(-0.00034042402473086035` t) - 
  20314.01115736056` E^(-0.0002650553359099233` t) + 
  8074.680386193031` E^(-0.0002087261148901471` t) - 
  1985.479134371541` E^(-0.00017465012059731007` t)

and I am trying to add up the responses to certain jumps:

jump = {10, 10, 10, 10, 90, 250, 580, 1930, 1910, 
  120, -730, -930, -650, -420, -300, -270, -240, -230, -230, -220,
-170, -130, -110, -100} 

at certain times:

jumptime = {10800, 21600, 32400, 43200, 54000, 64800, 75600, 86400, 
  97200, 108000, 118800, 129600, 140400, 151200, 162000, 172800, 
  183600, 194400, 205200, 216000, 226800, 237600, 248400, 259200}

If I define the lag-response function by:

r[j_] := jump[[j]]*
   UnitStep[
    t - jumptime[[j]]]*(response /. t -> (t - jumptime[[j]])) // 
  Simplify

and calculate the superposition of lagged jumps by:

totalresponse = Sum[r[tt], {tt, 1, 23}];

I get artifacts in the solution:

enter image description here

which are due to large numbers not being cancelled out. How can I fix this problem?

$\endgroup$
3
$\begingroup$

There is a large spike at the beginning of your response:

LogPlot[1 + response, {t, 0, 100000}, PlotRange -> Full, PlotStyle -> Red]

enter image description here

Remove it:

response2 = Piecewise[{{0, t < 10000}}, response];

r2[j_] := jump[[j]]*
   UnitStep[t - jumptime[[j]]]*(response2 /. t -> (t - jumptime[[j]])) // Simplify

totalresponse2 = Sum[r2[tt], {tt, 23}] // PiecewiseExpand;

Plot[totalresponse2, {t, 0, 350000}, Exclusions -> None]

enter image description here

$\endgroup$
2
$\begingroup$

Use rationals rather than floating point numbers. Using your definitions of response and the jump variables:

res[t_] := Rationalize[#, 0] & /@ response;
r[j_] := jump[[j]]*UnitStep[t - jumptime[[j]]]*res[t - jumptime[[j]]];
totalresponse[t_] := Sum[r[tt], {tt, 1, 23}];
Plot[totalresponse[t], {t, 0, 250000}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Nice workaround. However, the solution should be a smooth curve. See, the curve is showing in my plot. $\endgroup$
    – MathX
    Feb 19 '17 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.