MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Sheer frustration with integration of piecewise continuous functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40921] Re: [mg40907] Sheer frustration with integration of piecewise continuous functions
  • From: Bobby Treat <drmajorbob+MathGroup3528 at mailblocks.com>
  • Date: Thu, 24 Apr 2003 05:27:48 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Here's a slightly less exhaustive solution:

f1 = {(fpeak/L)*(x/0.6), {x, 0, 0.6*L}};
f2 = {(fpeak/L)*L, {x, 0.6*L, 0.9*L}};
f3 = {(fpeak/L)*10*(L - x), {x, 0.9*L, L}};
functions = {f1, f2, f3};
conditional[{f_, {a_, b_, c_}}] :=
   {b <= a < c, f}
f = Which @@ Flatten@{conditional /@ functions, True, 0}

Plot[Evaluate[f /. {L -> 1, fpeak -> 1}], {x, 0, 1}];
Plus @@ Integrate @@@ functions
% /. {L -> 1, fpeak -> 1}

Bobby

-----Original Message-----
From: Bobby Treat <drmajorbob+MathGroup3528 at mailblocks.com>
To: mathgroup at smc.vnet.net
Subject: [mg40921] Re: [mg40907] Sheer frustration with integration of piecewise 
continuous functions

I hope somebody comes up with a better solution, but here's an 
interesting one.


First, a breakdown of the function into intervals:


before = {0, {x, -Infinity, 0}};
f1 = {(fpeak/L)*(x/0.6), {x, 0, 0.6*L}};
f2 = {(fpeak/L)*L, {x, 0.6*L, 0.9*L}};
f3 = {(fpeak/L)*10*(L - x), {x, 0.9*L, L}};
after = {0, {x, L, Infinity}};
functions = {before, f1, f2, f3, after};


Second, a helper function:


conditional[{f_, {a_, b_, c_}}] := {b <= a < c, f}


This defines and plots the overall function:


f = Which @@ Flatten[conditional /@ functions]
Plot[Evaluate[f /. {L -> 1, fpeak -> 1}], {x, 0, 1}];


And this integrates it:


Plus @@ Integrate @@@ functions
% /. {L -> 1, fpeak -> 1}


Bobby


-----Original Message-----
From: Madhusudan Singh <spammers-go-here at yahoo.com>
To: mathgroup at smc.vnet.net
Subject: [mg40921] [mg40907] Sheer frustration with integration of piecewise 
continuous functions


Clear["'*"];
(*ClearAttributes[Which, HoldAll];*)


f[x_, L_, fpeak_] := (fpeak /L) Which[((0 <= x) && (x < 0.6 L)), x/(0.6
),((0.6 L <= x) && (x <= 0.9 L)), L, ((0.9 L < x) && (x <= L)) , 10 (L
-x)];
Plot[f[x, 1, 1], {x, 0, 1}];
Print[Integrate[f[x, L, fpeak], {x, 0, L}, Assumptions -> {L >= 0, 
fpeak >=
0, x >= 0, x <= L}]];


I have struggled with the above integration (believe me, its just a 
test
case, I have a much more complicated function) for an hour now.


What is missing above ? The plot evaluates but the integral does not. 
Why
does Mathematica make it so damned difficult to work with piecewise
continuous functions ? 


  • Prev by Date: Re: Mathematica and polynomial surface fitting...
  • Next by Date: Re: Mathematica and polynomial surface fitting...
  • Previous by thread: RE: Sheer frustration with integration of piecewise continuous functions
  • Next by thread: Re: Sheer frustration with integration of piecewise continuous functions