How to factor a expressions in a matrix with mathematica 7?

In summary, the MatrixSimplify function in Mathematica automatically simplifies a matrix, but it does not automatically simplify the matrix as a whole. You can use the Apply function to extract the denominator of a simplification, but this will block automatic operations.
  • #1
andresordonez
68
0
Hi, is there a way to factor expressions in matrices? for example

In[1]:= MatrixSimplify[{{3/2, 5/2}, {9/2, 1/2}}] (*I just made up the name MatrixSimplify*)

Out[1]:= 1/2 * {{3, 5}, {9, 1}}

I tried with Simplify[] and with Factor[] but it didn't work, it seems they just simplify every element in the matrix but not the matrix as a whole.

Thanks.
 
Physics news on Phys.org
  • #2
Mathematica's method of evaluating how simple an expression is determines that {{3/2, 5/2}, {9/2, 1/2}} is simpler than 1/2 * {{3, 5}, {9, 1}} and so it will automatically force it back to your undesired form even if you find a way to extract the denominator. Try entering your "simplified" form to confirm this.

Perhaps you can see a way to use this to accomplish what you wish

In[1]:= m = {{3/2, 5/2}, {9/2, 1/2}};c = Apply[LCM, Map[Denominator, Flatten[m]]];{1/c, c*m}

Out[1]= {1/2,{{3, 5}, {9, 1}}}
 
  • #3
Thanks, that's an interesting way to solve it, I wasn't familiar with the use of Apply and Map.

I wonder why mathematica "thinks" that {{3/2, 5/2}, {9/2, 1/2}} is simpler than 1/2 * {{3, 5}, {9, 1}}. (It's a shame that mathematica is not open source, that's so unscientific)
 
  • #4
There are two, sometimes contradictory, things going.

In[6]:=LeafCount[{{3/2,5/2},{9/2,1/2}}]
Out[6]=15
In[7]:=LeafCount[{{3,5},{9,1}}]
Out[7]=7
and so, if it didn't do the multiply, 1/2*m would have a LeafCcount of 11, less than 15 and thus seemingly "simpler."

The other is that operations on numeric values are automatically carried out.

In your example the second one wins.

It is possible to block some automatic operations during display using HoldForm
In[8]:=HoldForm[1/2*{{3,5},{9,1}}]
but all the various Hold functions are a tricky tarpit to enter for most folks.

There are open source alternatives, Axiom, Sage and Maxima are three. But each of those represents 100 or 1000 man years of development and most things of that size are impossible for a novice or even an amateur to really honestly actually read and understand the source and behavior at the level I think you are expecting. Open source is a fine idea, but almost nobody really does this.
 
  • #5


Hello, thank you for your question. There are a few different approaches you can take to factor expressions in a matrix using Mathematica 7. One option is to use the built-in function FactorTerms, which factors out common terms from each element in the matrix. For example:

In[1]:= FactorTerms[{{3/2, 5/2}, {9/2, 1/2}}]

Out[1]:= {{1/2, 5/2}, {9/2, 1/2}}

This function works by finding the greatest common divisor of all the elements in the matrix and factoring it out. However, this may not always give the desired result for more complex matrices.

Another option is to use the function Simplify with the assumption that the elements in the matrix are real numbers. This can be done by using the option "TargetFunctions" -> {Re, Im} to specify that Simplify should only work with real and imaginary parts of expressions. For example:

In[2]:= Simplify[{{3/2, 5/2}, {9/2, 1/2}}, "TargetFunctions" -> {Re, Im}]

Out[2]:= {{1/2, 5/2}, {9/2, 1/2}}

This approach may work better for more complex matrices, but it is important to note that it may not always give the most simplified form.

Lastly, you can also define your own function to factor matrices using Mathematica's pattern matching capabilities. This would involve writing a function that takes in a matrix as an argument, uses pattern matching to identify common factors, and then returns the factored matrix. This approach may give you more control over the specific factors you want to remove from your matrix.

I hope this helps answer your question and gives you some ideas for how to approach factoring expressions in matrices using Mathematica 7.
 

Related to How to factor a expressions in a matrix with mathematica 7?

1. What is the first step in factoring an expression in a matrix with Mathematica 7?

The first step is to enter the expression into Mathematica 7 using proper syntax. This can be done by using the "Factor" function and inputting the expression within the parentheses.

2. How do I know if my expression can be factored in a matrix with Mathematica 7?

You can use the "FactorSquareFree" function in Mathematica 7 to check if the expression can be factored. If the output is the same as the input, then the expression cannot be factored.

3. Can I factor expressions with variables in a matrix using Mathematica 7?

Yes, Mathematica 7 can factor expressions with variables. Just make sure to use proper syntax and input the variables as symbols (e.g. x, y, z).

4. How do I factor a complex expression in a matrix with Mathematica 7?

To factor a complex expression, you can use the "ComplexExpand" function in Mathematica 7 to simplify the expression before using the "Factor" function.

5. Are there any other functions in Mathematica 7 that can help with factoring expressions in a matrix?

Yes, there are several other functions that can aid in factoring expressions in a matrix with Mathematica 7, such as "Simplify", "FullSimplify", and "Collect". It is recommended to experiment with these functions to find the best approach for your specific expression.

Similar threads

Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
956
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top