MathGroup Archive 2001

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

Search the Archive

Re: Re: Integrate a matrix-function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27535] Re: [mg27488] Re: Integrate a matrix-function
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Sat, 3 Mar 2001 03:40:17 -0500 (EST)
  • References: <97cemm$d9s@smc.vnet.net> <97fepk$fu5@smc.vnet.net> <200103010853.DAA19744@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

I pasted your data into my notebook and it works (BTW, there is no need to
use SetDelayed with constants). The only change I made is use Integrate
instead of NIntegrate. I tried with Case one: Defining using entries.
Actually, the result was obtained almost at once:

In[1]:=
N[EX[1, 2]] // Timing
Out[1]=
{0.11 Second, {-0.218434, 0., 0.148989}}

I wonder if this is the kind of answer you were expecting.

Tomas Garza
Mexico City


----- Original Message -----
From: "Martin Richter" <mrMICE.fi at cbs.dk>
To: mathgroup at smc.vnet.net
Subject: [mg27535] [mg27488] Re: Integrate a matrix-function


> Hi
>
> Yes I should have started with a simple example and the one you gave me is
> working. I must say that in my case it looks like a Mathematica BUG. I
know
> that in 99,999% of the cases your are the dummy but here is my example
(the
> code is of course take out of content but you should be able to just paste
> it into Mathematica, if you/anyone has the time)
>
> So if anyone can explain, it would be great:
> Martin
>
> Code:
> A := {{0, -1, -1/2}, {0, -\[Alpha], 0}, {0, 0, -\[Kappa]}}
> B[t_] := {r, \[Alpha]*\[Beta][t], \[Kappa]*\[Theta]}
> IntegrandMean[u_, t_] := Simplify[MatrixExp[A*(t - u)].B[u]]
> X := {logP, \[Delta], v}
>
>
> \[Alpha] := 1; \[Kappa] := 5; \[Theta] := 1/5; r := 1/15;
> \[Beta]11 := 1/10; \[Beta]12 := 1/10; \[Beta]21 := 1/10; \[Beta]22 :=
1/10;
> logP := 4; \[Delta] := 1/5; v := 1/20;
>
> \[Beta][t_] := \[Beta]11*Cos[2*Pi*t] + \[Beta]12*Sin[2*Pi*t] + \[Beta]21*
>       Cos[4*Pi*t] + \[Beta]22*Sin[4*Pi*t]
>
>
> // Case one: Defining using entries:
> EX[s_, t_] := (MatrixExp[A*(t - s)] - IdentityMatrix[3]).X + {NIntegrate[
>         IntegrandMean[s, u][[1]], {u, s, t}],
>       NIntegrate[IntegrandMean[s, u][[2]], {u, s, t}],
>       NIntegrate[IntegrandMean[s, u][[3]], {u, s, t}]}
> N[EX[1, 2]]
>
> ---------
> Output:
> \!\({\(-0.21843440253831964`\), 2.7755575615628914`*^-17,
>     0.14898930795013723`}\)
>
> file://Case two: Using vector/matrix formulation
> EX1[s_, t_] := (MatrixExp[A*(t - s)] - IdentityMatrix[3]).X +
>     NIntegrate[IntegrandMean[s, u], {u, s, t}]
> N[EX1[1, 2]]
>
> ----------
> Output:
> \!\(NIntegrate::"inum" \(\(:\)\(\ \)\)
>     "Integrand \!\({\(\(-0.10381870152841678`\)\), 0.1213061319425267`, \
> 0.0820849986238988`}\) is not numerical at \!\({u}\) = \!\({3\/2}\)."\)
> And so one:
>
>
>
> "Allan Hayes" <hay at haystack.demon.co.uk> wrote in message
> news:97fepk$fu5 at smc.vnet.net...
> > Martin,
> >
> > With
> > f[s_,t_] := {{s t, s t^2},{s^2 t,s^2 t^2}}
> >
> > The integration that you  use seems to do what you want: the outpur is a
> > matrix of the same size as the integrand.
> >
> > Integrate[f[u,t],{u,s,t}]
> >
> > {{t*(-(s^2/2) + t^2/2), t^2*(-(s^2/2) + t^2/2)},
> >   {t*(-(s^3/3) + t^3/3), t^2*(-(s^3/3) + t^3/3)}}
> >
> > --
> > Allan
> > ---------------------
> > Allan Hayes
> > Mathematica Training and Consulting
> > Leicester UK
> > www.haystack.demon.co.uk
> > hay at haystack.demon.co.uk
> > Voice: +44 (0)116 271 4198
> > Fax: +44 (0)870 164 0565
> >
> > "Martin Richter" <mrMICE.fi at cbs.dk> wrote in message
> > news:97cemm$d9s at smc.vnet.net...
> > > Hi
> > >
> > > I'm using Mathematical 4.0. The problem is the following.
> > >
> > > I have a function, say f[s_,t_], there s,t are real numbers and the
> output
> > > is a matrix of size (n,n). I need to integrate each component in the
> > matrix,
> > > i.e. make a new function, like this:
> > > g[s_,t_] := Integrate[f[u,t], {u,s,t}] // error
> > >
> > > So right now I have a line for each element but I think there is a
> > one-line
> > > way of doing this (using Map or Apply) ?
> > >
> > > Thanks IA for any help
> > > Martin
> > >
> > >
> > > ----------------------------------------------
> > > Please remove the PET to reply by email
> > >
> > >
> > >
> >
> >
> >
>
>
>



  • Prev by Date: RE: Cobweb Plot
  • Next by Date: Re: Cobweb Plot
  • Previous by thread: Re: Integrate a matrix-function
  • Next by thread: Re: Integrate a matrix-function