Re: Algorithm for calculating matrix exponential



On Apr 27, 2:51 pm, LiorFains...@xxxxxxxxx wrote:
You have a fast reaction time in this group. That's great.
I am a programmer and I will like most of all to see an algorithm,
that I can write in code.
Is there some simple formula, I can use for 2x2 case? I also need a
solution for larger matrices, but that's a separate question.

On Apr 27, 9:46 pm, Jannick Asmus <jannick.n...@xxxxxx> wrote:

On 27.04.2008 20:43, LiorFains...@xxxxxxxxx wrote:

I need an algorithm for calculating an exponential of a small matrix,
with size of at most 6x6. 2x2 case is of particular interest and a
simple and efficient algorithm for this case will be welcome.
I tried using Taylor series expansion. It works for some matices, but
for others it produces wrong results, possibly due to rounding errors.

Thanks

Could diagonalizing the matrix - if possible - or the Cayley-Hamilton
theorem be of some help?

--
Best wishes,
J.

What do you know in advance about the 2x2 matrix?

Is it real? Symmetric? Does it have necessarily
two distinct eigenvalues? Is it nonsingular?

If you don't know these things in advance and are
not keen on doing a bit of case logic to determine
the answers and take advantage where possible, the
Taylor series approach is probably a good one.

You said that you'd gotten some errors, possibly
due to roundoff, in implementing that. It's
possible that your matrix entries are fairly big
and that scaling the matrix will reduce effects
of roundoff error.

Suppose that A is your original matrix. Find
a power of 2 that makes the absolute sum of
entries in A not more than 1, i.e.

B = 2^-k A

where SUM |B(i,j)| <= 1.

Then apply the Taylor series approach to exp(B),
and exp(A) = exp(2^k B) = exp(B)^(2^k), which
can be computed by repeated squarings.

For the best accuracy, Jannick's suggestion of
diagonalizing the matrix should be considered.
That is, suppose A is similar to a diagonal
matrix D, i.e.

D = P A P^-1

for some nonsingular matrix P. Then exp(D) can
be computed by applying the scalar exponential
function to each diagonal entry, and this gives:

exp(A) = P^-1 exp(D) P

by similarity. Not every 2x2 matrix can be
diagonalized, but if A is real symmetric or has
two distinct eigenvalues, then A can be.

regards, chip
.



Relevant Pages

  • Re: erf function in C
    ... > And what about the inverse cumulative normal distribution? ... > I used to implement an algorithm you published, ... should serve very well for solving the equation ... values Aand Bto initalize the Taylor series ...
    (comp.lang.c)
  • Re: erf function in C
    ... Would you still recommend this? ... Is there another fast but portable algorithm with sufficient ... > should serve very well for solving the equation ... the Taylor series was easy and fast only for the first few ...
    (comp.lang.c)
  • Re: opponents of taylor and lhospital ?
    ... like l'hospitals rule nor taylor series. ... There is in fact an _algorithm_ for evaluating limits of a wide class ... precisely it works by computing higher-rank valuations in certain ...
    (sci.math)
  • Re: Algorithm for calculating matrix exponential
    ... You have a fast reaction time in this group. ... I am a programmer and I will like most of all to see an algorithm, ... Could diagonalizing the matrix - if possible - or the Cayley-Hamilton ...
    (sci.math)