2

I have a general query about simplifying expressions in Mathematica, which I will illustrate using quadratics. If I tell Mathematica to simplify $a x^2 + b x + c$ then

  • Simplify will give the same (fully expanded) form $a x^2 + b x + c$
  • FullSimplify will give a form like $((ax+b)x+c)$

Clarification: The coefficients in the simplified form (of course) need not be the same values $a,b,c$. The variable names are meant for demonstration of the format.

Example

poly = x^2 + 4*x + 1
Simplify[poly] (* gives 1 + 4 x + x^2 *)
FullSimplify[poly] (* gives 1 + x (4 + x) *)
(*Desired answer (x+2)^2 - 3 *)

However, I desire the format: $a{(x-b)}^2 + c$ which I find to be more intuitive in "understanding" the expression.

  1. What measure of "expression complexity" does Mathematica work with?
  2. How could I get the kind of result that I want? If possible, I'd like to know how to do this for not just quadratics, but also more complicated polynomial expressions.
Siva
  • 323
  • 4
  • 10
  • Thanks, that addresses a part of my question. But I think my question is a little broader. – Siva Aug 21 '13 at 20:47
  • @Siva I think you should make more precise question in 2). – Kuba Aug 21 '13 at 20:49
  • Contrary to what you state, Simplify and FullSimplify yield the same result for me (c + x (b + a x)). You may have forgotten to insert a space between a and x. As to 1): Have a look at ComplexityFunction, especially the example at the bottom of the page. – Sjoerd C. de Vries Aug 21 '13 at 21:03
  • @SjoerdC.deVries Example added to demonstrate what I see. Simplify and FullSimplify give me different results, unless I'm doing something wrong. I don't understand what you mean by the space between a and x. And thanks, I'll look at ComplexityFunction – Siva Aug 21 '13 at 21:47
  • Since you originally presented your polynomial with symbolic coefficients (a , b, c) that's what I tried. In that case Simplify and FullSimplify yield the same. As to the space: a x^2 differs from ax^2. – Sjoerd C. de Vries Aug 21 '13 at 21:53
  • @Kuba, I understand that Q2 sounds vague, but I don't know how to concretely explain what I mean, since I'm touching on intuition. I apologize for that. In the case of the quadratic, the form I'm looking for immediately lets me visualize the function. Otoh, FullSimplify on the quadratic gives a format convenient for implementing as a recursion but is not easy for me (and presumably others) to intuitively understand. – Siva Aug 21 '13 at 21:54
  • Well, if you don't know what you are expecting how we can? What is intuitive for you does not have to be for others, not to mention that you have not specified what you want to format, polynomials only? To broad question will be closed, but without 2) it will be closed as a duplicate. I hope you understand. – Kuba Aug 21 '13 at 22:03

0 Answers0