MathGroup Archive 1998

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

Search the Archive

RE: [Q] Factoring arrays

  • To: mathgroup at
  • Subject: [mg14981] RE: [mg14929] [Q] Factoring arrays
  • From: "Ersek, Ted R" <ErsekTR at>
  • Date: Wed, 2 Dec 1998 03:59:02 -0500
  • Sender: owner-wri-mathgroup at

Kevin Jaffe wrote:
>I'm dealing with some large arrays of symbolic 
>expressions; it often happens that all the
>elements of the array have an
>obvious common factor.  These
>arrays would become much more
>readable if the common factor were
>pulled out in front as a prefactor
>for the array, but I can't figure
>out how to get Mathematica to do
>this.  As a (tiny) example:
>{{v[2]^2 v[3], -v[1] v[2] v[3]},
> {-v[1] v[2] v[3], v[1]^2 v[3]}}
>Is there a way to get Mathematica
>to pull out the common v[3] factor
>from the array above?
As far as I am aware you have to have something in the output expression to
prevent the common factor from being multiplied through before it's sent out
for display.  HoldForm will work, and you could write a program to find the
common-factor and automate the whole thing.  In the line below I manually
pull out the common factor.

matrx={{v[2]^2 v[3], -v[1] v[2] v[3]},
 {-v[1] v[2] v[3], v[1]^2 v[3]}}/ v[3]; factrd=HoldForm[v[3] #]&[matrx]
(*  your matrix factored  not shown  *)

The problem is that if you want to do anything with this expression you
have to use ReleaseHold first.  For example the line below will find
the Det of the above matrix.



What we really need is a new type of hold that will work like HoldForm,
but is automatically released as soon as you try to do anything (well
almost anything) with the "held" expression.  The idea is to give the
illusion that the held expression was fully evaluated.

I have asked several developers at Wolfram Research to provide such a
feature.  Although I am not sure if they have any plans to provide it.

Other applications for this feature are shown below.
I might like to have a function give a result in increasing powers of a
monomial.  An example of such an output is:
But Mathematica insist on arranging the above canonical order giving:
  2(e-h)^2 + 5(e-h)^3*k + 3(e-h)*s
I would like to have an output expression including  the form (w x y
z)^2 displayed without distributing  Power, but Mathematica insists
that this should  evaluate to (w^2x^2y^2z^2).

I would like to have output expressions including  the form Sqrt[5 x]
displayed without distributing  Sqrt, but Mathematica insists that 
Sqrt[5 x] should evaluate to 
(Sqrt[5] Sqrt[x]).
I would like to have an expression containing  48(10^n) do nothing else
with 48(10^n),  but Mathematica insists that 
48(10^n) should evaluate to 
I would like to have Simplify or FullSimplify notice that  the
expression (18446744073709551616-n)/5  can be expressed more concisely
((2^64-n)/5), but Mathematica doesn't do this.   Mathematica insists
that 2^64 should evaluate to  (18446744073709551616).
I would like to be able to get a power series where integers to a power
and factorials are not evaluated.  For example the following would be a
power series expansion of BesselI[0,x].
1+z^2/2^2+z^4/2^4/(2!)^2+z^8/2^8/(4!)^2+O[x]^6 ____________________
Programs can be written to do everything I mention here except the
output expression must make use of HoldForm.  Before the output
expression is used later on one must use ReleaseHold.  The user should
be permitted to any output mentioned above without using ReleaseHold of
a similar construct.

Ted Ersek

  • Prev by Date: Reading Native Excel files
  • Next by Date: Can Factorial[] be compiled?
  • Previous by thread: Re: Reading Native Excel files
  • Next by thread: Can Factorial[] be compiled?