Re: Handling several variables at once during matrix multiplications

• To: mathgroup at smc.vnet.net
• Subject: [mg30923] Re: Handling several variables at once during matrix multiplications
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Thu, 27 Sep 2001 02:16:40 -0400 (EDT)
• References: <9omhu5\$nls\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Yasvir,
> But I want to do it in such a way that t is divided up into 100
> increments. So starting with t = 1/100, I want to evaluate mat and
> multiply it by vec. I then want to evaluate mat at t = 2/100 (next
> increment) and multiply it by newvec to give a new newvec to which I
> want to add vec (previous solution) (Some use of FoldList????)

Yes, FoldList works:

FoldList[(#2.#1)+ #1&,v,Table[m[i],{i,3}]]

{v,v+m[1].v,v+m[1].v+m[2].(v+m[1].v),
v+m[1].v+m[2].(v+m[1].v)+m[3].(v+m[1].v+m[2].(v+m[1].v))}

If you want only the last entry in the list then use Fold

--
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

"Yasvir Tesiram" <y.tesiram at pgrad.unimelb.edu.au> wrote in message
news:9omhu5\$nls\$1 at smc.vnet.net...
> Dear Group,
> Could someone point me in the right direction of a matrix multiplied by
> a vector, where the matrix elements change with each increment of data
> and the final vector becomes the initial vector.
>
> I have 2x2 matrix,
>
> mat = {{fxx,fxy},{fyx,fyy}};
>
> where the elements of the matrix are defined as,
>
> fxx[rfMax_, bwdth_, Tp_, t_, np_, s_] :=
>      Sin[\[Beta]]^2*Cos[\[Theta][rfMax, bwdth, Tp, t, np, s]] +
>        Cos[\[Beta]]^2*(Cos[\[Alpha][rfMax, bwdth, Tp, t, np, s]]^2 +
>              Sin[\[Alpha][rfMax, bwdth, Tp, t, np, s]]^2*
>                Cos[\[Theta][rfMax, bwdth, Tp, t, np, s]]);
> fxy[rfMax_, bwdth_, Tp_, t_, np_,
>        s_] := -Sin[\[Alpha][rfMax, bwdth, Tp, t, np, s]]*
>          Sin[\[Theta][rfMax, bwdth, Tp, t, np, s]] -
>        Sin[2*\[Beta]]*(Cos[\[Alpha][rfMax, bwdth, Tp, t, np, s]]^2*
>              Sin[\[Theta][rfMax, bwdth, Tp, t, np, s]/2]^2);
> fyx[rfMax_, bwdth_, Tp_, t_, np_, s_] :=
>      Sin[\[Alpha][rfMax, bwdth, Tp, t, np, s]]*
>          Sin[\[Theta][rfMax, bwdth, Tp, t, np, s]] -
>        Sin[2*\[Beta]]*(Cos[\[Alpha][rfMax, bwdth, Tp, t, np, s]]^2*
>              Sin[\[Theta][rfMax, bwdth, Tp, t, np, s]/2]^2);
> fyy[rfMax_, bwdth_, Tp_, t_, np_, s_] :=
>      Cos[\[Beta]]^2*Cos[\[Theta][rfMax, bwdth, Tp, t, np, s]] +
>        Sin[\[Beta]]^2*(Cos[\[Alpha][rfMax, bwdth, Tp, t, np, s]]^2 +
>              Sin[\[Alpha][rfMax, bwdth, Tp, t, np, s]]^2*
>                Cos[\[Theta][rfMax, bwdth, Tp, t, np, s]]);
>
> and a vector,
>
> vec = {Ix, Iy}.  (*vec = {0,1} say*)
>
> I want the operation,
>
> newvec = mat . vec.
>
> But I want to do it in such a way that t is divided up into 100
> increments. So starting with t = 1/100, I want to evaluate mat and
> multiply it by vec. I then want to evaluate mat at t = 2/100 (next
> increment) and multiply it by newvec to give a new newvec to which I
> want to add vec (previous solution) (Some use of FoldList????)
> In the above equations, Tp and bwdth are chosen and then there are two
> conditions for s and rfMax. If I want to evaluate rfMax (let s = 0), how
> do I go about incrementing rfMax whilst conducting the matrix
> multiplication.  The rest of the equations are given below.
> Plots of Ix versus rfMax and Iy versus rfMax and s versus Ix and s
> versus Iy will be helpful but I think I can manage that. Any comments
> are welcome.
>
> Thanks
> Yas
>
> b1[rfMax_, Tp_, t_, np_] := rfMax * Sech[(betaN/2) * (1 - (2t/Tp))];
> dH[bwdth_, Tp_, t_, np_, s_] := (-bwdth/2) *
>        Tanh[(betaN/2) * (1 - (2t/Tp)) + s];
> be[rfMax_, bwdth_, Tp_, t_, np_, s_] :=
>      Sqrt[b1[rfMax, Tp, t, np]^2 + dH[bwdth, Tp, t, np, s]^2];
> \[Alpha][rfMax_, bwdth_, Tp_, t_, np_, s_] :=
>      ArcSin[dH[bwdth, Tp, t, np, s]/be[rfMax, bwdth, Tp, t, np, s]];
> \[Theta][rfMax_, bwdth_, Tp_, t_, np_, s_] :=
>      2*Pi*be[rfMax, bwdth, Tp, t, np, s]*t;
>

```

• Prev by Date: Re: Preserve natural number "e" using N or SetPrecision
• Next by Date: Re: Export table problem
• Previous by thread: Handling several variables at once during matrix multiplications