Dear developers,

first let me thank you for the excellent job you are doing.


Recently I have found out a problem during the computation of the numerator and the denominator of expressions involving nested functions. A simple example is enclosed in the file  test_normal.cc . Output of the program linked against the current git repository or the version 1.6.3 is in the file  test_normal.log . Though the denominator of both terms is the same, the program returns the square of it.

I looked into the source code. Seem like functions  replace_with_symbol(const ex & e, exmap & repl, exmap & rev_lookup)  and  replace_with_symbol(const ex & e, exmap & repl)   defined in the file normal.cpp search repl for an original expression but insert into repl alredy substitued expression. Then the repeated search does not work and a new symbol is introduced.
I tried to fix it with the enclosed patch normal.cpp.patch. Is it acceptable as a solution of the problem?

Best regards,
                       Ladislav Zejda