@certik : Sorry Ondrej, I was busy during the weekend. Couldn't involve in any development work in CSymPy.

( 2*x) is represented as `coef_`

= 2 and `dict_`

= {x: -1}

(x/2) is represented as `coef_`

= 1/2 (`pownum`

simplifies 2^-1 as -1 is an `Integer`

), `dict_`

= {x: 1}, so no problems arises when multiplying these two terms as `coef_`

s and `dict_`

s get simplified separately.

But how can we provide a solution to the case 2*2^(-1/2) ? How can we simplify that without knowing the structure of coef? 2*2(-1/2) is created by first inserting into

`dict_`

(2, 1) and then (2, -1/2). Since, the first tuple can be simplified with csympy (`pownum`

simplifies the expression if exponent is an `Integer`

), it's multiplied with the `coef_`

without keying it in `dict_`

. Then `(2, -1/2)`

is inserted, but this can't be simplified further. So it is keyed in the `dict_`

with 2 as the key and -1/2 as the value. When printing it prints as 2*2^(-1/2) according to the internal representation. Only work around I can think of here is, as you have suggested earlier, do the simplification of the numerical terms at the end, i.e. we insert both (2, 1) and (2, -1/2) to `dict_`

(then the `dict_`

will be `{2: -1/2}`

) and then run a for loop to see which terms can be simplified and multiplied with `coef_`

. But that will slow down things a bit.
@isuruf : Can't we make our implementation of

`primesieve`

to have a similar API to `primesieve.org`

? That way we can do something similar to what we do with `RCP`

and `csympy_rcp`

?