       Piecewise function involving matrices

• To: mathgroup at smc.vnet.net
• Subject: [mg91223] Piecewise function involving matrices
• From: kaveh <kavehkh at gmail.com>
• Date: Sat, 9 Aug 2008 07:50:12 -0400 (EDT)

```Hi,

I am trying to define a piecewise matrix function of time with
Mathematica that I later want to use to transform another matrix as a
function of time and integrate it. To make it simple I have

In:= A={{1,.1},{.1,-1}};

In:= H0={{0,b},{b,0}};

In:= F[t_]:=Piecewise[{{exp[-I t] A,0<t<1},{exp[+I t] A,1<t<2}}]

In:= F[0.1]
Out= {{exp[-0.1 \[ImaginaryI]],0.1 exp[-0.1 \[ImaginaryI]]},{0.1
exp[-0.1 \[ImaginaryI]],-exp[-0.1 \[ImaginaryI]]}}

In:= H[t_]:= Inverse[F[t]].H0.F[t]+H0.H0

In:= H[0.4]
Out= {{0.19802 b+b^2,-0.980198 b},{-0.980198 b,-0.19802 b+b^2}}

The problem is that when I evaluate H[t] for a given number, it
returns the right value but if t is a symbol Mathematica naturally
leaves it as unevaluated. This by itself is nice, however when I want
to integrate H[t], I run into problems.
Say
In:= Integrate[H[x],{x,0,1}]

Out=
{{{{0.00990099 (20. b+101. b^2),0.00990099 (-99. b+101. b^2)},
{0.00990099 (-99. b+101. b^2),0.00990099 (-20. b+101. b^2)}},{{0.19802
b,-0.980198 b},{-0.980198 b,-0.19802 b}}},{{{0.19802 b,-0.980198 b},
{-0.980198 b,-0.19802 b}},{{0.00990099 (20. b+101. b^2),0.00990099
(-99. b+101. b^2)},{0.00990099 (-99. b+101. b^2),0.00990099 (-20. b
+101. b^2)}}}}

Notice that the output is not a 2x2 matrix but has dimensions
{2,2,2,2}!
Same with:
In:= Integrate[H[x][[1,1]],{x,0,1}]
Out= {{0.00990099 (20. b+101. b^2),0.00990099 (-99. b+101. b^2)},
{0.00990099 (-99. b+101. b^2),0.00990099 (-20. b+101. b^2)}}
which should be just a number but is a 2x2 matrix!

Obviously there is something wrong with the treatment of piecewise as
an array instead of a flat thing.

Any ideas or neat ways of not resorting to step functions?

```

• Prev by Date: Re: Making parts of formulae blinking
• Next by Date: Re: Making parts of formulae blinking
• Previous by thread: When will there be *offical* support for Mathematica on Solaris x86
• Next by thread: Re: Piecewise function involving matrices