|
[Date Index]
[Thread Index]
[Author Index]
Re: Integrate piecewise with Assumptions
- To: mathgroup at smc.vnet.net
- Subject: [mg44153] Re: Integrate piecewise with Assumptions
- From: "Chia-Ming Yu" <yucalf at mail.educities.edu.tw>
- Date: Fri, 24 Oct 2003 04:24:30 -0400 (EDT)
- Organization: DCI HiNet
- References: <bn2iop$o1e$1@smc.vnet.net> <bn8der$ndn$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Dear Sir Poujade,
You can call me Chia-Ming, I am a graduate student in Taiwan.
Thank you for your kindly sharing of your two marvelous modules.
I believe that you have studied the machanism of integration for a period.
I believe they will help me a lot, and I will report the results of my test
to you as soon as possible.
Glad to discuss challenging questions with you!
Chia-Ming
"Jean-Claude Poujade" <poujadej at yahoo.fr> ¦b¶l¥ó
news:bn8der$ndn$1 at smc.vnet.net ¤¤¼¶¼g...
> "Chia-Ming" <yucalf at mail.educities.edu.tw> wrote in message
news:<bn2iop$o1e$1 at smc.vnet.net>...
> > Excuse me,
> >
> > First, I define a piecewise function to discribe the shortest distance
> > on the edge of a circle.
> >
> > dis[x_, xi_] :=
> > Which[1/2 >= x - xi >= 0, x - xi, x - xi > 1/2, 1 - (x - xi),
> > 0 > x - xi >= -1/2, xi - x, x - xi < -1/2, 1 - (xi - x)]
> >
> > And it does works that it can automatically judge to go in a clockwise
> > or a conter-clockwise direction.
> >
> > dis[2/3, 1/10]
> > 13/30
> >
> > Furthermore, dis[] can be applied in the Integrate[] command:
> >
> > Integrate[(a - 5 dist[1/6, x])^2, {x, 0, 1}]// Simplify
> > 25/12 - (5 a)/2 + a^2
> >
> > However, it can not work with the option Assumptions:
> >
> > Integrate[(a - 5 dist[y, x])^2, {x, 0, 1},
Assumptions->0<y<1/2]//Simplify
> [...]
>
> Dear Chia-Ming (or should I write Dear Yu ?)
>
> You better use UnitStep functions to describe your function.
> Here are two small modules that might help you
> to build piecewise constant functions,
> or piecewise linear functions, expressed
> in terms of UnitStep functions.
>
> In[1]:=(* 'pcf' is piecewise constant function constructor.
> Function is expressed in terms of UnitStep functions.
> call format : pcf[y0, listOfPoints, x]
> input :
> y0 = leftmost value
> listOfPoints = {{x1,y1},...,{xn,yn}} where yi are right values
> at points of discontiuity
> x = variable used to generate output expression
> output :
> piecewise constant function expressed in terms of UnitStep
> functions
> using 'x' as variable
> *)
>
> pcf[y0_, listOfPoints_List, x_]:=
> Module[{lp = Length[listOfPoints], f, a, b, eq, vars},
> f[u_] := Sum[a[i]UnitStep[u-listOfPoints[[i,1]]],{i,1,lp}]+b;
> eq = Append[f[#[[1]]] == #[[2]]& /@ listOfPoints,f[-Infinity] ==
> y0];
> vars = Append[Table[a[i],{i,1,lp}],b];
> First[f[x] /. Solve[eq,vars]]
> ];
>
> (* example of a square bump *)
> pcf[0,{{0,1},{1,0}},x]
> Out[2]=-UnitStep[-1+x]+UnitStep[x]
>
> In[3]:=(* a stairs function : *)
> pcf[0,{{0,1},{1,2},{2,3},{3,4},{4,5},{5,0}},x]
> Out[3]=-5
UnitStep[-5+x]+UnitStep[-4+x]+UnitStep[-3+x]+UnitStep[-2+x]+UnitStep[-1+x]+
> UnitStep[x]
>
> In[4]:=(* plf is a piecewise linear function constructor.
> (function may be discontinuous)
> call format : plf[leftSlope0_, listOfPoints_List, x_]
> input :
> leftSlope0 : leftmost slope
> listOfPoints format :
> {{x1, lefty1, righty1, rightSlope1},...,
> {xn, leftyn, rightyn, rightSlopen}}
> x : variable
> output :
> piecewise linear function expressed in terms of UnitStep functions
> using 'x' as variable
> *)
>
> plf[leftSlope0_, listOfPoints_List, x_]:=
> Module[{deltaFunctions, pcfPoints, tempPlf, k, sol},
> deltaFunctions = (#[[3]]-#[[2]])DiracDelta[x-#[[1]]]&/@listOfPoints;
> pcfPoints = {#[[1]],#[[4]]}& /@ listOfPoints;
> tempPlf =
Integrate[pcf[leftSlope0,pcfPoints,x]+Plus@@deltaFunctions,x]+k;
> sol = Solve[(tempPlf/.x -> (listOfPoints[[1,1]]+
>
listOfPoints[[2,1]])/2)==(listOfPoints[[1,3]]+listOfPoints[[2,2]])/2,k];
> tempPlf/.sol[[1]]
> ];
>
> (* example of a sawtooth function *)
> plf[0,{{0,0,0,1},{1,1,0,1},{2,1,0,1},{3,1,0,0}},x] //Simplify
>
> Out[5]=-(-2+x) UnitStep[-3+x]-UnitStep[-2+x]-UnitStep[-1+x]+x
> UnitStep[x]
>
> In[6]:=(* the bump function may be expressed two ways : *)
> plf[0,{{0,0,1,0},{1,1,0,0}},x] == pcf[0,{{0,1},{1,0}},x]//Simplify
> Out[6]=True
>
> Hoping this will help you
> ---
> jcp
>
Prev by Date:
RE: LogLogListPlot, LogLinearListPlot- Ticks and TickMarks
Next by Date:
Extracting Terms From a List
Previous by thread:
Re: Integrate piecewise with Assumptions
Next by thread:
NotebookML & css
|