[Date Index]
[Thread Index]
[Author Index]
Re: Integrating Conditionals/piecewise cont. functions
*To*: mathgroup at smc.vnet.net
*Subject*: [mg26250] Re: [mg26221] Integrating Conditionals/piecewise cont. functions
*From*: Roger Germundsson <roger at wolfram.com>
*Date*: Wed, 6 Dec 2000 02:16:32 -0500 (EST)
*References*: <21278@hack.wri.com>
*Sender*: owner-wri-mathgroup at wolfram.com
In Mathematica 4.1 do the following:
(* Load new Standard Package *)
In[1]:=
<< "Calculus`Integration`"
In[2]:=
f[x_, n_] := Which[x < n, 0, n <= x <= n + 1, 1,
n + 1 < x < n + 2, -1, x >= n + 2, 0];
(* Integrate now understands piecewise functions *)
In[3]:=
Integrate[f[x, 3]*f[x, 4], {x}]
Out[3]=
-1
(* Compute the table of integrals of interest *)
In[4]:=
Table[Integrate[f[x, i]*f[x, j], {x}], {i, 5}, {j, 5}]
Out[4]=
{{2, -1, 0, 0, 0}, {-1, 2, -1, 0, 0}, {0, -1, 2, -1, 0},
{0, 0, -1, 2, -1}, {0, 0, 0, -1, 2}}
(* Numeric validation of the above result *)
In[5]:=
Table[ NIntegrate[Evaluate[f[x, i]*f[x, j]],
{x, Min[i, j], Max[i + 2, j + 2]}], {i, 5}, {j, 5}]
Out[5]=
{{2., -1., 0., 0., 0.}, {-1., 2., -1., 0., 0.}, {0., -1., 2., -1., 0.},
{0., 0., -1., 2., -1.}, {0., 0., 0., -1., 2.}}
--Roger
Roger Germundsson
Director of Research and Development
Wolfram Research, Inc
Richard Lindenberg wrote:
>
> I am trying to do some simplified finite elements that simply requires the
> integration of some roof functions (i.e. piecewise continous functions that
> are 0 everywhere except where they ramp up and then down in a specified
> domain). I was hoping that I could do everything symbolically, but
> Mathemtica refuses to integrate every conditional I give it. I can get it to
> do the numerically, but it comes with baggage. This is what I have right
> now:
>
> These are roof functions differentiated
>
> Piecewise continuous
> b'[x_, n_] :=
> Which[x < n, 0, n <= x <= n + 1, 1, n + 1 < x < n + 2, -1, x >= n + 2, 0]
>
> Another way to look at it
> v'[x_, n_] := 0 /; x < n
> v'[x_, n_] := 1 /; n <= x <= n + 1
> v'[x_, n_] := -1 /; n + 1 < x < n + 2
> v'[x_, n_] := 0 /; x >= n + 2
>
> I want to simply do this...
>
> Integrate[v'[x,m] v'[x,n]] for m=n=1...5 (or something)
>
> (If you copy the below item into Mathematica you will see exactly, I
> think...)
>
> Essentially I am trying to make a matrix full of the these functions. The
> numerical integrate seems to work, but keeps spitting up after trying to
> integrate integrands of zero. I suppose if I could turn this off that would
> be good. The other stuff in the table function just makes it a tridiagonal.
>
> \!\(Table[
> Switch[i - j, \(-1\),
> N[\[Integral]\_0\%5\((\(v'\)[x, i]\ \(v'\)[x, j])\)
> \[DifferentialD]x],
> 0, N[\[Integral]\_0\%5\((\(v'\)[x, i]\ \(v'\)[x,
> j])\) \[DifferentialD]x], 1,
> N[\[Integral]\_0\%5\((\(v'\)[x, i]\ \(v'\)[x,
> j])\) \[DifferentialD]x], _, 0], {i, 5}, {j, 5}]\)
>
> Appreciate any help/ideas...
>
> Thanks,
> Rich Lindenberg
> UIUC
Prev by Date:
**Re: Integrating Conditionals/piecewise cont. functions**
Next by Date:
**Re: embedding Mathematica equations in MS Word part 2**
Previous by thread:
**Re: Integrating Conditionals/piecewise cont. functions**
Next by thread:
**Re: embedding Mathematica equations in MS Word part 2**
| |