I am experimenting with the ComplexityFunction of Simplify and came up with this one:


It gets the width of the bounding box of the image representation for the expression. The expression which generates an image with less width, is the chosen one. It works, but since it uses Rasterize, it is very slow.

I would like to know if there is a faster way to measure the displayed size the expression output. Any ideas?

  • $\begingroup$ I can't imagine how you could measure an image without generating it first. Perhaps the problem is more like finding another almost equivalent weighting function $\endgroup$ – Dr. belisarius Dec 7 '14 at 22:50
  • $\begingroup$ There is another way, by measuring the BoundingBox. It works, but is slow too. See mathematica.stackexchange.com/questions/67482/… $\endgroup$ – Giovanni F. Dec 8 '14 at 1:03
  • $\begingroup$ You mean ComplexityFunction-> Function[e,StringLength[ToString[InputForm[e]]]] cannot meet request? $\endgroup$ – yode Dec 8 '16 at 6:15
  • $\begingroup$ No, the string representation is not good for some expressions. $\endgroup$ – Giovanni F. Dec 8 '16 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.