Writing a big expression into one line is always hard. I usually simplify the expression further by manually finding some common terms (numerator and denominator) and give it some name. However, this becomes very tiring for very large expressions.
To illustrate what I mean, consider the following examples.
Example-1:
Consider the following expression, $$\frac{(a+b)^2}{1+a+b}$$ It can be seen that $a+b$ can be replaced with some variable, say c, which simplifies the expression to, $$\frac{c^2}{1+c}$$ where, $c = a+b$.
Example-2:
Consider the following expression, $$\frac{x (a+b)+y (c+d+e)^2+z (f+g)^3}{(a+b)^2+c+d+1}$$ It can be seen that $a+b$ can be replaced with some variable, say $m_0$, $c+d$ with $m_1$, and $f+g$ with $m_2$. By using those variables the expression simplifies to, $$\frac{x m_0 + y (m_1+e)^2+z m_2^3}{m_0^2+m_1+1}$$ where, $m_0 = a+b$, $m_1 = c+d$., $m_2 = e+f$.
expr1 = (a+b)^2/(1+a+b)
expr2 = ((a + b) x + (c + d + e)^2 y + (f + g)^3 z)/(1 + (a + b)^2 + c + d)
Question
How do I obtain common terms such as $c$, $m_0$, $m_1$, and $m_2$ automatically without any manual intervention? Is this even possible at all?
I don't have any idea of how to approach this. Can anyone help me with this?
FirstCase[Compile[Evaluate[Variables[expr2]], Evaluate[expr2]], _Function, 0, All]suggestsa + bfor the 2nd expression. – Coolwater May 21 '19 at 18:08Experimental`OptimizeExpressioncould work. – Roman May 24 '19 at 04:50