Hello, recently I was generating C-style output from GiNaC expressions and ran into the following problems: - the compiled code was inefficient, as common subexpressions are calculated over and over again, - the compiler didn't really appreciate single lines with about one million or more characters. On the mailing list I found that the issue of long lines was already discussed in July 2003, but it seems that this discussion did not lead to additional functionality of GiNaC. To overcome these problems, I wrote a routine which generates optimized C code. This routine - substitutes every subexpression, which occurs more than once with a temporary variable. - splits long expressions into several lines. As this could be of use to other people as well, it could be included into GiNaC. The source files are attached to this mail. An example for this routine would be the following code fragment symbol x("x"), y("y"); ex f = pow(sin(x+y),2)+sin(x+y)+log(sin(x+y)); optimized_C_code(std::cout, std::string("double"), std::string("tmp"), f); which prints double tmp1 = sin(y+x); double tmp0 = tmp1+(tmp1*tmp1)+log(tmp1); to standard output. Best wishes, Stefan