Previous Page Next Page Contents

numeric::fMatrix -- functional calculus for numerical square matrices

Introduction

numeric::fMatrix(f, A, ..) computes the matrix f(A,..) with a function f and a square matrix A.

Call(s)

numeric::fMatrix(f, A, p1, p2, ..)

Parameters

f - a procedure representing a scalar function f: C -> C or f: C x P x P x .. -> C, where P is a set of parameters
A - a square matrix of domain type DOM_ARRAY or of category Cat::Matrix
p1, p2, .. - arbitrary MuPAD objects accepted by f as parameters

Returns

The matrix f(A, ..) is returned as an array.

Side Effects

The function is sensitive to the environment variable DIGITS, which determines the numerical working precision.

Related Functions

numeric::expMatrix, numeric::inverse

Details

Example 1

We compute the matrix power A^100:

>> A := array(1..2, 1..2, [[2, PI], [exp(-10), 0]]):
   
>> numeric::fMatrix(x -> x^100, A)
   
                   +-                                -+
                   |  1.272133133e30, 1.998190806e30  |
                   |                                  |
                   |  2.887634784e25, 4.535724387e25  |
                   +-                                -+
      

Alternatively you may use the function _power which takes the exponent as a second parameter.

>> numeric::fMatrix(_power, A, 100)
   
>> delete A:
   

Example 2

We compute the square root of a matrix:

>> A := array(1..2, 1..2, [[0, 1], [-1, 0]]):
   
>> B := numeric::fMatrix(sqrt, A)
   
              array(1..2, 1..2,
                (1, 1) = 0.7071067812 - 1.084202173e-19 I,
                (1, 2) = 0.7071067812 + 2.710505431e-20 I,
                (2, 1) = - 0.7071067812 - 1.084202173e-19 I,
                (2, 2) = 0.7071067812 - 5.421010863e-20 I
              )
      

The small imaginary parts are caused by numerical roundoff. We eliminate them by extracting the real parts of the components:

>> B := map(B, Re)
   
                     +-                             -+
                     |   0.7071067812, 0.7071067812  |
                     |                               |
                     |  -0.7071067812, 0.7071067812  |
                     +-                             -+
      

We verify that B^2 matrix is A. For convenience we convert B to an element of a matrix domain and compute the square by the overloaded operator ^:

>> B := Dom::Matrix(Dom::Complex)(B): B^2
   
                  +-                                   -+
                  |  5.421010863e-20,        1.0        |
                  |                                     |
                  |        -1.0,      -1.084202173e-19  |
                  +-                                   -+
      

This coincides with A up to numerical roundoff.

>> delete A, B:
   

Example 3

We compute exp(t*PI*A) with a symbolic parameter t:

>> A := array(1..2,1..2,[[0,1],[-1,0]]):
   
>> numeric::fMatrix(exp@_mult, A, t*PI)
   
        array(1..2, 1..2,
          (1, 1) = 0.5 exp(-1.0 I t PI) + 0.5 exp(1.0 I t PI),
          (1, 2) = 0.5 I exp(-1.0 I t PI) - 0.5 I exp(1.0 I t PI),
          (2, 1) = 0.5 I exp(1.0 I t PI) - 0.5 I exp(-1.0 I t PI),
          (2, 2) = 0.5 exp(-1.0 I t PI) + 0.5 exp(1.0 I t PI)
        )
      
>> delete A:
   

Background

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000