These are chat archives for symengine/symengine

10th
Jan 2016
Ralf Stephan
@rwst
Jan 10 2016 07:26
@isuruf If I open a second PR with your PR+my commits, can you later add your next commits and put this all in the 1st PR?
Isuru Fernando
@isuruf
Jan 10 2016 07:27
Sure
Ralf Stephan
@rwst
Jan 10 2016 07:27
That's good. So the PRs are just the branches.
@isuruf BTW it seems your repo is not synced because I first tried to do a PR on your repo but got a huge diff.
Isuru Fernando
@isuruf
Jan 10 2016 07:30
Master branch is not synced in github, because it is not needed. I only keep my local copy synced
Ralf Stephan
@rwst
Jan 10 2016 07:31
ah ok, it works with the main repo just as well.
as to #751 there are still test fails but now you can see them yourself
Isuru Fernando
@isuruf
Jan 10 2016 07:32
You will get a diff of your changes if you change the branch from isuruf/symengine master to isuruf/symengine series
Ralf Stephan
@rwst
Jan 10 2016 07:33

-) that's right

that should have been #-)
Isuru Fernando
@isuruf
Jan 10 2016 16:49

@bluescarni, in SymEngine below function is there,

p_expr UPSeriesPiranha::pow(const p_expr &s, int n, unsigned prec) {
    std::cout << "pow " << s << " ** " << n << " prec " << prec << std::endl;
    p_expr::set_auto_truncate_degree(prec - 1);
    p_expr ret = s.pow(n);
    std::cout << "result " << ret << std::endl;
    p_expr::unset_auto_truncate_degree();
    return ret;
}

print statements give the following

pow (-1/3)*x**3+x ** 2 prec 6
result x**2

Do you have any idea what I'm doing wrong?

Ralf Stephan
@rwst
Jan 10 2016 16:51
try prec=7, your x**6 result term gets deleted I guess
ah ok x**4 missing
Isuru Fernando
@isuruf
Jan 10 2016 16:52
This is the reason for the tanh(x) failure
Francesco Biscani
@bluescarni
Jan 10 2016 17:40
@isuruf you there?
I am in a bit of a rush atm, but my guess is that you performed some other exponentiation before on p_expr objects?
Piranha keeps a cache of powers
so it is possible that maybe earlier you computed s**n with some other truncation level, the result gets cached and later when you change the truncation level you get the old result
try as a workaround for the moment to put this at the beginning of the function:
p_expr::clear_pow_cache()
I'll be back later, baby crying :)
Isuru Fernando
@isuruf
Jan 10 2016 17:55
Yes, it was computed earlier with another truncation level. Thanks for the info.
Isuru Fernando
@isuruf
Jan 10 2016 18:47
@rwst, when #753 is merged into #710, all tests pass
Francesco Biscani
@bluescarni
Jan 10 2016 19:02
@isuruf it should actually be a discussion to have, about these power caches
they were introduced to speed up the substitution routine
imagine you have a multivariate polynomial in x,y,z with thousands of terms, and you want to substitute x with a polynomial p say
you will be computing the same natural powers of p over and over, so in this scenario it makes a lot of sense to cache them
but on the other hand they result in problems like the one you ran into
right now pow caches are enabled by default, but maybe they should be an opt-in mechanism instead
Francesco Biscani
@bluescarni
Jan 10 2016 21:39
I had thought that maybe it would make sense to trigger a clear_pow_cache() each time the truncation level is changed, but obviously for your use case this would not be so efficient