MathGroup Archive 2008

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

Search the Archive

Piecewise function involving matrices

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


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[163]:= A={{1,.1},{.1,-1}};

In[171]:= H0={{0,b},{b,0}};

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

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

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

In[182]:= H[0.4]
Out[182]= {{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.
In[183]:= Integrate[H[x],{x,0,1}]

{{{{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
Same with:
In[186]:= Integrate[H[x][[1,1]],{x,0,1}]
Out[186]= {{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