Question: Getting a weird result with integration of an absolute value

I'm working on a simple toy model as an introductory example to some work I am writing up. I was hoping the example would be simple enough to get some nice analytical results to write up. However, maple is giving me some odd results.

Essentially I have taken the integral of the absolute value of an error that I have caluclated which has given me a somewhat nonsensical result. The attached file contains the specifics (hopefuly it's visible)...

assume(0 < k[1]);

x2 := solve(simplify(subs(_C1 = solve(subs(t = 0, dsolve(diff(x[2](t), t) = k[1]*x1-k[2]*x[2](t), x[2](t))), _C1), dsolve(diff(x[2](t), t) = k[1]*x1-k[2]*x[2](t), x[2](t)))), x[2](t)):

KL := simplify(k[2]*x2/(x1+x2)):

KLst := limit(KL, t = infinity): 

ErTime := abs(KLst*(x1+x2)-k[2]*x2)

abs(k[2]*k[1]*((k[0]+exp(-k[1]*t)*x[1](0)*k[1]-exp(-k[1]*t)*k[0])/k[1]-(k[2]*exp(k[2]*t)*k[0]-exp(k[2]*t)*k[0]*k[1]+x[1](0)*k[1]*exp(-t*(-k[2]+k[1]))*k[2]-k[0]*exp(-t*(-k[2]+k[1]))*k[2]+x[2](0)*k[2]^2-x[2](0)*k[2]*k[1]+k[0]*k[1]-x[1](0)*k[1]*k[2])*exp(-k[2]*t)/(k[2]*(-k[2]+k[1])))/(k[1]+k[2])+(k[2]*exp(k[2]*t)*k[0]-exp(k[2]*t)*k[0]*k[1]+x[1](0)*k[1]*exp(-t*(-k[2]+k[1]))*k[2]-k[0]*exp(-t*(-k[2]+k[1]))*k[2]+x[2](0)*k[2]^2-x[2](0)*k[2]*k[1]+k[0]*k[1]-x[1](0)*k[1]*k[2])*exp(-k[2]*t)/(-k[2]+k[1]))

(1)

``

Now I have an expression for the absolute error at a given time between an approximate and exact value of a curve - I want to integrate this expression to give a total error value. Doing so the obvious way gives the unexpectedly nice result:

 

TotEr := simplify(expand(int(ErTime, t = 0 .. infinity)))

-(-k[0]+x[2](0)*k[2])*signum(x[1](0)*k[1]-x[2](0)*k[2])/(k[1]+k[2])

(2)

This seems odd due to the fact that setting x[2](0)*k[2] = k[0] would give zero total error. I checked this with values  k[0] = 3, k[2] = .1, x[2](0) = 30 which gives the following results

 

The plot of the two curves (exact and symbolic) we are determining the error of:

 

plot([subs([k[0] = 3, k[1] = .2, k[2] = .1, x[1](0) = 0, x[2](0) = 30], k[2]*x2), subs([k[0] = 3, k[1] = .2, k[2] = .1, x[1](0) = 0, x[2](0) = 30], KLst*(x1+x2))], t = 0 .. 80)

 

The plot of the absolute value of the time dependent error:

 

  plot(subs([k[0] = 3, k[1] = .2, k[2] = .1, x[1](0) = 0, x[2](0) = 30], ErTime), t = 0 .. 40)

 

The plot of the area under the curve of the previous plot:

 

plot(int(subs([k[0] = 3, k[1] = .2, k[2] = .1, x[1](0) = 0, x[2](0) = 30], ErTime), t), t = 0 .. 70)

 

Finally the actual values of the integration for this case:

 

int(subs([k[0] = 3, k[1] = .2, k[2] = .1, x[1](0) = 0, x[2](0) = 30], ErTime), t)

piecewise(t < 6.931471804, -1.000000000*10^(-10)*t-5.*exp(-.2000000000*t)+9.999999999*exp(-.1000000000*t)-5.000000000*(exp(-.1000000000*t))^2, t = 6.931471804, 2.499999999, 6.931471804 < t, 1.000000000*10^(-10)*t+5.*exp(-.2000000000*t)-9.999999999*exp(-.1000000000*t)+5.000000000*(exp(-.1000000000*t))^2+4.999999998)

(3)

 

Clearly this does not give 0 total error, but rather a total error of 5. As far as I can tell, setting  x[2](0)*k[2] = k[0] does minimise the error (for a fixed k[2]+k[1]), but it does not make it equal to 0. Any advice on what I've done wrong would be gladly recieved.`` 

``

 

Download Integral_Issues.mw

I've probably done something stupid, but any help you can provide would be great! Cheers.

Please Wait...