# How can I simplify a super long expression? [closed]

I am a brand new to using Mathematica, and currently using it for my thesis.

Essentially I have a really long expression made up of lots of parameters.

I am trying to reduce the size of the expression to something a lot smaller.

Just wondering if anyone had any ideas/tips to help me out.

• This probably should be done along the way that generated that expression. What code generated it? – Coolwater Jun 29 '19 at 7:23
• So I defined a pretty convoluted 4x4 matrix (m) and super simple vector (Y). Then used the commands c = Inverse[m].Y --> c1 = c[[1]] – Taylor Jun 29 '19 at 8:44
• Your formulation is not clear: the Normalize command of Mathematica is applicable to vectors and complex numbers only. Please refine your question. – user64494 Jun 29 '19 at 8:53
• To get concrete answers, please ask a concrete question. Right now your question is so abstract that the answers will be equally abstract: try FullSimplify, Simplify, PowerExpand etc. possibly with assumptions? – Roman Jun 29 '19 at 15:29
• Your question may be put on-hold because it's not clear what you need. To avoid or revert the Hold you can edit your question to improve it and make it specific, well-structured and easy to understand. Please don't be discouraged by that cleaning-up policy. Your questions are and will be most welcomed. Learn about good questions here. – rhermans Jul 5 '19 at 16:08

It might help to be familiar with how expressions are structured in the Wolfram Language. Try reading through some of the tutorials here, particularly this one about expressions as trees and then this one about extracting certain levels of these trees.

It looks like your expression has a lot of smaller repeating subexpressions. As far as I know there isn't a great way to deal with simplifying such expressions built into the language; one that would extract these repeating subexpressions, replacing their instances in the original expression with some unique variable and then annotating the whole thing with maybe an Inactive[With] to mimic the "where x = ..." often seen in mathematical literature.

One thing you can do to approximate this feature is to enumerate all of the subexpressions that appear in your expression and see which ones appear most often, then do a simple ReplaceAll. For example, if you have an expression like the following

assigned to a symbol called expr, I could do the following

Level[expr, -5] // Tally // MaximalBy[Last]

to find which subexpression (subtree) with height of at least 5 occurs most often. Assigning this subexpression to subexpr and then using ReplaceAll you get

expr /. subexpr -> x

which is clearly a much smaller and more manageable expression.

While not a comprehensive answer, hopefully this gives you some additional avenues to explore beyond what other users have suggested.