MathGroup Archive 1998

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

Search the Archive

Re: Mantain unevaluated

  • To: mathgroup at
  • Subject: [mg14601] Re: Mantain unevaluated
  • From: "Allan Hayes" <hay at>
  • Date: Mon, 2 Nov 1998 01:51:08 -0500
  • References: <71bjc0$>
  • Sender: owner-wri-mathgroup at

Guillermo de Paz wrote in message <71bjc0$pn0 at>...
>I'm using Mathematica to obtain the differential equations of some
>mechanical systems and to integrate them numerically. When constructing
>the equations I need to invert a matrix. This matrix is not very big
>(lets say 8x8) but the elements al very long trigonometric expressions,
>the inverse takes a long time. By the other side, it is possible that
>for some values of the dependent variables the rank of the matrix is
>not complete, and the size of the problem decreases. For these reasons
>I would like to have unevaluated this inverse until the numerical
>function NDSolve uses it (not to compute symbolically the matrix, but
>compute it numerically inside NDSolve in each integration step).
>I have done some attempts with := and with Compile, but I cant avoid the
>symbolic  computation of the inverse. Could somebody help me?
>Guillermo de Paz
>Universidad de Valladolid.
>e-mail: guipaz at


mat = {{Sin[x], Cos[x]}, {x, x^2}};

Define an variant of Inverse that evaluates only if the matrix is

InverseN[mat_?(MatrixQ[#, NumberQ] &)] := Inverse[mat];

Then we get


InverseN[{{Sin[x], Cos[x]}, {x, x^2}}]

But if x has a numerical value, say

x = 1.2;

we get


{{1.58711, -0.399377}, {-1.3226, 1.02726}}


Allan Hayes
Mathematica Training and Consulting
hay at
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

  • Prev by Date: Re: spaces in notebook
  • Next by Date: Discontinuity of theta functions
  • Previous by thread: Re: spaces in notebook
  • Next by thread: RE: Mantain unevaluated